Files
napalm-vmware/napalm_vmware/paths.py
T
Christian Manivong 52c802ed41
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
feat: get_clusters() and create_vm_from_cloud_init(node=)
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
2026-11-01 16:38:38 +01:00

99 lines
2.6 KiB
Python

"""The vSphere property paths the drivers read, per managed object type.
Single source of truth for both the drivers and ``tools/harvest.py``: a
fixture harvested from a real host contains exactly what the parsers are
later fed, no more and no less. Adding a path here is the first step of
adding a field to any getter.
"""
from __future__ import annotations
HOST = (
"name",
"summary.hardware",
"summary.quickStats",
"summary.managementServerIp",
"hardware.systemInfo",
"runtime.inMaintenanceMode",
"runtime.connectionState",
"runtime.healthSystemRuntime.systemHealthInfo.numericSensorInfo",
"config.product",
"config.network.pnic",
"config.network.vnic",
"config.network.portgroup",
"config.network.vswitch",
"config.network.dnsConfig",
"config.autoStart",
"configIssue",
"configManager.networkSystem",
"parent",
"datastore",
"network",
)
VM = (
"name",
"config.instanceUuid",
"config.template",
"config.guestId",
"config.guestFullName",
"config.annotation",
"config.firmware",
"config.version",
"config.hardware.numCPU",
"config.hardware.numCoresPerSocket",
"config.hardware.memoryMB",
"config.hardware.device",
"config.bootOptions.bootOrder",
"runtime.powerState",
"runtime.host",
"summary.quickStats",
"guest.net",
"guest.ipAddress",
"guest.hostName",
"config.files.vmPathName",
"guest.toolsStatus",
"guest.toolsRunningStatus",
"snapshot",
)
DATASTORE = (
"name",
"summary",
)
DV_PORTGROUP = (
"name",
"config.defaultPortConfig",
"config.distributedVirtualSwitch",
"config.uplink",
)
DV_SWITCH = ("name",)
# Placement of new VMs: which network objects exist, and the parent chain from
# a host's compute resource up to its datacenter.
NETWORK = ("name",)
COMPUTE_RESOURCE = ("parent", "resourcePool")
FOLDER = ("parent",)
DATACENTER = ("name", "vmFolder")
# get_clusters: every compute resource and its hosts. Read once as
# ComputeResource (clusters included, a subtype) and once as
# ClusterComputeResource to tell the two apart.
CLUSTER = ("name", "host")
#: Managed object type name -> paths, in the order harvest.py dumps them.
ALL = {
"HostSystem": HOST,
"VirtualMachine": VM,
"Datastore": DATASTORE,
"DistributedVirtualPortgroup": DV_PORTGROUP,
"DistributedVirtualSwitch": DV_SWITCH,
"Network": NETWORK,
"ComputeResource": tuple(dict.fromkeys(COMPUTE_RESOURCE + CLUSTER)),
"ClusterComputeResource": CLUSTER,
"Folder": FOLDER,
"Datacenter": DATACENTER,
}