Merge pull request 'chore(release): 4.44.0' (#133) from feature/pve93-2728 into main
driver / types (push) Successful in 59s
driver / standard (push) Successful in 17s
driver / lint (push) Successful in 14s
driver / test (3.12) (push) Successful in 1m14s
driver / test (3.13) (push) Successful in 1m8s
driver / lowest (push) Successful in 40s
driver / build (push) Successful in 34s
driver / security (push) Successful in 1m9s
driver / publish (push) Successful in 28s
CI / driver (push) Successful in 3m24s

This commit was merged in pull request #133.
This commit is contained in:
christianmanivong committed 2026-11-26 17:15:12 +00:00
commit 03ccae82e3
8 files changed
+261 -8

No files matched your search

+21
View File
@@ -7,6 +7,27 @@ recorded here; their history is the git log.
## [Unreleased]
## [4.44.0] - 2026-11-26
### Added
- `VMDict.uid`, optional: an identity of the guest that survives a migration, a restore
and a changed `vmid` (NetOrk/netork#2728). Proxmox VE 9.3 gives every guest one, VMware's
instance UUID is one; a driver leaves it out where the platform has none, and a caller
then knows the guest by `vmid` alone.
- `CredentialExpiryMixin.get_credential_expiry()`: the credential the connection logged in
with (`kind` `"api-token"` or `"account"`, its `name`) and when it expires, `None` for
never (NetOrk/netork#2728). `PermissionError` where the platform will not tell the
credential its own expiry.
- `UpdateMixin.get_update_history(since)`: the package manager's past transactions, newest
first, each with a stable `id`, start and end, the packages it changed (`action`, old and
new version), who asked for it, the command line and the error it ended with
(`UpdateHistoryDict`, `UpdateHistoryPackageDict`, NetOrk/netork#2728).
### Changed
- `HypervisorDriver.resume_vm()`: the guest's clock is set to the host's time after it
resumes, where the platform can (NetOrk/netork#2728). A documented expectation, not a
parameter: no caller wants a guest that runs behind.
## [4.43.0] - 2026-11-26
### Added
+19 -1
View File
@@ -41,6 +41,7 @@ instead of being restated on every role that happens to need it:
* :class:`~napalm_device_types.config_revisions.ConfigRevisionsMixin`
* :class:`~napalm_device_types.config_sync.ConfigSyncMixin`
* :class:`~napalm_device_types.container_engine.ContainerEngineMixin`
* :class:`~napalm_device_types.credential_expiry.CredentialExpiryMixin`
* :class:`~napalm_device_types.dhcp.DhcpServerMixin`
* :class:`~napalm_device_types.firewall_rules.FirewallRuleMixin`
* :class:`~napalm_device_types.health_metrics.HealthMetricsMixin`
@@ -143,6 +144,11 @@ from napalm_device_types.container_engine import (
ContainerEngineMixin,
ContainerEngineUnavailable,
)
from napalm_device_types.credential_expiry import (
CredentialExpiryDict,
CredentialExpiryMixin,
CredentialKind,
)
from napalm_device_types.dhcp import DhcpApplyError, DhcpServerMixin, normalize_cidr, normalize_mac
from napalm_device_types.dns_forward import DnsForwardMixin
from napalm_device_types.firewall import FirewallDriver
@@ -361,7 +367,13 @@ from napalm_device_types.time_sync import (
check_ntp_servers,
)
from napalm_device_types.time_sync_posix import PosixTimeSyncMixin, parse_time_sync
from napalm_device_types.updates import PackageIndexMissing, UpdateMixin
from napalm_device_types.updates import (
PackageIndexMissing,
UpdateHistoryAction,
UpdateHistoryDict,
UpdateHistoryPackageDict,
UpdateMixin,
)
from napalm_device_types.virtual_ips import (
VIRTUAL_IPS_COMMAND,
VirtualIpsMixin,
@@ -406,6 +418,12 @@ __all__ = [
"OspfInterfaceDict",
"OspfMixin",
"UpdateProgressDict",
"UpdateHistoryAction",
"UpdateHistoryDict",
"UpdateHistoryPackageDict",
"CredentialExpiryDict",
"CredentialExpiryMixin",
"CredentialKind",
"FirmwareOfferMixin",
"FirmwareUpgradeMixin",
"LicenseDict",
+58
View File
@@ -0,0 +1,58 @@
"""When the credential a driver logs in with stops working.
An API token can be given an expiry, and a platform can require one (Proxmox VE
9.3's datacenter ``token-policy``). Once it has passed, every login fails with
an authentication error, and an application that polls the device learns of it
only then. A driver that can read its own credential's expiry says so here, so
the application can warn before, the way it warns of an expiring certificate.
Which credential is read is the driver's: the one this connection logged in
with, never another.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, Literal
from typing_extensions import TypedDict
#: ``"api-token"``: a token of an account; ``"account"``: the account a password logs in to.
CredentialKind = Literal["api-token", "account"]
class CredentialExpiryDict(TypedDict):
"""The credential this connection logged in with, and when it expires."""
kind: CredentialKind
#: The credential as the platform names it, e.g. ``"netork@pve!poll"``.
name: str
#: Unix seconds; ``None`` when it never expires.
expires: int | None
class CredentialExpiryMixin:
"""Reads the expiry of the credential the driver logged in with.
Declared under ``if TYPE_CHECKING``: a contract, not a placeholder.
"""
if TYPE_CHECKING:
def get_credential_expiry(self) -> CredentialExpiryDict:
"""
The credential this connection logged in with, and when it expires.
``expires`` is ``None`` for one that never expires. A credential
whose expiry has passed cannot log in, so a driver that returns at
all reports one that still works.
:raises PermissionError: The platform will not tell this credential
its own expiry (a token whose privileges do not reach it). Not a
fault of the connection; a caller then knows nothing either way.
:raises RuntimeError: The platform could not be read.
Example::
{"kind": "api-token", "name": "netork@pve!poll", "expires": 1767225600}
"""
...
+14 -2
View File
@@ -41,6 +41,13 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
Inherits all standard NAPALM NetworkDriver methods and adds
hypervisor-specific operations that concrete drivers must implement.
A guest is known by its ``vmid``, which a platform may give to another guest
once the first is gone, and where it has one also by its ``uid``
(``VMDict.uid``): an identity that survives a migration, a restore and a
changed ``vmid`` -- Proxmox VE 9.3's ``uid``, VMware's instance UUID. A driver
leaves it out where the platform has none or has not given the guest one yet;
a caller then knows that guest by ``vmid`` alone.
"""
#: Stable key netOrk exposes as ``device_class``. The order in which a
@@ -69,8 +76,7 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
Each entry contains:
* name (string) - VM display name
* vmid (string) - hypervisor-internal ID (Proxmox: ``"100"``,
VMware: the instance UUID)
* vmid (string) - hypervisor-internal ID (Proxmox: ``"100"``, VMware: the instance UUID)
* status (string) - ``"running"``, ``"stopped"``, ``"paused"``, ``"suspended"``.
A guest that is not executing is never ``"running"``: ``"paused"``
while its process still holds its memory (Proxmox's ``qmpstatus``
@@ -82,6 +88,7 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
* memory_usage (int) - current RAM usage in megabytes
* uptime (int) - uptime in seconds (0 if not running)
* node (string) - cluster node this VM lives on (empty string for standalone)
* uid (string, optional) - outlives the ``vmid``; absent where none (``VMDict.uid``)
Example::
@@ -272,6 +279,11 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
counterpart of :meth:`suspend_vm`. The method blocks until the
hypervisor took the request.
The guest's clock is set to the host's time after it resumes, where the
platform can do so (Proxmox VE: through the guest agent): a guest that
stood still for hours would otherwise run behind. No caller wants
otherwise, so it is the driver's to do, not a choice.
Optional, like every power action: a driver whose platform cannot
resume a guest does not implement it, and a caller then offers no
resume. A driver that can resume some guests but not others (a
+2 -2
View File
@@ -1,5 +1,4 @@
"""
TypedDicts for NAPALM device-type-specific return values.
"""TypedDicts for NAPALM device-type-specific return values.
These supplement the types defined in napalm.base.models and are used by the
abstract device-type driver classes in this package.
@@ -835,6 +834,7 @@ class VMDict(TypedDict):
memory_usage: int
uptime: int
node: str
uid: NotRequired[str] # outlives a migration, a restore, a changed vmid (get_vms)
class VMPassthroughDict(TypedDict):
+78 -2
View File
@@ -12,9 +12,47 @@ this class in can never shadow a working implementation from a sibling base.
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal
from napalm_device_types.models import ApplyUpdatesResultDict, UpdateDict, UpdateProgressDict
from typing_extensions import TypedDict
from napalm_device_types.models import (
ApplyUpdatesResultDict,
UpdateDict,
UpdateProgressDict,
)
UpdateHistoryAction = Literal[
"install", "reinstall", "upgrade", "downgrade", "remove", "purge", "disappear"
]
class UpdateHistoryPackageDict(TypedDict):
"""One package a past transaction changed (``UpdateHistoryDict.packages``)."""
name: str
action: UpdateHistoryAction # "disappear": dpkg dropped it, its files taken by another
old_version: str | None # None where nothing was installed before
new_version: str | None # None where nothing is installed after
class UpdateHistoryDict(TypedDict):
"""A past run of the host's package manager (``UpdateMixin.get_update_history``).
A fact of the host's own log: what it changed, when, and who asked, also for
a run that no application of the caller started.
"""
#: Stable for the same transaction across reads, unique on the host: apt's
#: start time with its index among those starting in the same second, dnf's
#: transaction ID.
id: str
start: int # unix seconds
end: int | None # None: still running, or interrupted
packages: list[UpdateHistoryPackageDict]
requested_by: str | None # the user behind sudo, pkexec or PackageKit; None when unknown
command: str | None # the command line, where the log keeps it
error: str | None # the error the run ended with; None for none
class PackageIndexMissing(RuntimeError):
@@ -83,6 +121,44 @@ class UpdateMixin:
"""
...
def get_update_history(self, since: int | None = None) -> list[UpdateHistoryDict]:
"""
The transactions the host's package manager ran, newest first: what
each changed, when, and who asked for it -- also those no caller of
this driver started (an operator's ``apt upgrade``, unattended-upgrades).
:param since: Unix seconds; only transactions that started at or after
it. ``None`` for as far back as the host's log reaches.
**An empty list means no transaction since.** A reader that cannot
read raises, as :meth:`get_available_updates` does: a caller keeps what
it read before, and an empty list for "don't know" would read as a
host that never changed. ``NotImplementedError`` where the package
manager keeps no history.
Example::
[
{
"id": "1764158400-0",
"start": 1764158400,
"end": 1764158460,
"packages": [
{
"name": "openssh-server",
"action": "upgrade",
"old_version": "1:9.2p1-2+deb12u1",
"new_version": "1:9.2p1-2+deb12u2",
},
],
"requested_by": "admin",
"command": "apt-get -y upgrade",
"error": None,
},
]
"""
...
def refresh_available_updates(self) -> dict[str, Any]:
"""
Refreshes the host's package index, so that :meth:`get_available_updates`
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "napalm-device-types"
version = "4.43.0"
version = "4.44.0"
description = "Abstract device-type base classes for NAPALM drivers"
readme = "README.md"
requires-python = ">=3.12"
+68
View File
@@ -0,0 +1,68 @@
"""Contracts Proxmox VE 9.3 made worth having, kept neutral (NetOrk/netork#2728).
A guest identity that survives a changed ID, the expiry of the credential a
driver logs in with, and what a host's package manager did in the past: each a
shape every driver of its kind can fill, with the platform's own calls left to
the driver.
"""
from __future__ import annotations
import typing
from typing import get_type_hints
from napalm_device_types import (
CredentialExpiryDict,
CredentialExpiryMixin,
UpdateHistoryDict,
UpdateHistoryPackageDict,
UpdateMixin,
)
from napalm_device_types.models import VMDict
def test_a_vm_may_carry_an_identity_that_outlives_its_vmid():
assert "uid" in get_type_hints(VMDict)
assert "uid" in VMDict.__optional_keys__
def test_a_credential_expiry_names_the_credential_and_when_it_ends():
assert set(get_type_hints(CredentialExpiryDict)) == {"kind", "name", "expires"}
kinds = typing.get_args(get_type_hints(CredentialExpiryDict)["kind"])
assert set(kinds) == {"api-token", "account"}
def test_credential_expiry_is_a_contract_not_a_placeholder():
assert not hasattr(CredentialExpiryMixin, "get_credential_expiry")
def test_an_update_transaction_is_its_packages_and_who_asked_for_it():
assert set(get_type_hints(UpdateHistoryDict)) == {
"id",
"start",
"end",
"packages",
"requested_by",
"command",
"error",
}
assert set(get_type_hints(UpdateHistoryPackageDict)) == {
"name",
"action",
"old_version",
"new_version",
}
actions = typing.get_args(get_type_hints(UpdateHistoryPackageDict)["action"])
assert set(actions) == {
"install",
"reinstall",
"upgrade",
"downgrade",
"remove",
"purge",
"disappear",
}
def test_update_history_is_declared_next_to_pending_updates():
assert not hasattr(UpdateMixin, "get_update_history")