feat: drop get_device_warnings; the pending updates are the fact (0.3.0) #22

Merged
christianmanivong merged 1 commits from feat/facts-not-warnings into master 2026-10-17 08:34:57 +00:00
3 changed files with 9 additions and 29 deletions

No files matched your search

-28
View File
@@ -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.
+1 -1
View File
@@ -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" }
+8
View File
@@ -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)