feat(vm-provision): declare the guest agent per guest OS, Linux only
CI / test (3.10) (push) Successful in 30s
CI / test (3.11) (push) Successful in 26s
CI / test (3.12) (push) Successful in 28s
CI / test (3.10) (pull_request) Successful in 27s
CI / test (3.11) (pull_request) Successful in 26s
CI / test (3.12) (pull_request) Successful in 27s

Follows napalm-device-types 3.0, which replaces GUEST_AGENT_PACKAGES /
GUEST_AGENT_RUNCMD with GUEST_AGENTS = {guest_os: (packages, runcmd)}.
VMware lists Linux with open-vm-tools, as before, and refuses any other
guest_os before anything is created: BSD guests on VMware are optional
for now (NetOrk/netork#801).

The NoCloud network-config moved to napalm-device-types
(`provisioning.network_config`), which Proxmox now uses as well; the seed
module's copy is gone, and the tests check that the generic one is used.
This commit is contained in:
Christian Manivong
2026-10-08 07:54:13 +02:00
parent 0430ded280
commit b5c830acfe
8 changed files with 53 additions and 35 deletions
+13 -6
View File
@@ -22,6 +22,7 @@ from napalm_device_types.models import (
VMProvisionResultDict,
VMStatusDict,
)
from napalm_device_types.provisioning import GuestAgents, network_config
from pyVmomi import vim
from napalm_vmware import paths
@@ -35,7 +36,7 @@ from napalm_vmware.provision.image import ImageCache
from napalm_vmware.provision.ovf import ovf_descriptor
from napalm_vmware.provision.placement import Inventory as PlacementInventory
from napalm_vmware.provision.placement import Placement, choose_placement
from napalm_vmware.provision.seed import meta_data, network_config, nocloud_iso, user_data
from napalm_vmware.provision.seed import meta_data, nocloud_iso, user_data
logger = logging.getLogger(__name__)
@@ -48,11 +49,14 @@ _STATUS = {"poweredOn": "running", "poweredOff": "stopped", "suspended": "suspen
class VmwareProvisioningMixin:
"""Mixed into both drivers ahead of :class:`VmwareBaseDriver`."""
GUEST_AGENT_PACKAGES: tuple[str, ...] = ("open-vm-tools",)
# The unit is open-vm-tools on Debian/Ubuntu and vmtoolsd on EL/Fedora.
GUEST_AGENT_RUNCMD: tuple[str, ...] = (
"systemctl enable --now open-vm-tools || systemctl enable --now vmtoolsd",
)
# Linux only: BSD guests on VMware are optional (NetOrk/netork#801). The
# unit is open-vm-tools on Debian/Ubuntu and vmtoolsd on EL/Fedora.
GUEST_AGENTS: GuestAgents = {
"linux": (
("open-vm-tools",),
("systemctl enable --now open-vm-tools || systemctl enable --now vmtoolsd",),
),
}
hostname: str
_port: int
@@ -148,9 +152,12 @@ class VmwareProvisioningMixin:
disk_resize_gb: int | None = None,
storage: str | None = None,
cpu_type: str | None = None,
guest_os: str = "linux",
download_timeout: int = 300,
timeout: int = 180,
) -> VMProvisionResultDict:
if guest_os not in self.GUEST_AGENTS:
raise ValueError(f"VMware provisions Linux guests only, not {guest_os!r}")
if cpu_type is not None:
# CPU compatibility is a cluster setting here (EVC), not a per-VM
# one, and there is no get_vm_cpu_types() that could offer a model.