Two drivers from one package, both in the hypervisor role: - vmware_esxi talks to one host directly: facts, vmnics and vmkernel NICs, CDP/LLDP neighbours, sensors, VMs, datastores and port groups. - vmware_vcenter talks to a vCenter: every VM of every host it manages, with the host as the VM's node, plus distributed port groups. It reports no interfaces of its own; the hosts' NICs belong to the hosts. Both implement the HypervisorDriver VM contract: get_vms, get_vm_config, start/stop/reboot/suspend_vm and the four snapshot methods, and emit raw device warnings (maintenance mode, disconnected host, config issues, host managed by a vCenter, free license making the API read-only). Every read is a PropertyCollector query for the explicit paths in paths.py, converted by to_plain() into dicts and lists; the parsers only ever see that. tools/harvest.py dumps exactly those paths to JSON and tools/sanitize.py scrubs the dump, so a real host can become a test fixture without code changes. A VM's vmid is its instance UUID, which survives vMotion and re-registration; a MoRef does not. Tested against govmomi's vcsim in ESXi and vCenter mode, including real power and snapshot tasks. Not yet tested against real hardware.
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
"""NAPALM driver for VMware vCenter Server.
|
|
|
|
netOrk treats the vCenter as one device. The ESXi hosts behind it appear as
|
|
the ``node`` of each VM; a host can additionally be added with the
|
|
``vmware_esxi`` driver when its own NICs and sensors are of interest.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from napalm_device_types import FingerprintRule
|
|
|
|
from napalm_vmware.actions import VmwareActionsMixin
|
|
from napalm_vmware.base import VmwareBaseDriver
|
|
from napalm_vmware.parse.facts import vcenter_facts
|
|
|
|
|
|
class VmwareVcenterDriver(VmwareActionsMixin, VmwareBaseDriver):
|
|
"""A vCenter and every VM, datastore and port group it manages."""
|
|
|
|
DRIVER_NAME = "vmware_vcenter"
|
|
API_TYPE = "VirtualCenter"
|
|
STANDALONE = False
|
|
# The appliance starts several dozen services before the API answers.
|
|
REBOOT_SETTLE_SECONDS = 600
|
|
# Unverified against real hardware; see VmwareEsxiDriver.
|
|
HTTP_FINGERPRINT = [
|
|
FingerprintRule("vcenter", weight=9.0, mandatory=True),
|
|
FingerprintRule("vsphere", weight=3.0),
|
|
FingerprintRule("vmware esxi", weight=9.0, negative=True),
|
|
]
|
|
|
|
def get_facts(self) -> dict[str, Any]:
|
|
return vcenter_facts(self._inventory.about(), self.hostname)
|
|
|
|
# The hosts' NICs are not the vCenter's; reporting them here would attach
|
|
# their MAC addresses to the wrong device. The appliance's own NICs are
|
|
# only visible through its management API, which this driver does not use.
|
|
|
|
def get_interfaces(self) -> dict[str, dict[str, Any]]:
|
|
return {}
|
|
|
|
def get_interfaces_ip(self) -> dict[str, dict[str, Any]]:
|
|
return {}
|
|
|
|
def get_lldp_neighbors(self) -> dict[str, list[dict[str, str]]]:
|
|
return {}
|