Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- from netaddr import IPAddress
- from netmiko import ConnectHandler
- N9K1 = {"ip":"10.1.100.91", "device_type":"cisco_nxos","username":"admin","password":"Cisco123$"}
- N9K2 = {"ip":"10.1.100.92", "device_type":"cisco_nxos","username":"admin","password":"Cisco123$"}
- core = {"ip":"10.1.100.100", "device_type":"cisco_ios","username":"admin","password":"Cisco123$"}
- devices_list = [N9K1, N9K2, core]
- for device in devices_list:
- connection = ConnectHandler(**device)
- connection.enable()
- if device['device_type'] == 'cisco_nxos':
- hostname = connection.send_command('show hostname')
- licenseid = connection.send_command('show license host-id')
- else:
- hostname = connection.send_command('show run | i host')
- hostname = hostname.replace('hostname ', '')
- licenseid = 'License hostid: no license '
- connection.disconnect()
- print('Host [{}] {} {}'.format(device['ip'], hostname, licenseid))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement