feat: drop get_device_warnings; the pending updates are the fact (0.3.0) #22
No files matched your search
@@ -2196,34 +2196,6 @@ class OPNsenseDriver(OPNsensePingMixin, ConfigSyncMixin, SnmpAgentMixin, Firewal
|
|||||||
"auto_updates": None,
|
"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]:
|
def apply_updates(self, packages: list[str]) -> dict[str, Any]:
|
||||||
"""Trigger a full firmware upgrade on OPNsense.
|
"""Trigger a full firmware upgrade on OPNsense.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "napalm-opnsense"
|
name = "napalm-opnsense"
|
||||||
version = "0.2.0"
|
version = "0.3.0"
|
||||||
description = "NAPALM driver for OPNsense (read-only via REST API)."
|
description = "NAPALM driver for OPNsense (read-only via REST API)."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = { text = "Apache-2.0" }
|
license = { text = "Apache-2.0" }
|
||||||
|
|||||||
@@ -138,3 +138,11 @@ class TestRebootHost:
|
|||||||
with patch.object(driver, "_post", side_effect=ConnectionError("403 Forbidden")):
|
with patch.object(driver, "_post", side_effect=ConnectionError("403 Forbidden")):
|
||||||
with pytest.raises(RuntimeError, match="403"):
|
with pytest.raises(RuntimeError, match="403"):
|
||||||
driver.reboot_host()
|
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)
|
||||||
Reference in new issue
Block a user