Skip to content
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

nxos_ssh devices with Netmiko 3.1 fail on is_alive() call #1211

Closed
xschlef opened this issue May 12, 2020 · 3 comments
Closed

nxos_ssh devices with Netmiko 3.1 fail on is_alive() call #1211

xschlef opened this issue May 12, 2020 · 3 comments

Comments

@xschlef
Copy link

xschlef commented May 12, 2020

Description of Issue/Question

This is the same issue as #1128 but with nxos_ssh.
Downgrading to netmiko 2.4.2 fixed the issue, but I think the logic has to be fixed here as well.

Setup

napalm version

3.0

Network operating system version

nxos

Steps to Reproduce the Issue

Error Traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/paramiko/channel.py", line 699, in recv
    out = self.in_buffer.read(nbytes, self.timeout)
  File "/usr/local/lib/python3.7/dist-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 "/usr/local/lib/python3.7/dist-packages/netmiko/base_connection.py", line 550, in _read_channel_expect
    new_data = self.remote_conn.recv(MAX_BUFFER)
  File "/usr/local/lib/python3.7/dist-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 "/usr/local/lib/python3.7/dist-packages/napalm/nxos_ssh/nxos_ssh.py", line 509, in is_alive
    self._send_command(null)
  File "/usr/local/lib/python3.7/dist-packages/napalm/nxos_ssh/nxos_ssh.py", line 447, in _send_command
    return self.device.send_command(command)
  File "/usr/local/lib/python3.7/dist-packages/netmiko/utilities.py", line 347, in wrapper_decorator
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/netmiko/base_connection.py", line 1389, in send_command
    new_data = self.read_until_pattern(pattern=re.escape(cmd))
  File "/usr/local/lib/python3.7/dist-packages/netmiko/base_connection.py", line 627, in read_until_pattern
    return self._read_channel_expect(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-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.
@ktbyers ktbyers changed the title Latest 3.0 failing to connect nxos_ssh devices with Netmiko 3.1 nxos_ssh devices with Netmiko 3.1 fail on is_alive() call May 12, 2020
@ktbyers
Copy link
Contributor

ktbyers commented May 12, 2020

@xschlef Can you post your NAPALM code corresponding to the exception. Thanks.

The exception above happens in the is_alive() call.

@xschlef
Copy link
Author

xschlef commented May 13, 2020

I have wrapped all calls which checks if the connection is still alive.

def connection_alive(f):
    """ decorator for all functions that require a working connection """

    @wraps(f)
    def wrapper(*args, **kwargs):
        if "hostname" not in kwargs:
            raise Exception("Supply a hostname.")
        if kwargs['hostname'] not in CONNECTIONS:
            raise Exception(
                "There is no existing connection to %s." % kwargs['hostname'])
        if not CONNECTIONS[kwargs['hostname']].is_alive():
            raise Exception("No alive connection to %s." % kwargs['hostname'])

        return f(*args, **kwargs)

    return wrapper

@ktbyers
Copy link
Contributor

ktbyers commented May 13, 2020

Proposed fix:

#1214

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

No branches or pull requests

3 participants