feat: drop the get_device_warnings override; the pending updates are the fact (0.2.0) #7
No files matched your search
@@ -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]:
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user