The vCenter driver reads how people log in to the vSphere Client, in napalm-device-types' WebLoginAuthDict: each identity provider of identity federation (GET /api/vcenter/identity/providers) is a source that decides itself (external), the default first; each SSO domain the vSphere API names (UserDirectory.domainList) is a source whose second factor cannot be read (unknown), since smart card and RSA SecurID live in SSO's authentication policy, which neither API exposes. Listing the providers needs VcIdentityProviders.Read and .Manage; without them the vCenter answers 403 and the driver raises PermissionError naming them. The REST read logs in to /api/session with the same account and logs out after. The ESXi driver has no reader.
54 lines
1.9 KiB
Python
54 lines
1.9 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
|
|
from napalm_vmware.provisioning import VmwareProvisioningMixin
|
|
from napalm_vmware.web_login import VcenterWebLoginMixin
|
|
|
|
|
|
class VmwareVcenterDriver(
|
|
VcenterWebLoginMixin, VmwareProvisioningMixin, VmwareActionsMixin, VmwareBaseDriver
|
|
):
|
|
"""A vCenter and every VM, datastore and port group it manages, and how people
|
|
log in to its web interface (``web_login``)."""
|
|
|
|
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 {}
|