Files
napalm-proxmox/tests/test_pve_version.py
T
Christian Manivong fddf8af680 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.
2026-11-26 17:35:50 +01:00

47 lines
1.7 KiB
Python

"""Which Proxmox VE release the node runs, for what only newer releases offer.
``GET /version`` names the pve-manager package's version (``"9.3.0"``) and the
point release (``"9.3"``). PVE 9.3 added the REST calls of NetOrk/netork#2728;
the driver takes them only on a node that has them.
"""
from __future__ import annotations
import pytest
@pytest.mark.parametrize(
("version", "expected"),
[
({"version": "9.3.0", "release": "9.3"}, True),
({"version": "9.3.2", "release": "9.3"}, True),
({"version": "10.0.1", "release": "10.0"}, True),
({"version": "9.2.4", "release": "9.2"}, False),
({"version": "8.4.1", "release": "8.4"}, False),
# No package version: the point release tells.
({"release": "9.3"}, True),
],
)
def test_at_least(driver, version, expected):
driver._api.version.get.return_value = version
assert driver._version_at_least(9, 3) is expected
@pytest.mark.parametrize("version", [{}, {"version": "unknown", "release": ""}])
def test_a_version_it_cannot_read_counts_as_older(driver, version):
driver._api.version.get.return_value = version
assert driver._version_at_least(9, 3) is False
def test_an_api_error_propagates(driver):
driver._api.version.get.side_effect = ConnectionError("node unreachable")
with pytest.raises(ConnectionError):
driver._version_at_least(9, 3)
def test_another_node_is_asked_for_its_own_version(driver):
driver._api.version.get.return_value = {"version": "9.3.0", "release": "9.3"}
driver._api.nodes("pve2").version.get.return_value = {"version": "9.2.4", "release": "9.2"}
assert driver._version_at_least(9, 3, node="pve2") is False
driver._api.nodes.assert_called_with("pve2")