-
Notifications
You must be signed in to change notification settings - Fork 0
/
netmiko.py
36 lines (32 loc) · 1005 Bytes
/
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
#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass
#Input is asking for username, and getpass is asking for the password.
username = input("Enter your username")
password = getpass()
cisco1 = {
"host": "192.168.0.1",
"username": username,
"password": password,
"device_type": "cisco_ios",
}
cisco2 = {
"host": "192.168.0.2",
"username": username,
"password": password,
"device_type": "cisco_ios",
}
#Runnning three commands (command1, 2 and 3) through all devices, and then print the three commands.
for device in (cisco1, cisco2):
net_connect = Netmiko(**device)
command1 = "show env power"
command2 = "show power inline"
command3 = "show cdp nei | i AP"
print(net_connect.find_prompt())
output1 = net_connect.send_command(command1)
output2 = net_connect.send_command(command2)
output3 = net_connect.send_command(command3)
net_connect.disconnect()
print(output1)
print(output2)
print(output3)