From 6f9914f29eb96d7bedf230496017da5111c96c41 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Sun, 1 Nov 2026 21:54:12 +0100 Subject: [PATCH 1/3] fix(plus)!: drop set_vlan, delete_vlan and set_interface stubs The three methods only raised NotImplementedError. napalm-device-types declares them on SwitchDriver for type checking only, so a driver that cannot carry them out is meant not to have them; netOrk reads the capability from the method being callable and offered "Add VLAN" and the port VLAN editor on Plus switches, which then failed. BREAKING CHANGE: NetgearPlusDriver has no set_vlan, delete_vlan or set_interface attribute any more. Closes #9 --- CHANGELOG.md | 7 +++++++ napalm_netgear/netgear_plus.py | 25 ------------------------- tests/unit/test_plus_capabilities.py | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 tests/unit/test_plus_capabilities.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 068954f..8167b5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,13 @@ All notable changes to this driver. The format follows just now". The "Age (min)" column of `show arp` is not parsed until real switch output confirms its format (NetOrk/netork#1327). +### Removed +- **Breaking:** the Netgear Plus driver no longer has `set_vlan`, `delete_vlan` and + `set_interface`. They only raised `NotImplementedError`; an application that tells + what a switch can do by whether the method exists offered VLAN and port editing on + Plus switches, and the action then failed. A caller that caught + `NotImplementedError` from them now finds no such attribute. + ## [0.6.0] - 2026-10-23 The first release on PyPI, under the new name `napalm-netgear-switches`. diff --git a/napalm_netgear/netgear_plus.py b/napalm_netgear/netgear_plus.py index a338a93..4bd074c 100644 --- a/napalm_netgear/netgear_plus.py +++ b/napalm_netgear/netgear_plus.py @@ -511,24 +511,6 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver): for vid, info in detail.items() } - def set_vlan(self, vlan_id: int, config: dict) -> None: - """Create or update a VLAN. - - Not supported via HTTP API. - """ - raise NotImplementedError( - "VLAN management is not supported for Netgear Plus switches via HTTP." - ) - - def delete_vlan(self, vlan_id: int) -> None: - """Delete a VLAN. - - Not supported via HTTP API. - """ - raise NotImplementedError( - "VLAN management is not supported for Netgear Plus switches via HTTP." - ) - def get_config( self, retrieve: str = "all", @@ -723,13 +705,6 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver): raise ValueError(f"{interface} is not a PoE port on this switch.") self._connector.power_cycle_poe_port(port_number) - def set_interface(self, interface: str, config: dict) -> None: - """Configure an interface. - - Not supported via HTTP API. - """ - raise NotImplementedError("set_interface() is not supported for Netgear Plus switches.") - # ── SNMP / Health ────────────────────────────────────────────────────────── def get_snmp_config(self): diff --git a/tests/unit/test_plus_capabilities.py b/tests/unit/test_plus_capabilities.py new file mode 100644 index 0000000..e51286e --- /dev/null +++ b/tests/unit/test_plus_capabilities.py @@ -0,0 +1,18 @@ +"""Netgear Plus only has the methods it can carry out. + +An application reads a capability from the method being there: netOrk offers +"Add VLAN" and the port VLAN editor when ``set_vlan`` / ``set_interface`` are +callable (#9). A method that only raises NotImplementedError +made the HTTP-only Plus switches look able to do it. +""" + +from __future__ import annotations + +import pytest + +from napalm_netgear.netgear_plus import NetgearPlusDriver + + +@pytest.mark.parametrize("method", ["set_vlan", "delete_vlan", "set_interface"]) +def test_plus_has_no_vlan_or_port_writes(method): + assert not callable(getattr(NetgearPlusDriver, method, None)) -- 2.54.1 From 3e333d6bfd4b8d3eb8b128209afe7d9eeb7a5e7e Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Sun, 1 Nov 2026 21:54:31 +0100 Subject: [PATCH 2/3] fix(plus): leave ping to NAPALM so sweeps skip Plus switches The Plus driver overrode ping only to raise NotImplementedError. An override is what napalm-device-types' driver_supports_ping looks for, so the driver was offered as a ping-sweep source and every target came back as an error. Without the override it inherits NAPALM's stub, which raises the same way and reads as unsupported. Closes #5 --- CHANGELOG.md | 3 +++ napalm_netgear/netgear_plus.py | 17 ----------------- tests/unit/test_plus_capabilities.py | 13 ++++++++++++- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8167b5d..b7aa38b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ All notable changes to this driver. The format follows napalm-device-types' `ARP_AGE_UNKNOWN`) instead of `0.0`, which means "confirmed just now". The "Age (min)" column of `show arp` is not parsed until real switch output confirms its format (NetOrk/netork#1327). +- 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 + came back as an error. `ping` still raises `NotImplementedError`, now NAPALM's own. ### Removed - **Breaking:** the Netgear Plus driver no longer has `set_vlan`, `delete_vlan` and diff --git a/napalm_netgear/netgear_plus.py b/napalm_netgear/netgear_plus.py index 4bd074c..a547536 100644 --- a/napalm_netgear/netgear_plus.py +++ b/napalm_netgear/netgear_plus.py @@ -548,23 +548,6 @@ class NetgearPlusDriver(FirmwareOfferMixin, SwitchDriver): def has_pending_commit(self) -> bool: return False - def ping( - self, - destination: str, - source: str = "", - ttl: int = 255, - timeout: int = 2, - size: int = 100, - count: int = 5, - vrf: str = "", - source_interface: str = "", - ) -> dict[str, Any]: - """Execute ping. - - Not supported on Netgear Plus switches via HTTP. - """ - raise NotImplementedError("ping() is not supported for Netgear Plus switches.") - def traceroute( self, destination: str, diff --git a/tests/unit/test_plus_capabilities.py b/tests/unit/test_plus_capabilities.py index e51286e..15d516a 100644 --- a/tests/unit/test_plus_capabilities.py +++ b/tests/unit/test_plus_capabilities.py @@ -2,7 +2,8 @@ An application reads a capability from the method being there: netOrk offers "Add VLAN" and the port VLAN editor when ``set_vlan`` / ``set_interface`` are -callable (#9). A method that only raises NotImplementedError +callable (#9), and napalm-device-types takes a driver with a ``ping`` of its +own as a ping-sweep source (#5). A method that only raises NotImplementedError made the HTTP-only Plus switches look able to do it. """ @@ -11,8 +12,18 @@ from __future__ import annotations import pytest from napalm_netgear.netgear_plus import NetgearPlusDriver +from napalm_netgear.netgear_smart import NetgearSmartDriver @pytest.mark.parametrize("method", ["set_vlan", "delete_vlan", "set_interface"]) def test_plus_has_no_vlan_or_port_writes(method): assert not callable(getattr(NetgearPlusDriver, method, None)) + + +def test_plus_is_no_ping_sweep_source(): + """Its ping only raised, so every sweep target came back as an error (#5).""" + assert NetgearPlusDriver.supports_ping() is False + + +def test_smart_still_is_a_ping_sweep_source(): + assert NetgearSmartDriver.supports_ping() is True -- 2.54.1 From 09092be5db9884677319442d9bf1e14d83d5e286 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Sun, 1 Nov 2026 21:55:21 +0100 Subject: [PATCH 3/3] fix(smart): copy optional_args, report in English, drop requirements The Smart driver's constructor wrote its connection defaults into the optional_args dict the caller passed in, and an unexpected connect error started with a German phrase. requirements.txt repeated pyproject's dependencies with floors older than the driver needs. The issue's other points were already fixed on main: pyproject declares napalm-device-types since 34554ea and points its URLs at git.netork.io since 10a3b1e. Closes #7 --- CHANGELOG.md | 7 ++++++ napalm_netgear/netgear_smart.py | 9 +++---- requirements.txt | 4 --- tests/quality_baseline.json | 2 +- tests/unit/test_smart_init.py | 43 +++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 11 deletions(-) delete mode 100644 requirements.txt create mode 100644 tests/unit/test_smart_init.py diff --git a/CHANGELOG.md b/CHANGELOG.md index b7aa38b..6e347d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 (`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. +- 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 : "). +- `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 - **Breaking:** the Netgear Plus driver no longer has `set_vlan`, `delete_vlan` and diff --git a/napalm_netgear/netgear_smart.py b/napalm_netgear/netgear_smart.py index 395916a..c5db884 100644 --- a/napalm_netgear/netgear_smart.py +++ b/napalm_netgear/netgear_smart.py @@ -102,8 +102,8 @@ class NetgearSmartDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver): self.timeout = timeout self.device: ConnectHandler | None = None - if optional_args is None: - optional_args = {} + # A copy: the defaults below must not end up in the caller's dict (#7). + optional_args = dict(optional_args or {}) self.force_no_enable = optional_args.get("force_no_enable", False) self.port = optional_args.get("port", 22) @@ -165,10 +165,7 @@ class NetgearSmartDriver(ConfigLifecycleMixin, SnmpAgentMixin, SwitchDriver): except NetmikoAuthenticationException as exc: raise ConnectionException(f"Authentication failed for {self.hostname}: {exc}") from exc except Exception as exc: - raise ConnectionException( - f"Verbindungsaufbau fehlgeschlagen (ConnectionException): " - f"Cannot connect to {self.hostname}:\n{exc}" - ) from exc + raise ConnectionException(f"Cannot connect to {self.hostname}: {exc}") from exc def close(self) -> None: """Close the SSH connection.""" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a5f74c8..0000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -napalm>=4.0.0 -napalm-device-types>=4.16.0 -netmiko>=4.0.0 -netaddr diff --git a/tests/quality_baseline.json b/tests/quality_baseline.json index 0d88aa9..452714d 100644 --- a/tests/quality_baseline.json +++ b/tests/quality_baseline.json @@ -31,7 +31,7 @@ "napalm_netgear.netgear_smart" ], "python_file_lines": { - "napalm_netgear/netgear_smart.py": 2070 + "napalm_netgear/netgear_smart.py": 2067 }, "untyped_public": [ "napalm_netgear/netgear_plus.py::NetgearPlusDriver.get_snmp_config", diff --git a/tests/unit/test_smart_init.py b/tests/unit/test_smart_init.py new file mode 100644 index 0000000..d173c56 --- /dev/null +++ b/tests/unit/test_smart_init.py @@ -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" -- 2.54.1