-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9_Python1_netmiko.py
executable file
·47 lines (42 loc) · 1.1 KB
/
9_Python1_netmiko.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Configure multiple config lines...reading from file iosv2_l2_cisco_design, iosv_core_design
# switches using netmiko library
# CORE as well as ACCESS SWITCHES
from netmiko import ConnectHandler
iosv_l2_s2 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.72',
'username': 'cisco',
'password': 'cisco',
}
iosv_l2_s3 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.73',
'username': 'cisco',
'password': 'cisco',
}
iosv_l2_s4 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.74',
'username': 'cisco',
'password': 'cisco',
}
iosv_l2_s5 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.75',
'username': 'cisco',
'password': 'cisco',
}
iosv_l2_s6 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.76',
'username': 'cisco',
'password': 'cisco',
}
with open('iosv_core_design') as f:
lines = f.read().splitlines()
print(lines)
all_devices = [iosv_l2_s6, iosv_l2_s5, iosv_l2_s4, iosv_l2_s3, iosv_l2_s2]
for devices in all_devices:
net_connect = ConnectHandler(**devices)
output = net_connect.send_config_set(lines)
print(output)