From 8b41a948be5b020f4f3b1b098bfc6fb8b0de00b6 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Sat, 17 Oct 2026 09:39:16 +0200 Subject: [PATCH] feat: drop the get_device_warnings override; the pending updates are the fact (0.2.0) The override counted "N upgraded" in an apt simulation run without a fixed locale -- nothing matched on a German host -- and hid held-back packages, which FULL_UPGRADE installs. netOrk names updates_available from get_available_updates (netOrk #1111). --- napalm_openmediavault/openmediavault.py | 38 ------------------------- pyproject.toml | 2 +- tests/test_no_warnings.py | 12 ++++++++ 3 files changed, 13 insertions(+), 39 deletions(-) create mode 100644 tests/test_no_warnings.py diff --git a/napalm_openmediavault/openmediavault.py b/napalm_openmediavault/openmediavault.py index bff2d29..54b2983 100644 --- a/napalm_openmediavault/openmediavault.py +++ b/napalm_openmediavault/openmediavault.py @@ -85,44 +85,6 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): pass return facts - # ── Warnings ────────────────────────────────────────────────────────────── - - def get_device_warnings(self) -> list[dict[str, Any]]: - """Return warnings, ignoring packages held back by apt-get upgrade. - - On OMV, kernel and OMV-specific packages are routinely held back - (they require dist-upgrade or omv-upgrade). Reporting them as - "updates available" after a successful apt-get upgrade is misleading. - We simulate the upgrade first and only warn if there are packages - that a standard apt-get upgrade would actually install. - """ - warnings: list[dict[str, Any]] = [] - try: - sim = self._sudo( - "DEBIAN_FRONTEND=noninteractive apt-get upgrade --simulate 2>&1", - read_timeout=60, - ) - m = re.search(r'(\d+) upgraded', sim) - upgradable_count = int(m.group(1)) if m else 0 - except Exception: - upgradable_count = -1 # unknown — fall back to parent behaviour - - if upgradable_count == 0: - return [] # nothing to do with apt-get upgrade; held-back only - if upgradable_count < 0: - return super().get_device_warnings() - - updates = self.get_available_updates() - if updates: - warnings.append({ - "code": "updates_available", - "meta": { - "count": upgradable_count, - "packages": [u.get("name", "") for u in updates[:10]], - }, - }) - return warnings - # ── Physical disks ───────────────────────────────────────────────────────── def get_disks(self) -> list[PhysicalDiskDict]: diff --git a/pyproject.toml b/pyproject.toml index 417bb11..3090a3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "napalm-openmediavault" -version = "0.1.1" +version = "0.2.0" description = "NAPALM driver for OpenMediaVault NAS (SSH)" readme = "README.md" requires-python = ">=3.9" diff --git a/tests/test_no_warnings.py b/tests/test_no_warnings.py new file mode 100644 index 0000000..ee85774 --- /dev/null +++ b/tests/test_no_warnings.py @@ -0,0 +1,12 @@ +"""The pending updates are a fact, not a warning of the driver's (netOrk #1111). + +The override counted "N upgraded" in apt's simulation -- nothing on a German +host -- and hid held-back packages, which FULL_UPGRADE installs. The caller +names updates_available from get_available_updates. +""" + +from napalm_openmediavault.openmediavault import OpenMediaVaultDriver + + +def test_no_warnings_of_its_own(): + assert "get_device_warnings" not in vars(OpenMediaVaultDriver) -- 2.54.0