Wednesday, February 21, 2018

Issue with a NetMiko script

Hello all.

I'm going through a Udemy course regarding automation tools and i'm stuck on a NetMiko script. I don't understand the output of the error so i'm hoping someone can help. I posted my issue on github here: https://github.com/ktbyers/netmiko/issues/721

Essentially, The script will run, and either fail right after trying to connect to the first host, or it will connect to a host and then fail on the second, etc. It's not a STP issue as I statically configured S1 to be the primary for all vlans.

Any help would be appreciated. Here is the script along with the error:

!/usr/bin/env python

from netmiko import ConnectHandler

iosv_l2_s1 = { 'device_type': 'cisco_ios', 'ip': '192.168.122.71', 'username': 'michael', 'password': 'cisco', }

iosv_l2_s2 = { 'device_type': 'cisco_ios', 'ip': '192.168.122.72', 'username': 'michael', 'password': 'cisco', }

iosv_l2_s3 = { 'device_type': 'cisco_ios', 'ip': '192.168.122.73', 'username': 'michael', 'password': 'cisco', }

iosv_l2_s4 = { 'device_type': 'cisco_ios', 'ip': '192.168.122.74', 'username': 'michael', 'password': 'cisco', }

iosv_l2_s5 = { 'device_type': 'cisco_ios', 'ip': '192.168.122.75', 'username': 'michael', 'password': 'cisco', }

with open('iosv_l2_config') as f: lines = f.read().splitlines() print lines

all_devices = [iosv_l2_s5, iosv_l2_s4, iosv_l2_s3, iosv_l2_s2, iosv_l2_s1]

for devices in all_devices: net_connect = ConnectHandler(**devices)

Try delay_factor =2 and if that doesn't work 4

output = net_connect.send_config_set(lines, delay_factor=5) print output


Traceback (most recent call last): File "netmiko3", line 51, in output = net_connect.send_config_set(lines, delay_factor=5) File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 1131, in send_config_set output += self.exit_config_mode() File "/usr/local/lib/python2.7/dist-packages/netmiko/cisco_base_connection.py", line 51, in exit_config_mode pattern=pattern) File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 1081, in exit_config_mode if self.check_config_mode(): File "/usr/local/lib/python2.7/dist-packages/netmiko/cisco_base_connection.py", line 33, in check_config_mode pattern=pattern) File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 1065, in check_config_mode output = self.read_until_pattern(pattern=pattern) File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 449, in read_until_pattern return self._read_channel_expect(args, *kwargs) File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 384, in _read_channel_expect raise NetMikoTimeoutException("Timed-out reading channel, data not available.") netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.



No comments:

Post a Comment