How to configure multiple vendors devices using same script. Demonstrates NXOS, Cisco, Arista devices. NAPALM getfacts output.
Define individual device list for each vendor and use for loop for configuraing individual devices using Python.
import json
from napalm import get_network_driver
cisco = ['192.168.67.47']
arista = ['192.168.67.30']
for cisco_ip in cisco:
print ("Connecting to Cisco Device " + str(cisco_ip))
driver = get_network_driver('ios')
cisco_device = driver(cisco_ip, 'admin', 'admin')
cisco_device.open()
facts = cisco_device.get_facts()
print (json.dumps(facts,sort_keys=True, indent=4))
cisco_device.close()
for arista_ip in arista:
print ("Connecting to Arista Device " + str(arista_ip))
driver = get_network_driver('eos')
arista_device = driver(arista_ip, 'admin', 'admin')
arista_device.open()
facts = arista_device.get_facts()
# print (json.dumps(facts,sort_keys=True, indent=4))
print ('Device '+ str(arista_ip) + ' Software version is ' + facts['os_version'])
arista_device.close()
Define individual device list for each vendor and use for loop for configuraing individual devices using Python.
import json
from napalm import get_network_driver
cisco = ['192.168.67.47']
arista = ['192.168.67.30']
for cisco_ip in cisco:
print ("Connecting to Cisco Device " + str(cisco_ip))
driver = get_network_driver('ios')
cisco_device = driver(cisco_ip, 'admin', 'admin')
cisco_device.open()
facts = cisco_device.get_facts()
print (json.dumps(facts,sort_keys=True, indent=4))
cisco_device.close()
for arista_ip in arista:
print ("Connecting to Arista Device " + str(arista_ip))
driver = get_network_driver('eos')
arista_device = driver(arista_ip, 'admin', 'admin')
arista_device.open()
facts = arista_device.get_facts()
# print (json.dumps(facts,sort_keys=True, indent=4))
print ('Device '+ str(arista_ip) + ' Software version is ' + facts['os_version'])
arista_device.close()
- Category
- Routers and Switches
Be the first to comment