feat: get_clusters() and create_vm_from_cloud_init(node=)
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Failing after 1m2s
driver / test (3.12) (pull_request) Failing after 57s
driver / test (3.13) (pull_request) Failing after 52s
driver / lowest (pull_request) Failing after 25s
driver / build (pull_request) Successful in 24s
driver / security (pull_request) Successful in 57s
CI / driver (pull_request) Failing after 2m21s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 14s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Failing after 1m2s
driver / test (3.12) (pull_request) Failing after 57s
driver / test (3.13) (pull_request) Failing after 52s
driver / lowest (pull_request) Failing after 25s
driver / build (pull_request) Successful in 24s
driver / security (pull_request) Successful in 57s
CI / driver (pull_request) Failing after 2m21s
driver / publish (pull_request) Skipped
vCenter reports each cluster compute resource, and each standalone host it runs as a cluster of one, identified by "<instanceUuid>/<moref>"; an ESXi host reports itself. Nodes carry state, maintenance, CPU and memory; datastores and port groups carry the hosts that see them. create_vm_from_cloud_init(node=) places the VM on that host and refuses one that does not exist or cannot take it, before anything is created. Placement now runs before the image download, so a refused host fails at once instead of after the download. Refs NetOrk/netork#484, NetOrk/netork#1822
This commit is contained in:
1 parent
1bf8de4c23
commit
52c802ed41
14 files changed
+812
-28
No files matched your search
@@ -11,7 +11,7 @@ import yaml
|
||||
|
||||
from napalm_vmware import VmwareEsxiDriver
|
||||
from napalm_vmware import provisioning as prov
|
||||
from napalm_vmware.provision.placement import Placement
|
||||
from napalm_vmware.provision.placement import NodeRefused, Placement
|
||||
from tests.conftest import FakeInventory
|
||||
|
||||
PLACE = Placement(
|
||||
@@ -170,6 +170,31 @@ class TestCreate:
|
||||
_create(driver)
|
||||
staged.import_ovf.assert_not_called()
|
||||
|
||||
def test_an_image_refusal_is_a_runtime_error(self, driver, staged):
|
||||
staged.cache.return_value.vmdk.side_effect = ValueError("checksum mismatch")
|
||||
with pytest.raises(RuntimeError, match="checksum mismatch"):
|
||||
_create(driver)
|
||||
staged.import_ovf.assert_not_called()
|
||||
|
||||
def test_no_node_leaves_the_host_to_placement(self, driver, staged):
|
||||
with patch.object(prov, "choose_placement", return_value=PLACE) as choose:
|
||||
_create(driver)
|
||||
assert choose.call_args.kwargs["host_name"] is None
|
||||
|
||||
def test_the_node_is_the_only_host_placement_considers(self, driver, staged):
|
||||
with patch.object(prov, "choose_placement", return_value=PLACE) as choose:
|
||||
assert _create(driver, node="esx01")["node"] == "esx01"
|
||||
assert choose.call_args.kwargs["host_name"] == "esx01"
|
||||
|
||||
def test_a_refused_node_is_a_value_error_before_anything_happens(self, driver, staged):
|
||||
refusal = NodeRefused("There is no host named 'esx99'")
|
||||
with patch.object(prov, "choose_placement", side_effect=refusal):
|
||||
with pytest.raises(ValueError, match="esx99") as raised:
|
||||
_create(driver, node="esx99")
|
||||
assert not isinstance(raised.value, RuntimeError)
|
||||
staged.cache.return_value.vmdk.assert_not_called()
|
||||
staged.import_ovf.assert_not_called()
|
||||
|
||||
|
||||
MAC = "00:0c:29:39:31:62"
|
||||
|
||||
|
||||
Reference in new issue
Block a user