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:
Christian Manivong committed 2026-11-26 17:35:50 +01:00
1 parent c2d9d7e75e
commit fddf8af680
17 files changed
+718 -17

No files matched your search

+22
View File
@@ -28,6 +28,7 @@ from __future__ import annotations
import io
import logging
import re
from typing import Any
from napalm.base.exceptions import ConnectionException
@@ -39,6 +40,9 @@ logger = logging.getLogger(__name__)
_JsonDict = dict[str, Any]
#: The release at the start of a product version, ``"9.3"`` of ``"9.3.0"``.
_RELEASE = re.compile(r"^(\d+)\.(\d+)")
#: The API port of each proxmoxer service this package drives.
DEFAULT_PORTS = {"PVE": 8006, "PBS": 8007}
@@ -301,6 +305,24 @@ class ProxmoxBase:
logger.debug("Failed to fetch version info: %s", exc)
return {}
def _version_at_least(self, major: int, minor: int, node: str | None = None) -> bool:
"""Whether the product on the node is release *major*.*minor* or newer.
Read from ``GET /version`` of the node the driver is connected to, or with
*node* from ``GET /nodes/{node}/version``: during a rolling upgrade the
cluster's members run different releases. The package ``version``
(``"9.3.0"``) decides, else the point ``release`` (``"9.3"``). A version it
cannot parse counts as older, so the caller takes the path every release
has. An API error propagates.
"""
source = self._api.nodes(node).version if node else self._api.version
info = source.get() or {}
for raw in (info.get("version"), info.get("release")):
match = _RELEASE.match(str(raw or ""))
if match:
return (int(match[1]), int(match[2])) >= (major, minor)
return False
def _get_node_status(self) -> _JsonDict:
"""Return the node's status from the Proxmox API."""
try: