-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiarea OSPF_Network Automation using Python .py
74 lines (62 loc) · 2.11 KB
/
Multiarea OSPF_Network Automation using Python .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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
from netmiko import ConnectHandler
import os
iosv_l3_r1 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.11',
'username': 'badrik',
'password': 'cisco',
}
iosv_l3_r2 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.12',
'username': 'badrik',
'password': 'cisco',
}
iosv_l3_r3 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.13',
'username': 'badrik',
'password': 'cisco',
}
def configuration():
net_connect = ConnectHandler(**devices)
output = net_connect.send_config_set(lines)
print(output)
def output():
net_connect = ConnectHandler(**devices)
#net_connect.find_prompt()
command = raw_input("Type the priviledge mode command to find required information")
output = net_connect.send_command(command)
return output
all_devices = [iosv_l3_r1,iosv_l3_r2,iosv_l3_r3]
for devices in all_devices:
if devices == iosv_l3_r1:
with open('R1.txt') as f:
lines = f.read().splitlines()
print(lines)
configuration()
output()
if devices == iosv_l3_r2:
with open('R2.txt') as f:
lines = f.read().splitlines()
print(lines)
configuration()
if devices == iosv_l3_r3:
with open('R3.txt') as f:
lines = f.read().splitlines()
print(lines)
configuration()
print("\nType the device name from the mentioned below:")
for devices in all_devices:
print(devices)
device = raw_input("Enter the name: \t")
net_connect = ConnectHandler(**device)
command = raw_input("\nType the priviledge mode command to find required information")
output = net_connect.send_command(command)
print(output)
File = raw_input("\nDo you want to save output in a file.?")
if File == "Yes" or "yes":
os.system("touch output.txt")
with open("output.txt","w") as f:
f.write(output)