feat(hypervisor): resume_vm, and a paused guest is never running (NetOrk/netork#2658)
driver / lint (pull_request) Successful in 12s
driver / standard (pull_request) Successful in 15s
driver / types (pull_request) Successful in 50s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / lowest (pull_request) Successful in 36s
driver / test (3.13) (pull_request) Successful in 1m0s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 59s
CI / driver (pull_request) Successful in 2m24s
driver / publish (pull_request) Skipped

The contract could suspend a VM but not bring it back: suspend_vm pointed
at start_vm, which Proxmox refuses for a paused guest because it is still
running. resume_vm is declared beside suspend_vm, optional like every power
action, and get_vms() says a guest that is not executing is paused or
suspended, never running.
This commit is contained in:
christianmanivong committed 2026-11-25 21:26:37 +01:00
1 parent e729b935a4
commit cd47587e80
3 files changed
+63 -2

No files matched your search

+23
View File
@@ -12,6 +12,7 @@ These tests pin the property that prevents a fourth.
from __future__ import annotations
import ast
import inspect
import pytest
@@ -82,6 +83,7 @@ class TestDeclaredMethodsDoNotExistAtRuntime:
(StorageDriver, "get_disks"),
(StorageDriver, "get_volumes"),
(HypervisorDriver, "get_vms"),
(HypervisorDriver, "resume_vm"),
(FirewallDriver, "send_wake_on_lan"),
(SwitchDriver, "set_vlan"),
(AccessPointDriver, "get_wireless_config"),
@@ -101,6 +103,27 @@ class TestDeclaredMethodsDoNotExistAtRuntime:
assert not hasattr(base, method)
class TestHypervisorPowerContract:
"""The power actions a hypervisor driver may implement, as declared."""
@staticmethod
def _declared(module) -> dict[str, list[str]]:
tree = ast.parse(inspect.getsource(module))
methods: dict[str, list[str]] = {}
for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef):
methods[node.name] = [a.arg for a in node.args.args]
return methods
def test_resume_vm_is_declared_beside_suspend_vm(self):
"""A VM netOrk paused must be one it can bring back (NetOrk/netork#2658)."""
from napalm_device_types import hypervisor
declared = self._declared(hypervisor)
assert declared.get("suspend_vm") == ["self", "name"]
assert declared.get("resume_vm") == ["self", "name"]
class TestNoShadowingAcrossRoles:
"""The regression test for the bug class."""