Merge branch 'fix/vm-resume-2658'
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
784f7ac686
3 files changed
+63
-2
No files matched your search
@@ -7,6 +7,8 @@ recorded here; their history is the git log.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [4.42.0] - 2026-11-25
|
||||
|
||||
### Added
|
||||
- `AptReleaseMixin.get_apt_source_releases()`: the host's release from `/etc/os-release`
|
||||
(`ID`, `ID_LIKE`, `VERSION_CODENAME`, `UBUNTU_CODENAME`) and every enabled source apt
|
||||
@@ -24,10 +26,18 @@ recorded here; their history is the git log.
|
||||
`server_active` instead of `server`. `configure_zabbix_agent`'s firewall step opens
|
||||
nothing for it and does not call the driver's `_allow_zabbix_agent_sources`, so no
|
||||
driver changes.
|
||||
- `HypervisorDriver.resume_vm(name)`: bring a paused or suspended VM back where it stopped,
|
||||
the counterpart of `suspend_vm` (NetOrk/netork#2658). Optional like every power action;
|
||||
a driver that can resume some guests but not others refuses the others with
|
||||
`RuntimeError`.
|
||||
|
||||
### Changed
|
||||
- `zabbix_agent_config` comments a `StartAgents=0` line out for an agent that is not
|
||||
active only, since it would keep the agent from listening; another count stays.
|
||||
- `HypervisorDriver.get_vms()`: a guest that is not executing is never `"running"`. It is
|
||||
`"paused"` while its process still holds its memory and `"suspended"` once its state was
|
||||
saved away (NetOrk/netork#2658). `suspend_vm` names `resume_vm`, not `start_vm`, as the
|
||||
way back.
|
||||
|
||||
## [4.41.0] - 2026-11-17
|
||||
|
||||
|
||||
@@ -71,7 +71,11 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
|
||||
* name (string) - VM display name
|
||||
* vmid (string) - hypervisor-internal ID (Proxmox: ``"100"``,
|
||||
VMware: the instance UUID)
|
||||
* status (string) - ``"running"``, ``"stopped"``, ``"paused"``, ``"suspended"``
|
||||
* status (string) - ``"running"``, ``"stopped"``, ``"paused"``, ``"suspended"``.
|
||||
A guest that is not executing is never ``"running"``: ``"paused"``
|
||||
while its process still holds its memory (Proxmox's ``qmpstatus``
|
||||
``paused``), ``"suspended"`` once its state was saved away (VMware's
|
||||
``suspended``). :meth:`resume_vm` brings either back.
|
||||
* vcpus (int) - number of virtual CPUs assigned
|
||||
* memory (int) - configured RAM in megabytes
|
||||
* cpu_usage (float) - current CPU utilisation 0.0–1.0
|
||||
@@ -248,7 +252,9 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
|
||||
def suspend_vm(self, name: str) -> None:
|
||||
"""
|
||||
Suspends (pauses) a running virtual machine, preserving its in-memory
|
||||
state. The VM can be resumed with :meth:`start_vm`.
|
||||
state. :meth:`get_vms` then reports it ``"paused"`` (its process
|
||||
still holds the memory) or ``"suspended"`` (its state was saved
|
||||
away), and :meth:`resume_vm` brings it back.
|
||||
|
||||
:param name: VM name or its ``vmid``.
|
||||
:raises ValueError: If no VM with the given name/ID exists.
|
||||
@@ -260,6 +266,28 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
|
||||
"""
|
||||
...
|
||||
|
||||
def resume_vm(self, name: str) -> None:
|
||||
"""
|
||||
Resumes a paused or suspended virtual machine where it stopped, the
|
||||
counterpart of :meth:`suspend_vm`. The method blocks until the
|
||||
hypervisor took the request.
|
||||
|
||||
Optional, like every power action: a driver whose platform cannot
|
||||
resume a guest does not implement it, and a caller then offers no
|
||||
resume. A driver that can resume some guests but not others (a
|
||||
Proxmox container) refuses the others with ``RuntimeError``.
|
||||
|
||||
:param name: VM name or its ``vmid``.
|
||||
:raises ValueError: If no VM with the given name/ID exists.
|
||||
:raises RuntimeError: If the VM is neither paused nor suspended, or
|
||||
the platform cannot resume this kind of guest.
|
||||
|
||||
Example::
|
||||
|
||||
driver.resume_vm("web01")
|
||||
"""
|
||||
...
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Snapshots
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@@ -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."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user