netmiko import
ConnectHandler
user = input("Enter
the Username: ")
passwd = input("Enter
the pass: ")
cisco_switch = {
'device_type':
'cisco_ios',
'host':
input("Enter
the IP address: "),
'username':
user,
'password':
passwd,
'port':
22, #
optional, defaults to 22
'secret':
'secret', #
optional, defaults to ''
}
net_connect = ConnectHandler(**cisco_switch)
print("What
do you want to see in switch: \n 1--VLAN\n
2--INETRFACE_IP\n 3--RUNING_CONFIG\n
4--STARTUP_CONFIG\n 5--TRUNK_PORTS\n
6--SPANING_TREE\n
7--MAC_ADDRESS_TABLE\n
8--ETHERCHANNEL/PORT-CHANNEL\n
9--IP_ROUTE_DATABASE\n")
while True:
op
= int(input("Enter
your answer: "))
if
op == 1:
output
= net_connect.send_command('sh
vlan br')
print(output)
print(100*"*")
elif
op == 2:
net_connect.enable
output
= net_connect.send_command('sh
ip int br')
print(output)
print(100*"*")
elif
op == 3:
output
= net_connect.send_command('sh
running-config')
print(output)
print(100*"*")
elif
op == 4:
output
= net_connect.send_command('sh
startup-config')
print(output)
print(100*"*")
elif
op == 5:
output
= net_connect.send_command('sh
interfaces trunk')
print(output)
print(100*"*")
elif
op == 6:
output
= net_connect.send_command('sh
spanning-tree summary')
print(output)
print(100*"*")
elif
op == 7:
output
= net_connect.send_command('sh
mac address-table')
print(output)
print(100*"*")
elif
op == 8:
output
= net_connect.send_command('sh
etherchannel summary')
print(output)
print(100*"*")
elif
op == 9:
output
= net_connect.send_command('sh
ip route')
print(output)
print(100*"*")
elif
op == 0:
exit(0)
else:
print("!!Invalid
input")
OUTPUT:
-
Comments
Post a Comment