HOW TO Connect to "MULTIPLE ROUTERS" and Execute "MULTIPLE CLI COMMANDS" using SIMPLE PYTHON SCRIPT

Опубликовано: 01 Март 2023
на канале: Network Tips and Topics
133
3

BASIC PYTHON SCRIPT: Connect to Multiple routers and Execute Multiple Commands

Full script is below

lab@admin:~$ cat T1
from netmiko import Netmiko
from getpass import getpass
username = input('Enter your SSH username: ')
password=getpass()


with open('Commands-to-run') 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)
for x in commands_to_send:
output = net_connect.send_command(x) + "\n"
print(output)

net_connect.disconnect()


Смотрите видео HOW TO Connect to "MULTIPLE ROUTERS" and Execute "MULTIPLE CLI COMMANDS" using SIMPLE PYTHON SCRIPT онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Network Tips and Topics 01 Март 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 133 раз и оно понравилось 3 людям.