Basic SW configs:
!
hostname SX
!
enable password cisco
!
username adrian privilege 15 password 0 cisco
no aaa new-model
!
ip domain-name cciepython.com
!
!
interface Vlan1
ip address 192.168.122.X 255.255.255.0
line vty 0 4
login local
transport input ssh
!
crypto key generate rsa
1024
.
#!/usr/bin/env python | |
from netmiko import ConnectHandler | |
iosv_l2_s1 = { | |
'device_type': 'cisco_ios', | |
'ip': '192.168.122.71', | |
'username': 'adrian', | |
'password': 'cisco', | |
} | |
iosv_l2_s2 = { | |
'device_type': 'cisco_ios', | |
'ip': '192.168.122.72', | |
'username': 'adrian', | |
'password': 'cisco', | |
} | |
iosv_l2_s3 = { | |
'device_type': 'cisco_ios', | |
'ip': '192.168.122.73', | |
'username': 'adrian', | |
'password': 'cisco', | |
} | |
all_devices = [iosv_l2_s1, iosv_l2_s2, iosv_l2_s3] | |
for devices in all_devices: | |
net_connect = ConnectHandler(**devices) | |
for n in range (2,21): | |
print "Creating VLAN " + str(n) | |
config_commands = ['vlan ' + str(n), 'name Python_VLAN ' + str(n)] | |
output = net_connect.send_config_set(config_commands) | |
print output |
No comments:
Post a Comment