Advertisement
mikulc

test

Jun 25th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. from netaddr import IPAddress
  4. from netmiko import ConnectHandler
  5.  
  6. N9K1 = {"ip":"10.1.100.91", "device_type":"cisco_nxos","username":"admin","password":"Cisco123$"}
  7. N9K2 = {"ip":"10.1.100.92", "device_type":"cisco_nxos","username":"admin","password":"Cisco123$"}
  8. core = {"ip":"10.1.100.100", "device_type":"cisco_ios","username":"admin","password":"Cisco123$"}
  9.  
  10. devices_list = [N9K1, N9K2, core]
  11.  
  12. for device in devices_list:
  13.  
  14. connection = ConnectHandler(**device)
  15. connection.enable()
  16.  
  17. if device['device_type'] == 'cisco_nxos':
  18. hostname = connection.send_command('show hostname')
  19. licenseid = connection.send_command('show license host-id')
  20. else:
  21. hostname = connection.send_command('show run | i host')
  22. hostname = hostname.replace('hostname ', '')
  23. licenseid = 'License hostid: no license '
  24.  
  25. connection.disconnect()
  26.  
  27. print('Host [{}] {} {}'.format(device['ip'], hostname, licenseid))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement