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
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import pytest
|
||||
|
||||
from napalm_vmware.provision.placement import Inventory as Inv
|
||||
from napalm_vmware.provision.placement import choose_placement
|
||||
from napalm_vmware.provision.placement import NodeRefused, choose_placement
|
||||
|
||||
|
||||
def _host(moref, name, *, datastores, networks, parent="domain-c1", state="connected", maint=False):
|
||||
@@ -112,3 +112,43 @@ def test_datacenter_is_found_through_nested_folders(inv):
|
||||
inv.compute_resources[0]["parent"] = "group-h2"
|
||||
inv.folders.append({"_moref": "group-h2", "parent": "group-h1"})
|
||||
assert choose_placement(inv, storage=None, networks=["VM Network"]).datacenter_name == "DC0"
|
||||
|
||||
|
||||
class TestNamedHost:
|
||||
"""``create_vm_from_cloud_init(node=...)``: only that host is considered."""
|
||||
|
||||
def test_the_named_host_is_used_even_with_less_free_space_elsewhere(self, inv):
|
||||
inv.hosts[0]["datastore"] = ["ds-1"]
|
||||
p = choose_placement(inv, storage=None, networks=["VM Network"], host_name="esx01")
|
||||
assert (p.host, p.datastore_name, p.networks) == ("host-1", "local1", ["net-1"])
|
||||
|
||||
def test_the_best_datastore_of_the_named_host(self, inv):
|
||||
p = choose_placement(inv, storage=None, networks=["VM Network"], host_name="esx02")
|
||||
assert (p.host, p.datastore_name) == ("host-2", "san")
|
||||
|
||||
def test_an_unknown_host(self, inv):
|
||||
with pytest.raises(NodeRefused, match="no host named 'esx99'"):
|
||||
choose_placement(inv, storage=None, networks=["VM Network"], host_name="esx99")
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("change", "message"),
|
||||
[
|
||||
(lambda h: h.update({"runtime.inMaintenanceMode": True}), "maintenance"),
|
||||
(lambda h: h.update({"runtime.connectionState": "disconnected"}), "not connected"),
|
||||
],
|
||||
)
|
||||
def test_a_host_that_cannot_take_a_vm(self, inv, change, message):
|
||||
change(inv.hosts[1])
|
||||
with pytest.raises(NodeRefused, match=f"esx02.*{message}"):
|
||||
choose_placement(inv, storage=None, networks=["VM Network"], host_name="esx02")
|
||||
|
||||
def test_a_host_without_the_networks(self, inv):
|
||||
with pytest.raises(NodeRefused, match="esx02 does not see"):
|
||||
choose_placement(inv, storage=None, networks=["DC0_DVPG0"], host_name="esx02")
|
||||
|
||||
def test_a_host_without_the_datastore(self, inv):
|
||||
with pytest.raises(NodeRefused, match="esx02 does not see datastore local1"):
|
||||
choose_placement(inv, storage="local1", networks=["VM Network"], host_name="esx02")
|
||||
|
||||
def test_a_refused_host_is_a_value_error(self):
|
||||
assert issubclass(NodeRefused, ValueError)
|
||||
Reference in new issue
Block a user