HOW TO CONFIGURE MULTIPLE ROUTERS OR SWITCHES USING A "CONFIGURATION FILE" WITH PYTHON SCRIPT

Published: 06 March 2023
on channel: Network Tips and Topics - Plexinor
108
1

"Want more expert insights and updates? Follow us on LinkedIn and explore our company page to connect with us directly. Don’t miss out - click the link and join the conversation!"

Follow us on LinkedIn   / plexinor  
Company Website Https://www.plexinor.com

HOW TO CONFIGURE MULTIPLE ROUTERS, SWITCHES USING SIMPLE PYTHON Script

Full script is below

lab@admin:~$ cat Config-Multiple-device-using-Config-File
from netmiko import Netmiko
from getpass import getpass
username = input('Enter your SSH username: ')
password=getpass()

with open('Changes') as f:
commands_to_send = f.read().splitlines()
print (commands_to_send)

with open('Device-IP-List') as f:
devices = f.read().splitlines()
print (devices)

for router in devices:
print ('Connecting to device ====================" ' + router)
ip_address_of_device = router
junos_devices = {
'device_type': 'juniper_junos',
'ip': ip_address_of_device,
'username': username,
'password': password
}


all_devices = [junos_devices]


for devices in all_devices:
net_connect = Netmiko(**devices)
print(net_connect.find_prompt())
output = net_connect.send_config_set(commands_to_send, exit_config_mode=False)
output += net_connect.commit(and_quit=True)
print(output)


Watch video HOW TO CONFIGURE MULTIPLE ROUTERS OR SWITCHES USING A "CONFIGURATION FILE" WITH PYTHON SCRIPT online without registration, duration hours minute second in high quality. This video was added by user Network Tips and Topics - Plexinor 06 March 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 108 once and liked it 1 people.