Merge remote-tracking branch 'origin/main' into feat/tls-fingerprint-tofu

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
christianmanivong committed 2026-11-01 23:01:38 +01:00
commit c9571d59f1
7 files changed
+247 -2

No files matched your search

+8
View File
@@ -88,10 +88,13 @@ from napalm_device_types.channel import (
run_on_transport,
)
from napalm_device_types.clusters import (
BackupDict,
BackupJobDict,
ClusterDict,
ClusterNetworkDict,
ClusterNodeDict,
ClusterStorageDict,
HAResourceDict,
)
from napalm_device_types.config_lifecycle import ConfigLifecycleMixin
from napalm_device_types.config_sync import ConfigSyncMixin
@@ -238,13 +241,18 @@ from napalm_device_types.virtual_ips import (
VirtualIpsMixin,
parse_virtual_ips,
)
from napalm_device_types.vm_migration import MigrationPreflightDict
from napalm_device_types.vm_stop_request import VmStopRequestMixin
__all__ = [
"BackupDict",
"BackupJobDict",
"ClusterDict",
"ClusterNetworkDict",
"ClusterNodeDict",
"ClusterStorageDict",
"HAResourceDict",
"MigrationPreflightDict",
"HypervisorHostDict",
"DnsForwardDict",
"DnsForwardMixin",
+42
View File
@@ -21,6 +21,7 @@ class ClusterNodeDict(TypedDict):
cpu_usage: float | None # 0.0–1.0
memory_total: int | None # bytes
memory_used: int | None # bytes
votes: NotRequired[int | None] # quorum votes of this node; None standalone/unreadable
class ClusterStorageDict(TypedDict):
@@ -45,6 +46,43 @@ class ClusterNetworkDict(TypedDict):
nodes: list[str]
class HAResourceDict(TypedDict):
"""A guest the cluster's HA manager looks after."""
vmid: int
kind: str # "qemu" or "lxc"
requested: str # state HA is asked to keep: "started", "stopped", "disabled", "ignored"
status: str | None # what the HA manager reports now: "started", "fence", "migrate", ...
node: str | None # the node the HA manager places it on now
group: NotRequired[str | None] # HA group (Proxmox VE 8)
rules: list[str] # ids of the HA rules that name it (Proxmox VE 9); [] where there are none
class BackupJobDict(TypedDict):
"""A scheduled backup job of the cluster."""
id: str
enabled: bool
schedule: str | None # as the platform writes it: "sat 02:00", "daily", "mon..fri 21:00"
storage: str | None
mode: str | None # "snapshot", "suspend", "stop"
all: bool # every guest, minus ``exclude``
vmids: list[int] # the guests it names; a pool job: the pool's members now; [] with all
exclude: list[int]
pool: str | None
node: str | None # the one node it runs on; None for every node
class BackupDict(TypedDict):
"""The backups of one guest on one storage."""
vmid: int
storage: str
time: int # unix seconds of the newest backup of this guest on this storage
size: int | None # bytes of that newest backup
count: int # backups of this guest on this storage
class ClusterDict(TypedDict):
"""A cluster the connection can see. A standalone host is a cluster of one,
with no name."""
@@ -55,3 +93,7 @@ class ClusterDict(TypedDict):
nodes: list[ClusterNodeDict]
storages: list[ClusterStorageDict]
networks: list[ClusterNetworkDict]
# None: could not be read; []: read, nothing there.
ha_resources: NotRequired[list[HAResourceDict] | None]
backup_jobs: NotRequired[list[BackupJobDict] | None]
backups: NotRequired[list[BackupDict] | None]
+35
View File
@@ -31,6 +31,7 @@ from napalm_device_types.models import (
)
from napalm_device_types.packages import PackageManagementMixin
from napalm_device_types.provisioning import QEMU_GUEST_AGENTS, GuestAgents
from napalm_device_types.vm_migration import MigrationPreflightDict
class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDriver):
@@ -662,6 +663,40 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
"""
...
def get_vm_migration_preflight(self, name: str) -> MigrationPreflightDict:
"""Which nodes of its cluster the guest could move to, and what blocks it
(see ``vm_migration``).
:raises ValueError: If no VM with the given name/ID exists.
"""
...
def migrate_vm(
self,
name: str,
target_node: str,
online: bool = True,
target_storage: str | None = None,
timeout: int = 3600,
) -> None:
"""Move the guest to another node of its cluster; block until the
platform's task ended. ``online`` keeps a running guest running.
:raises ValueError: Unknown VM, or a target that is not another
member of the cluster.
:raises RuntimeError: The migration failed, with the platform's cause.
"""
...
def set_node_maintenance(self, node: str, enabled: bool) -> None:
"""Switch HA maintenance mode of a cluster node; HA guests leave it
while it is on.
:raises ValueError: If ``node`` is not a member of the cluster.
:raises RuntimeError: If the platform refuses or cannot be asked.
"""
...
def get_hypervisor_hosts(self) -> list[HypervisorHostDict]:
"""The hosts this hypervisor or its manager runs, and how each stands:
connected, in maintenance, with configuration issues, under a central
+26
View File
@@ -0,0 +1,26 @@
"""Moving a guest to another node of its cluster (``HypervisorDriver.migrate_vm``).
``get_vm_migration_preflight`` reports what the platform says before a move:
which nodes would take the guest, which refuse it and why, and what the guest
holds on its current node. ``migrate_vm`` then moves it and blocks until the
platform's task ended; a failure raises with the platform's own cause.
``set_node_maintenance`` switches a node's HA maintenance mode, which makes the
HA manager move its HA guests away while it is on.
Facts only: which node to pick, and whether a local disk is worth copying, is
the caller's to decide.
"""
from typing import TypedDict
class MigrationPreflightDict(TypedDict):
"""Where a guest could move to, and what stands in the way."""
running: bool
allowed_nodes: list[str] # nodes the platform would move it to
refused_nodes: dict[str, str] # node -> the platform's reason, in plain words
# volume ids on storage the target does not share; they block nothing by
# themselves, the migration copies them
local_disks: list[str]
local_resources: list[str] # e.g. "hostpci0", "usb0": they block the migration