New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetMiko timeout issue when connecting to IOSv_L2 (VIRL) device #721

Closed
magic9669 opened this Issue Feb 17, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@magic9669
Copy link

magic9669 commented Feb 17, 2018

I am working on an automation course and following along, I cannot get netmiko to work properly. I built a lab of 5 switches, and my script just goes in, configures the interfaces for trunk or access ports depending on the interface, and creates a vlan. That's it. Sometimes, it will work on one or two devices before failing, other times, it just fails after trying to connect to the first switch.

I'm using GNS3 VM with this along with the VIRL image for the L2 switch. I've read a couple of similar issues on here so I tried adding a delay, not using the 'interface range' command, etc. I am not having any luck. Below is the script, commands and the output of the error. Any help would be appreciated. Thank you.

-Michael

#!/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


vlan 2
int g2/0
switchport mode access
switchport access vlan 2
int g2/1
switchport mode access
switchport access vlan 2
int g2/2
switchport mode access
switchport access vlan 2
int g2/3
switchport mode access
switchport access vlan 2
int g0/0
switchport trunk encap dot
switchport mode trunk
switchport nonegotiate
switchport trunk allowed vlan 1,2
int g0/1
switchport trunk encap dot
switchport mode trunk
switchport nonegotiate
switchport trunk allowed vlan 1,2
int g0/2
switchport trunk encap dot
switchport mode trunk
switchport nonegotiate
switchport trunk allowed vlan 1,2
int g0/3
switchport trunk encap dot
switchport mode trunk
switchport nonegotiate
switchport trunk allowed vlan 1,2
int g1/0
switchport trunk encap dot
switchport mode trunk
switchport nonegotiate
switchport trunk allowed vlan 1,2
int g1/1
switchport trunk encap dot
switchport mode trunk
switchport nonegotiate
switchport trunk allowed vlan 1,2


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.

@ktbyers

This comment has been minimized.

Copy link
Owner

ktbyers commented Feb 9, 2019

Probably not enough information here to do anything.

@ktbyers ktbyers closed this Feb 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment