feat(provisioning): accept cpu_type, and refuse one that cannot be honoured

napalm_device_types' create_vm_from_cloud_init gained cpu_type, the CPU model
a new VM gets (netork#494). VMware sets CPU compatibility per cluster (EVC),
not per VM, and this driver has no get_vm_cpu_types() to offer a model, so
None is the only value it can honour. Anything else raises ValueError before
the image is fetched rather than being dropped silently.
This commit is contained in:
Christian Manivong
2026-10-04 12:02:48 +02:00
parent 25bad821ab
commit 4b4410741f
2 changed files with 16 additions and 0 deletions
+11
View File
@@ -141,6 +141,17 @@ class TestCreate:
_create(driver)
staged.discard.assert_called_once_with("vm-99")
def test_no_cpu_type_is_the_normal_case(self, driver, staged):
assert _create(driver, cpu_type=None)["vmid"] == "uuid-99"
def test_a_cpu_type_is_refused_before_anything_happens(self, driver, staged):
"""VMware sets CPU compatibility per cluster (EVC), not per VM, so a
requested model cannot be honoured -- and is not silently dropped."""
with pytest.raises(ValueError, match="CPU type"):
_create(driver, cpu_type="host")
staged.cache.return_value.vmdk.assert_not_called()
staged.import_ovf.assert_not_called()
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"):