From bff275402efb21f4415e0cec2aabcf6076325835 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Sun, 1 Nov 2026 00:33:32 +0100 Subject: [PATCH] fix: keep linux.py within its line count (quality ratchet) One handler for the two netmiko failures that both became a ConnectionException, and the retry's note on its own line. --- napalm_linux/linux.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/napalm_linux/linux.py b/napalm_linux/linux.py index c219a97..800ff01 100644 --- a/napalm_linux/linux.py +++ b/napalm_linux/linux.py @@ -391,10 +391,7 @@ class LinuxDriver( """Open the SSH connection and detect the package manager.""" try: with self._host_key.netmiko(self.netmiko_optional_args) as netmiko_args_: - # Again after a pause when sshd closes the connection before its - # banner: OpenSSH 9.8+ does that to a source it has just - # penalised (NetOrk/netork#1800). - self._device = retry_refused( + self._device = retry_refused( # waits out sshd's penalty (NetOrk/netork#1800) lambda: ConnectHandler( device_type=self.NETMIKO_DEVICE_TYPE, host=self.hostname, @@ -406,9 +403,7 @@ class LinuxDriver( **netmiko_args_, ) ) - except NetmikoAuthenticationException as exc: - raise ConnectionException(str(exc)) from exc - except NetmikoTimeoutException as exc: + except (NetmikoAuthenticationException, NetmikoTimeoutException) as exc: raise ConnectionException(str(exc)) from exc self._host_key.observe(self._device.remote_conn_pre.get_transport())