From c9a9d532aa09ee20b6b67fc8fa623f97761c31ba Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 13 Nov 2026 21:45:23 +0100 Subject: [PATCH 1/2] fix(driver): load_replace_candidate is None, not a stub that raises (NetOrk/netork#2503) The driver cannot replace a device's configuration, and said so with a load_replace_candidate that raised NotImplementedError. A method that only raises still looks like a replace to anyone who asks whether the driver has one: netOrk offered a config restore for these devices that could only fail. None is how a driver switches off a method, the convention netOrk's capability checks and napalm-device-types follow, so asking now says no. Nothing in the driver calls it. --- CHANGELOG.md | 4 ++++ README.md | 2 +- napalm_linux/linux.py | 5 +++-- tests/test_config_replace.py | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/test_config_replace.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 97d39f9..ad61a61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `NotImplementedError`. ### Changed +- `load_replace_candidate` is `None` instead of a method that raises + `NotImplementedError`, so a caller that asks whether the driver can replace a + configuration gets no. netOrk offered a config restore for these devices that + could only fail (NetOrk/netork#2503). - On an rpm host a package's version carries its epoch where it has one (`1:6.2.0-13.el9`), as on a dpkg host. Oracle's and Red Hat's fixes name it, and without it an epoch-1 fix read as newer than every installed build (NetOrk/netork#2394). diff --git a/README.md b/README.md index eaa3043..1c1b9a9 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ with Driver( | `get_config()` | ✅ | Returns `ip addr` + `ip route` output | | `ping()` | ✅ | Executes `ping` on the remote host | | `load_merge_candidate()` | ❌ | Not applicable for generic Linux | -| `load_replace_candidate()` | ❌ | Not applicable for generic Linux | +| `load_replace_candidate()` | ❌ | Not applicable for generic Linux; `None`, so a caller can tell | | `compare_config()` | ❌ | Not applicable for generic Linux | | `commit_config()` | ❌ | Not applicable for generic Linux | | `discard_config()` | ❌ | Not applicable for generic Linux | diff --git a/napalm_linux/linux.py b/napalm_linux/linux.py index 39f95f2..d95d106 100644 --- a/napalm_linux/linux.py +++ b/napalm_linux/linux.py @@ -1009,8 +1009,9 @@ class LinuxDriver( def load_merge_candidate(self, filename: str = None, config: str = None) -> None: # type: ignore[override] raise NotImplementedError("Config management is not supported for Linux hosts") - def load_replace_candidate(self, filename: str = None, config: str = None) -> None: # type: ignore[override] - raise NotImplementedError("Config management is not supported for Linux hosts") + #: No config replace: switched off rather than a stub that raises, so asking + #: whether the driver has one says no (NetOrk/netork#2503). + load_replace_candidate = None # type: ignore[assignment] def compare_config(self) -> str: raise NotImplementedError("Config management is not supported for Linux hosts") diff --git a/tests/test_config_replace.py b/tests/test_config_replace.py new file mode 100644 index 0000000..183ee13 --- /dev/null +++ b/tests/test_config_replace.py @@ -0,0 +1,17 @@ +"""The driver cannot replace a device's configuration, and says so by not having the method. + +A ``load_replace_candidate`` that only raises looks like a replace to anyone who asks +whether the driver has one: netOrk offered a config restore for these devices that +could only fail (NetOrk/netork#2503). ``None`` is how a driver switches off a method +it would otherwise inherit, the convention of napalm-device-types and netOrk's +capability checks. +""" + +from __future__ import annotations + +from napalm_linux import LinuxDriver + + +def test_the_driver_has_no_config_replace(): + assert LinuxDriver.load_replace_candidate is None + assert not callable(getattr(LinuxDriver, "load_replace_candidate", None)) From de91b1a91820d7da793a908e5640ae9a3b4e89d0 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 13 Nov 2026 21:50:25 +0100 Subject: [PATCH 2/2] style: one comment line, so linux.py keeps its recorded length --- napalm_linux/linux.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/napalm_linux/linux.py b/napalm_linux/linux.py index d95d106..ac67d3d 100644 --- a/napalm_linux/linux.py +++ b/napalm_linux/linux.py @@ -1009,8 +1009,7 @@ class LinuxDriver( def load_merge_candidate(self, filename: str = None, config: str = None) -> None: # type: ignore[override] raise NotImplementedError("Config management is not supported for Linux hosts") - #: No config replace: switched off rather than a stub that raises, so asking - #: whether the driver has one says no (NetOrk/netork#2503). + #: No config replace, switched off so a capability check says no (NetOrk/netork#2503). load_replace_candidate = None # type: ignore[assignment] def compare_config(self) -> str: