refactor: the update history shapes live with UpdateMixin, within the quality ratchet
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 19s
driver / types (pull_request) Successful in 1m3s
driver / test (3.12) (pull_request) Successful in 1m16s
driver / test (3.13) (pull_request) Successful in 1m11s
driver / lowest (pull_request) Successful in 42s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m3s
CI / driver (pull_request) Successful in 2m33s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 19s
driver / types (pull_request) Successful in 1m3s
driver / test (3.12) (pull_request) Successful in 1m16s
driver / test (3.13) (pull_request) Successful in 1m11s
driver / lowest (pull_request) Successful in 42s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 1m3s
CI / driver (pull_request) Successful in 2m33s
driver / publish (pull_request) Skipped
This commit is contained in:
1 parent
53bc79098b
commit
d561046802
4 files changed
+53
-50
No files matched your search
@@ -232,9 +232,6 @@ from napalm_device_types.models import (
|
||||
PowerAction,
|
||||
PowerStateDict,
|
||||
SnmpAgentSettingsDict,
|
||||
UpdateHistoryAction,
|
||||
UpdateHistoryDict,
|
||||
UpdateHistoryPackageDict,
|
||||
UpdateProgressDict,
|
||||
)
|
||||
from napalm_device_types.nat_vpn import NatVpnMixin
|
||||
@@ -370,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,
|
||||
|
||||
@@ -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,10 +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) - an identity of the guest that survives a
|
||||
migration, a restore and a changed ``vmid`` (Proxmox VE 9.3's ``uid``,
|
||||
VMware's instance UUID). Left out where the platform has none, or has
|
||||
not given this guest one yet; a caller then knows it by ``vmid`` alone.
|
||||
* uid (string, optional) - outlives the ``vmid``; absent where none (``VMDict.uid``)
|
||||
|
||||
Example::
|
||||
|
||||
|
||||
@@ -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,9 +834,7 @@ class VMDict(TypedDict):
|
||||
memory_usage: int
|
||||
uptime: int
|
||||
node: str
|
||||
# An identity of the guest that survives migration, restore and a changed
|
||||
# ``vmid``; absent where the platform has none or has not assigned it yet.
|
||||
uid: NotRequired[str]
|
||||
uid: NotRequired[str] # outlives a migration, a restore, a changed vmid (get_vms)
|
||||
|
||||
|
||||
class VMPassthroughDict(TypedDict):
|
||||
@@ -1144,39 +1141,6 @@ class UpdateProgressDict(TypedDict):
|
||||
log: str # the device's own log of it, whole; a caller follows it by line count
|
||||
|
||||
|
||||
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 DnsForwardDict(TypedDict):
|
||||
"""A domain the device's resolver forwards to another server
|
||||
(``DnsForwardMixin.get_dns_forwards``)."""
|
||||
|
||||
@@ -12,15 +12,48 @@ 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 typing_extensions import TypedDict
|
||||
|
||||
from napalm_device_types.models import (
|
||||
ApplyUpdatesResultDict,
|
||||
UpdateDict,
|
||||
UpdateHistoryDict,
|
||||
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):
|
||||
"""The host holds no package index to read pending updates from.
|
||||
|
||||
Reference in new issue
Block a user