I have been doing some network automation, now I am working with for lops to be able to do not only one at time, so when I ran the code below I see the first router it is successful but the second one has the error netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, data not available.
So I am testing with 3 routers, the first goes well but the second one never works.
from netmiko import Netmiko
from getpass import getpass
import re
router1 = {
"host": "10.0.0.248",
"username": "cisco",
"password": "cisco",
"device_type": "cisco_ios",
}
router2 = {
"host": "10.0.0.247",
"username": "cisco",
"password": "cisco",
"device_type": "cisco_ios",
}
router3 = {
"host": "10.0.0.246",
"username": "cisco",
"password": "cisco",
"device_type": "cisco_ios",
}
routers = [router1, router2, router3]
interface_shut = list()
for router in routers:
net_connect = Netmiko(**router)
print(net_connect.find_prompt())
output = net_connect.send_command("show ip int br")
print(output)
find_interfaces = re.findall("GigabitEthernet\d.\d", output)
print(find_interfaces)
for int in find_interfaces:
interface_shut.append("Interface " int)
interface_shut.append("no shut")
output2 = net_connect.send_config_set(interface_shut)
print(output2)
interface_shut = list() # I am doing this so the list doesnt have to have more than 3 items for each device
print(interface_shut)
net_connect.disconnect()
CodePudding user response:
That was my bad. The code is working fine. I just forgot to add the priv 15 in the other 2 routers.