No files matched your search
@@ -20,6 +20,13 @@ All notable changes to this driver. The format follows
|
|||||||
- A Netgear Plus switch is no longer offered as a ping-sweep source
|
- A Netgear Plus switch is no longer offered as a ping-sweep source
|
||||||
(`supports_ping()` is `False`): its `ping` only raised, so every target of a sweep
|
(`supports_ping()` is `False`): its `ping` only raised, so every target of a sweep
|
||||||
came back as an error. `ping` still raises `NotImplementedError`, now NAPALM's own.
|
came back as an error. `ping` still raises `NotImplementedError`, now NAPALM's own.
|
||||||
|
- The Smart driver no longer adds its connection defaults (`conn_timeout`,
|
||||||
|
`banner_timeout`, `disabled_algorithms`) to the `optional_args` dict the caller
|
||||||
|
passed in.
|
||||||
|
- An unexpected error while connecting to a Smart switch is reported in English
|
||||||
|
("Cannot connect to <host>: <reason>").
|
||||||
|
- `requirements.txt` is gone: it repeated the dependencies of `pyproject.toml` with
|
||||||
|
older floors (napalm 4.0, napalm-device-types 4.16) than the driver needs.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- **Breaking:** the Netgear Plus driver no longer has `set_vlan`, `delete_vlan` and
|
- **Breaking:** the Netgear Plus driver no longer has `set_vlan`, `delete_vlan` and
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ class NetgearSmartDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver):
|
|||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.device: ConnectHandler | None = None
|
self.device: ConnectHandler | None = None
|
||||||
|
|
||||||
if optional_args is None:
|
# A copy: the defaults below must not end up in the caller's dict (#7).
|
||||||
optional_args = {}
|
optional_args = dict(optional_args or {})
|
||||||
|
|
||||||
self.force_no_enable = optional_args.get("force_no_enable", False)
|
self.force_no_enable = optional_args.get("force_no_enable", False)
|
||||||
self.port = optional_args.get("port", 22)
|
self.port = optional_args.get("port", 22)
|
||||||
@@ -165,10 +165,7 @@ class NetgearSmartDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver):
|
|||||||
except NetmikoAuthenticationException as exc:
|
except NetmikoAuthenticationException as exc:
|
||||||
raise ConnectionException(f"Authentication failed for {self.hostname}: {exc}") from exc
|
raise ConnectionException(f"Authentication failed for {self.hostname}: {exc}") from exc
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise ConnectionException(
|
raise ConnectionException(f"Cannot connect to {self.hostname}: {exc}") from exc
|
||||||
f"Verbindungsaufbau fehlgeschlagen (ConnectionException): "
|
|
||||||
f"Cannot connect to {self.hostname}:\n{exc}"
|
|
||||||
) from exc
|
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
"""Close the SSH connection."""
|
"""Close the SSH connection."""
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
napalm>=4.0.0
|
|
||||||
napalm-device-types>=4.16.0
|
|
||||||
netmiko>=4.0.0
|
|
||||||
netaddr
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
"napalm_netgear.netgear_smart"
|
"napalm_netgear.netgear_smart"
|
||||||
],
|
],
|
||||||
"python_file_lines": {
|
"python_file_lines": {
|
||||||
"napalm_netgear/netgear_smart.py": 2070
|
"napalm_netgear/netgear_smart.py": 2067
|
||||||
},
|
},
|
||||||
"untyped_public": [
|
"untyped_public": [
|
||||||
"napalm_netgear/netgear_plus.py::NetgearPlusDriver.get_snmp_config",
|
"napalm_netgear/netgear_plus.py::NetgearPlusDriver.get_snmp_config",
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
"""The Smart driver leaves the caller's optional_args alone and speaks English (#7)."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from napalm.base.exceptions import ConnectionException
|
||||||
|
|
||||||
|
from napalm_netgear.netgear_smart import NetgearSmartDriver
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_callers_optional_args_are_not_changed():
|
||||||
|
args = {"port": 2222}
|
||||||
|
|
||||||
|
driver = NetgearSmartDriver("10.0.0.8", "admin", "pw", optional_args=args)
|
||||||
|
|
||||||
|
assert args == {"port": 2222}
|
||||||
|
assert driver.netmiko_optional_args["conn_timeout"] == 20
|
||||||
|
assert driver.netmiko_optional_args["banner_timeout"] == 20
|
||||||
|
assert driver.netmiko_optional_args["disabled_algorithms"] == {
|
||||||
|
"pubkeys": ["rsa-sha2-256", "rsa-sha2-512"]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_the_callers_own_values_still_win():
|
||||||
|
args = {"conn_timeout": 5, "disabled_algorithms": {}}
|
||||||
|
|
||||||
|
driver = NetgearSmartDriver("10.0.0.8", "admin", "pw", optional_args=args)
|
||||||
|
|
||||||
|
assert driver.netmiko_optional_args["conn_timeout"] == 5
|
||||||
|
assert driver.netmiko_optional_args["disabled_algorithms"] == {}
|
||||||
|
|
||||||
|
|
||||||
|
def test_an_unexpected_connect_error_is_reported_in_english():
|
||||||
|
driver = NetgearSmartDriver("10.0.0.8", "admin", "pw")
|
||||||
|
with patch(
|
||||||
|
"napalm_netgear.netgear_smart.ConnectHandler", side_effect=OSError("no route to host")
|
||||||
|
):
|
||||||
|
with pytest.raises(ConnectionException) as exc_info:
|
||||||
|
driver.open()
|
||||||
|
|
||||||
|
assert str(exc_info.value) == "Cannot connect to 10.0.0.8: no route to host"
|
||||||
Reference in new issue
Block a user