Files
napalm-proxmox/napalm_proxmox/pve_values.py
T
Christian Manivong 0704d9a102
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Successful in 1m3s
driver / test (3.12) (pull_request) Successful in 1m10s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / lowest (pull_request) Successful in 33s
driver / build (pull_request) Successful in 33s
driver / security (pull_request) Successful in 1m27s
CI / driver (pull_request) Successful in 3m4s
driver / publish (pull_request) Skipped
feat: HA state, backups and votes in get_clusters(); migrate_vm, preflight, maintenance
get_clusters() reads /cluster/ha/* (PVE 8 and 9), /cluster/backup with pool
members, the newest backup per guest on each backup storage (PBS included) and
/cluster/config/nodes votes; each read is best-effort. migrate_vm() moves a
guest of the connected node and follows the task (HA-managed guests through
the HA manager), raising with the task log's ERROR lines;
get_vm_migration_preflight() maps PVE's own pre-flight; set_node_maintenance()
runs ha-manager over SSH.

Part of NetOrk/netork#1820 (stage 7: #759, #760, #761).
2026-11-01 22:15:01 +01:00

28 lines
787 B
Python

"""How the Proxmox VE API writes plain values: numbers as strings, flags as 0/1, lists
as comma-separated strings."""
from __future__ import annotations
import re
from typing import Any
_LIST_SEPARATORS = re.compile(r"[\s,;\0]+")
def to_int(value: Any) -> int | None:
return None if value is None else int(value)
def to_flag(value: Any) -> bool:
return bool(int(value or 0))
def split_list(value: Any) -> list[str]:
"""``"a,b"`` -> ``["a", "b"]``; PVE also separates with ``;``, blanks or NUL."""
return [part for part in _LIST_SEPARATORS.split(str(value or "")) if part]
def vmid_list(value: Any) -> list[int]:
"""``"100,101"`` -> ``[100, 101]``; what is not a number is left out."""
return [int(part) for part in split_list(value) if part.isdigit()]