feat: Proxmox VE 9.3 API additions (NetOrk/netork#2728)
On a node running 9.3: HA maintenance over PUT /nodes/{node}/maintenance
(the target node's version decides, SSH below it), the guest uid in
get_vms, the cluster-id as ClusterDict.id, sync-time-on-resume on resume.
get_credential_expiry reads the expiry of the token or account the driver
logged in with; get_update_history lists the node's APT transactions.
Needs napalm-device-types 4.44.0.
This commit is contained in:
1 parent
c2d9d7e75e
commit
fddf8af680
17 files changed
+718
-17
No files matched your search
@@ -19,6 +19,7 @@ from napalm_device_types.models import (
|
||||
VMPassthroughDict,
|
||||
)
|
||||
|
||||
from napalm_proxmox.pve_values import PVE_9_3
|
||||
from napalm_proxmox.vm_mixin import qemu_status
|
||||
|
||||
_JsonDict = dict[str, Any]
|
||||
@@ -152,9 +153,9 @@ class ProxmoxVMContractMixin:
|
||||
node = self._node_api()
|
||||
return node.qemu(vmid) if vm_type == "vm" else node.lxc(vmid)
|
||||
|
||||
def _run_power(self, vmid: int, vm_type: str, action: str) -> None:
|
||||
def _run_power(self, vmid: int, vm_type: str, action: str, **params: Any) -> None:
|
||||
try:
|
||||
upid = getattr(self._guest_api(vmid, vm_type).status, action).post()
|
||||
upid = getattr(self._guest_api(vmid, vm_type).status, action).post(**params)
|
||||
except Exception as exc:
|
||||
raise RuntimeError(f"{action} of {vm_type} {vmid} failed: {exc}") from exc
|
||||
if upid:
|
||||
@@ -197,6 +198,10 @@ class ProxmoxVMContractMixin:
|
||||
suspend is experimental (CRIU), and its listing does not tell a suspended
|
||||
container from another. A guest that is not paused is refused too: PVE would
|
||||
answer a running one with success and do nothing.
|
||||
|
||||
From PVE 9.3 the guest agent sets the guest's clock to the host's time after
|
||||
it resumes (``sync-time-on-resume``); PVE skips that where the guest has no
|
||||
agent enabled and running.
|
||||
"""
|
||||
vmid, vm_type = self._resolve_vm(name)
|
||||
if vm_type != "vm":
|
||||
@@ -207,7 +212,8 @@ class ProxmoxVMContractMixin:
|
||||
state = qemu_status(current)
|
||||
if state != "paused":
|
||||
raise RuntimeError(f"Cannot resume VM {vmid}: it is not paused ({state})")
|
||||
self._run_power(vmid, vm_type, "resume")
|
||||
params = {"sync-time-on-resume": 1} if self._version_at_least(*PVE_9_3) else {}
|
||||
self._run_power(vmid, vm_type, "resume", **params)
|
||||
|
||||
def get_vm_config(self, name: str) -> VMConfigDict:
|
||||
vmid, vm_type = self._resolve_vm(name)
|
||||
|
||||
Reference in new issue
Block a user