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
+8 -2
View File
@@ -94,8 +94,14 @@ class TestIdentity:
assert callable(getattr(cls, method, None))
@pytest.mark.parametrize("cls", DRIVERS)
def test_declares_its_guest_agent(self, cls):
assert cls.GUEST_AGENT_PACKAGES == ("open-vm-tools",)
def test_provisions_linux_guests_with_open_vm_tools(self, cls):
"""Linux only: BSD guests on VMware are optional (NetOrk/netork#801)."""
assert cls.GUEST_AGENTS == {
"linux": (
("open-vm-tools",),
("systemctl enable --now open-vm-tools || systemctl enable --now vmtoolsd",),
),
}
class TestOptionalArgs:
+10 -11
View File
@@ -6,8 +6,11 @@ import io
import pycdlib
import yaml
from napalm_device_types import provisioning as generic
from napalm_vmware.provision.seed import meta_data, network_config, nocloud_iso, user_data
from napalm_vmware import provisioning as prov
from napalm_vmware.provision import seed
from napalm_vmware.provision.seed import meta_data, nocloud_iso, user_data
class TestUserData:
@@ -34,17 +37,13 @@ def test_meta_data():
class TestNetworkConfig:
def test_dhcp_nics_matched_by_mac(self):
cfg = network_config([("00:50:56:aa:bb:cc", True), ("00:50:56:aa:bb:dd", False)])
assert cfg == {
"version": 2,
"ethernets": {
"nic0": {"match": {"macaddress": "00:50:56:aa:bb:cc"}, "dhcp4": True},
},
}
"""Written by napalm-device-types, which Proxmox uses as well (NetOrk/netork#794)."""
def test_no_dhcp_nic_means_no_network_config(self):
assert network_config([("00:50:56:aa:bb:cc", False)]) is None
def test_the_seed_is_built_with_the_generic_network_config(self):
assert prov.network_config is generic.network_config
def test_no_copy_of_it_is_left_here(self):
assert not hasattr(seed, "network_config")
def _read(iso: bytes, name: str) -> str:
+12
View File
@@ -152,6 +152,18 @@ class TestCreate:
staged.cache.return_value.vmdk.assert_not_called()
staged.import_ovf.assert_not_called()
@pytest.mark.parametrize("guest_os", ["freebsd", "openbsd"])
def test_a_guest_other_than_linux_is_refused_before_anything_happens(
self, driver, staged, guest_os
):
with pytest.raises(ValueError, match=guest_os):
_create(driver, guest_os=guest_os)
staged.cache.return_value.vmdk.assert_not_called()
staged.import_ovf.assert_not_called()
def test_linux_is_the_default_guest(self, driver, staged):
assert _create(driver, guest_os="linux")["vmid"] == "uuid-99"
def test_placement_refusal_is_a_runtime_error(self, driver, staged):
with patch.object(prov, "choose_placement", side_effect=ValueError("no host")):
with pytest.raises(RuntimeError, match="no host"):