0% found this document useful (0 votes)
12 views1 page

Code 1st To Get Ip Cisco

Uploaded by

shahzaibmalik009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Code 1st To Get Ip Cisco

Uploaded by

shahzaibmalik009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

from netmiko import ConnectHandler

from netmiko import NetMikoTimeoutException


from paramiko.ssh_exception import SSHException

my_devices = ['192.168.153.10','192.168.153.20','192.168.23.30','192.168.23.40']
device_list = list() #create an empty list to use it later

for device_ip in my_devices:


try:
device = {
"device_type": "cisco_ios",
"host": device_ip,
"username": "test",
"password":"test"
}
device_list.append(device)

for each_device in device_list:


connection = ConnectHandler(**each_device)
output = connection.send_command('show ip interface brief',)
print(output)
connection.disconnect()
except (EOFError, SSHException):
print(f'SSH Session timed-out trying to connect to:{each_device["host"]}')

You might also like