From 5ab33d67f3210891f94abbc8dc46c82e19abc80a Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Sat, 17 Oct 2026 09:38:34 +0200 Subject: [PATCH] feat: drop get_device_warnings; the pending updates are the fact (0.3.0) updates_available came from the cached firmware status with ten package names; netOrk builds it from get_available_updates with the full list (netOrk #1111). --- napalm_opnsense/opnsense.py | 28 ---------------------------- pyproject.toml | 2 +- tests/unit/test_updates.py | 8 ++++++++ 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/napalm_opnsense/opnsense.py b/napalm_opnsense/opnsense.py index 702b7ae..b722e88 100644 --- a/napalm_opnsense/opnsense.py +++ b/napalm_opnsense/opnsense.py @@ -2196,34 +2196,6 @@ class OPNsenseDriver(OPNsensePingMixin, ConfigSyncMixin, SnmpAgentMixin, Firewal "auto_updates": None, } - def get_device_warnings(self) -> list[dict[str, Any]]: - """Return a list of warning dicts for issues detected on this device. - - Reads the cached ``GET /api/core/firmware/status`` (no network - update trigger) to detect available package/firmware updates. - """ - warnings: list[dict[str, Any]] = [] - try: - status = self._get("/api/core/firmware/status") - state = status.get("status", "none") - if state in ("update", "upgrade"): - upgrades = ( - status.get("upgrade_packages") - or status.get("updates") - or [] - ) - if upgrades: - warnings.append({ - "code": "updates_available", - "meta": { - "count": len(upgrades), - "packages": [u.get("name", "") for u in upgrades[:10]], - }, - }) - except Exception as exc: - logger.debug("Failed to check firmware status for device warnings: %s", exc) - return warnings - def apply_updates(self, packages: list[str]) -> dict[str, Any]: """Trigger a full firmware upgrade on OPNsense. diff --git a/pyproject.toml b/pyproject.toml index 1c8aebb..d602780 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "napalm-opnsense" -version = "0.2.0" +version = "0.3.0" description = "NAPALM driver for OPNsense (read-only via REST API)." readme = "README.md" license = { text = "Apache-2.0" } diff --git a/tests/unit/test_updates.py b/tests/unit/test_updates.py index 4f04b5a..b8c8b4f 100644 --- a/tests/unit/test_updates.py +++ b/tests/unit/test_updates.py @@ -138,3 +138,11 @@ class TestRebootHost: with patch.object(driver, "_post", side_effect=ConnectionError("403 Forbidden")): with pytest.raises(RuntimeError, match="403"): driver.reboot_host() + + +def test_no_warnings_of_its_own(): + """The pending updates are get_available_updates; the caller names + updates_available from them (netOrk #1111).""" + from napalm_opnsense.opnsense import OPNsenseDriver + + assert "get_device_warnings" not in vars(OPNsenseDriver) -- 2.54.0