from netmiko import ConnectHandler iosv_l2_s1 = { ‘device_type’: ‘cisco_ios’, ‘ip’: ‘192.168.10.21’, ‘username’: ‘rachit’, ‘password’: ‘cisco’, ‘secret’: ‘cisco’ } iosv_l2_s2 = { ‘device_type’: ‘cisco_ios’, ‘ip’: ‘192.168.10.22’, ‘username’: ‘rachit’, ‘password’: ‘cisco’, ‘secret’: ‘cisco’ } iosv_l2_s3 = { ‘device_type’: ‘cisco_ios’, ‘ip’: ‘192.168.10.23’, ‘username’: ‘rachit’, ‘password’: ‘cisco’, ‘secret’: ‘cisco’ } all_devices = [iosv_l2_s1, iosv_l2_s2, iosv_l2_s3] for devices in all_devices: net_connect = ConnectHandler(**devices) net_connect.enable() for n in range (2,5): 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 |