ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.54k stars 1.29k forks source link

A10 - NetmikoTimeoutException #1686

Closed bpastravanu closed 2 years ago

bpastravanu commented 4 years ago

I am running bellow, and the config is being pushed to the device, but I still get some timeout errors back:

!/usr/bin/env python

from netmiko import Netmiko from getpass import getpass from netmiko.a10 import A10SSH

a10_lab = { "host": "172.16..131.200", "username": "admin", "password": "a10", "device_type": "a10", "secret": " ", "session_log": ".../session_log.txt", }

cfg_file = ".../config_changes.txt" net_connect = Netmiko(**a10_lab) net_connect.enable()

print() print(net_connect.find_prompt())

output = net_connect.send_config_from_file(cfg_file) print(output) print()

net_connect.save_config() net_connect.disconnect()

Exceptions bellow:

Traceback (most recent call last): File "/home/boddo0504/.local/lib/python3.6/site-packages/paramiko/channel.py", line 699, in recv out = self.in_buffer.read(nbytes, self.timeout) File "/home/boddo0504/.local/lib/python3.6/site-packages/paramiko/buffered_pipe.py", line 164, in read raise PipeTimeout() paramiko.buffered_pipe.PipeTimeout During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/boddo0504/.local/lib/python3.6/site-packages/netmiko/base_connection.py", line 550, in _read_channel_expect new_data = self.remote_conn.recv(MAX_BUFFER) File "/home/boddo0504/.local/lib/python3.6/site-packages/paramiko/channel.py", line 701, in recv raise socket.timeout() socket.timeout During handling of the above exception, another exception occurred: Traceback (most recent call last): File "a10_config_change.py", line 34, in output = net_connect.send_config_from_file(cfg_file) File "/home/boddo0504/.local/lib/python3.6/site-packages/netmiko/base_connection.py", line 1665, in send_config_from_file return self.send_config_set(cfg_file, *kwargs) File "/home/boddo0504/.local/lib/python3.6/site-packages/netmiko/base_connection.py", line 1759, in send_config_set new_output = self.read_until_pattern(pattern=pattern) File "/home/boddo0504/.local/lib/python3.6/site-packages/netmiko/base_connection.py", line 627, in read_until_pattern return self._read_channel_expect(args, **kwargs) File "/home/boddo0504/.local/lib/python3.6/site-packages/netmiko/base_connection.py", line 561, in _read_channel_expect "Timed-out reading channel, data not available." netmiko.ssh_exception.NetmikoTimeoutException: Timed-out reading channel, data not available.

########### Session log captured############

Last********login:********Wed********Apr********22********09:32:18********2020********from********172.16.131.185
System********is********ready********now.
[type********?********for********help]
vThunder(NOLICENSE)>
vThunder(NOLICENSE)>
vThunder(NOLICENSE)>enable
Password:
vThunder(NOLICENSE)#
vThunder(NOLICENSE)#terminal********length********0
vThunder(NOLICENSE)#
vThunder(NOLICENSE)#
vThunder(NOLICENSE)#config
vThunder(config)(NOLICENSE)#!
vThunder(config)(NOLICENSE)#slb********virtual-server********vs100********10.10.100.1********/24
vThunder(config-slb********vserver)(NOLICENSE)#port********8080********tcp
vThunder(config-slb********vserver-vport)(NOLICENSE)#conn-limit********1
vThunder(config-slb********vserver-vport)(NOLICENSE)#bucket-count********1
vThunder(config-slb********vserver-vport)(NOLICENSE)#!
vThunder(config-slb********vserver-vport)(NOLICENSE)#wr********mem
Building********configuration...
Write********configuration********to********default********primary********startup-config
[OK]
vThunder(config-slb********vserver-vport)(NOLICENSE)#!
vThunder(config-slb********vserver-vport)(NOLICENSE)#end
vThunder(NOLICENSE)#exit
vThunder(NOLICENSE)>exit
Are********you********sure********to********quit********(N/Y)?:********
ktbyers commented 4 years ago

Someone would probably need to do a PR on the A-10 driver.

I don't really no what is going on with all those * characters in the session log that is a bit odd.

Items I see that might be an issue:

  1. Why didn't it automatically exit from configuration mode at the end of send_config_from_file.
  2. The prompting you to quit at the end of the disconnect--that would require a special handler in Netmio.

Also your exception message doesn't match up with your session_log. Your exception indicates failure on send_confg_from_file whereas your session_log looks like it went all the way to the disconnect() call.

bpastravanu commented 4 years ago

Thanks for the quick turnaround Kirk. For

  1. can I manually force it to exit?
  2. I also tried bellow:

if "sure" in output: output += net_connect.send_comand("Y")

bpastravanu commented 4 years ago

By enabling logging of reads and writes of the communications channel, I can see the same behaviour as in the logs previously captured, config is being sent.

DEBUG:netmiko:Pattern found: (?:vThunder(NOLICENSE)|#) Building configuration... Write configuration to default primary startup-config [OK] vThunder(config-slb vserver-vport)(NOLICENSE)# DEBUG:netmiko:write_channel: b'!\n' DEBUG:netmiko:Pattern is: ! DEBUG:netmiko:_read_channel_expect read_data: ! vThunder(config-slb vserver-vport)(NOLICENSE)# DEBUG:netmiko:Pattern found: ! ! vThunder(config-slb vserver-vport)(NOLICENSE)# DEBUG:netmiko:write_channel: b'end\n' DEBUG:netmiko:Pattern is: end DEBUG:netmiko:_read_channel_expect read_data: end vThunder(NOLICENSE)# DEBUG:netmiko:Pattern found: end end vThunder(NOLICENSE)# DEBUG:netmiko:write_channel: b'exit\n' DEBUG:netmiko:Pattern is: exit DEBUG:netmiko:_read_channel_expect read_data: exit vThunder(NOLICENSE)> DEBUG:netmiko:Pattern found: exit exit vThunder(NOLICENSE)> DEBUG:netmiko:write_channel: b'exit\n' DEBUG:netmiko:Pattern is: exit DEBUG:netmiko:_read_channel_expect read_data: e DEBUG:netmiko:_read_channel_expect read_data: xit Are you sure to quit (N/Y)?: DEBUG:netmiko:Pattern found: exit exit Are you sure to quit (N/Y)?: DEBUG:netmiko:Pattern is: (?:vThunder(NOLICENSE)|#)

sbo-7455 commented 4 years ago

Hi, I'm interested to get the final solution to this issue, I have similar errors and wish to get alternative solutions to my scrip that configures a login banner on multiple cisco devices.

bpastravanu commented 4 years ago

Hi, no solution yet. @ktbyers , how can I do that PR on the A10 driver?

ktbyers commented 2 years ago

@sbo-7455 @bpastravanu Is anyone still working on this? If I create a fix for it, is someone available/willing to test it?

ktbyers commented 2 years ago

If anyone has an A10 device and is willing to test a fix, just let me know and I can re-open this issue.