feat: licenses, a hypervisor's hosts and the package proxy as facts (4.14.0)
CI / test (3.10) (push) Successful in 32s
CI / test (3.11) (push) Successful in 32s
CI / test (3.12) (push) Successful in 35s
CI / test (3.13) (push) Successful in 35s
CI / test (3.10) (pull_request) Successful in 31s
CI / test (3.11) (pull_request) Successful in 27s
CI / test (3.12) (pull_request) Successful in 30s
CI / test (3.13) (pull_request) Successful in 29s

Drivers report facts and the application decides what is a warning
(docs/STRUCTURE.md, NetOrk/netork#1111). Three facts drivers so far
only reported as warning codes get contracts:

- LicenseMixin.get_licenses(): licenses and subscriptions with their
  status (a Proxmox subscription, a VMware edition, a BMC license a
  feature needs).
- HypervisorDriver.get_hypervisor_hosts(): each host connected, in
  maintenance, with configuration issues, under a central manager.
- PackageProxyMixin.get_package_proxy(): the proxy apt fetches through.

All declared only.
This commit is contained in:
christianmanivong committed 2026-10-17 09:12:20 +02:00
1 parent 6551008ad3
commit 2805f911c4
7 files changed
+114 -1

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
"""Facts instead of warnings (docs/STRUCTURE.md, NetOrk/netork#1111).
A driver reports what it reads; the application decides what is a warning. Three
facts that drivers so far only reported as warning codes get contracts of their
own: the package manager's proxy, licenses and subscriptions, and the state of a
hypervisor's hosts. All are declared only, so a capability check stays truthful.
"""
from __future__ import annotations
from typing import get_type_hints
from napalm_device_types import (
HypervisorDriver,
HypervisorHostDict,
LicenseDict,
LicenseMixin,
PackageProxyMixin,
)
def test_a_license_says_what_it_is_and_whether_it_holds():
hints = get_type_hints(LicenseDict)
assert {"name", "status"} <= set(hints)
assert LicenseDict.__required_keys__ == frozenset({"name", "status"})
assert set(hints) == {"name", "status", "edition", "expires", "detail"}
def test_a_hypervisor_host_says_how_it_stands():
hints = get_type_hints(HypervisorHostDict)
assert set(hints) == {"name", "connected", "maintenance", "config_issues", "managed_by"}
assert HypervisorHostDict.__required_keys__ == frozenset(
{"name", "connected", "maintenance", "config_issues"}
)
def test_the_getters_are_declared_only():
assert not hasattr(PackageProxyMixin, "get_package_proxy")
assert not hasattr(LicenseMixin, "get_licenses")
assert not hasattr(HypervisorDriver, "get_hypervisor_hosts")