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

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:
Christian Manivong committed 2026-11-01 16:38:38 +01:00
1 parent 1bf8de4c23
commit 52c802ed41
14 files changed
+812 -28

No files matched your search

+20
View File
@@ -8,6 +8,7 @@ from typing import Any, ClassVar
from napalm.base.exceptions import ConnectionException
from napalm_device_types import HypervisorDriver, LicenseMixin
from napalm_device_types.models import (
ClusterDict,
HypervisorHostDict,
LicenseDict,
SnapshotDict,
@@ -18,6 +19,7 @@ from napalm_device_types.models import (
from napalm_vmware import _session, paths
from napalm_vmware._inventory import Inventory
from napalm_vmware.parse.clusters import ClusterSources, host_cluster, manager_clusters
from napalm_vmware.parse.environment import environment
from napalm_vmware.parse.hosts import hypervisor_hosts
from napalm_vmware.parse.licenses import license_list
@@ -160,5 +162,23 @@ class VmwareBaseDriver(LicenseMixin, HypervisorDriver):
def get_hypervisor_hosts(self) -> list[HypervisorHostDict]:
return hypervisor_hosts(self._hosts(), standalone=self.STANDALONE)
def get_clusters(self) -> list[ClusterDict]:
collect = self._inventory.collect
src = ClusterSources(
hosts=self._hosts(),
datastores=collect("Datastore", paths.DATASTORE),
networks=collect("Network", paths.NETWORK),
dv_portgroups=collect("DistributedVirtualPortgroup", paths.DV_PORTGROUP),
)
if self.STANDALONE:
return [host_cluster(src)]
clusters = collect("ClusterComputeResource", paths.CLUSTER)
return manager_clusters(
collect("ComputeResource", paths.CLUSTER),
{c["_moref"] for c in clusters},
src,
instance_uuid=self._inventory.about().get("instanceUuid"),
)
def get_licenses(self) -> list[LicenseDict]:
return license_list(self._inventory.licenses())