Skip to content

vmware: sync Fibre Channel HBAs of hosts as interfaces - #591

Merged
semx merged 1 commit into
developmentfrom
feature/host-fc-adapters
Oct 10, 2026
Merged

semx merged 1 commit into
developmentfrom
feature/host-fc-adapters

Conversation

@semx

@semx semx commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Fibre Channel HBAs of ESXi hosts as NetBox interfaces, for #343, behind sync_host_fc_adapters (default off).

For every vim.host.FibreChannelHba of a host (block and PCIe adapters are ignored) an interface is created on the device: the adapter's device name (vmhba3), the FC interface type derived from the adapter model's capability (QLE2700/QLE2800 32/64G … → 32gfc-sfp28; the port's current link speed is only used when the model names none, so a port that drops link keeps its type), the port WWN converted from the decimal the API returns to the 21:00:F4:C7:AA:9E:28:E6 form NetBox stores, model and driver as description, enabled from the adapter status.

The matching code needed one change: an FC HBA has no MAC, and interfaces that match nothing used to be paired 1:1 by name with whatever current interface was left. On a host that also had a BMC interface from the check_redfish source that pairing renamed the BMC interface to vmhba4 and moved its IP around. Now an interface with a WWN matches the current interface with the same WWN when no interface of its name exists (case-insensitive), and Fibre Channel ports, meaning an FC interface type or a WWN without a MAC address, take no part in the leftover pairing on either side. Interfaces with a MAC address are matched exactly as before, including converged adapter ports that check_redfish reports with both a MAC and a WWN; a test pins that. An FC adapter that reports no port WWN is skipped, since the WWN is what tells it apart from a NIC. A unit test reproduces the hijack and fails without the change.

Live NetBox 4.7.2 with the vc001 inventory (20 FC HBAs on 3 hosts) and check_redfish as a second source: the option on creates 20 FC interfaces with uppercase WWNs and types 32gfc-sfp28 (20 POST, no PATCH on existing interfaces or IPs), the BMC interface keeps its name and IP, and the second run writes nothing. (A first version sent lowercase WWNs, which NetBox normalises, and PATCHed every FC interface on every run; that is why the case matters.)

Tests: tests/test_vmware_host_fc_adapters.py (32): type derivation for every speed and for the model string, WWN conversion and padding, option off creates nothing, vc001 interfaces (exactly the 8 FC adapters and none of the SATA/NVMe controllers, types, WWNs, description, enabled state), the hijack, WWN matching when no interface of that name exists and across case, two HBAs sharing a WWN not merged, a current FC interface never handed to a new NIC, each of the two FC signals on its own, a MAC+WWN port still matched by MAC, host_interface_exclude_filter applied to the adapter names. On development without this change 28 of the 31 test runs fail; the three that pass pin today's behaviour (the MAC+WWN port, the exclude filter). Full suite: 311 passed, 1 skipped (development: 280). With the option unset the handler produces the same inventory as development on vc001: 324 objects, byte-identical canonical dump.

Behind the new option sync_host_fc_adapters (off by default) every
vim.host.FibreChannelHba of an ESXi host becomes a NetBox interface on
the device: the adapter's device name, an FC interface type derived
from the model's capability (the port's link speed only when the model
names none, so a port that drops link keeps its type), the port WWN in
the colon separated upper case form NetBox stores, model and driver as
description, and enabled from the adapter status. Block and PCIe host
bus adapters are ignored, as is an FC adapter that reports no port WWN.

FC HBAs carry no MAC address, and interfaces that match nothing used to
be paired 1:1 by name with whatever current interface was left, which
on a host with a BMC interface from another source renamed that
interface and moved its IP. Interfaces with a WWN now match by it when
no interface of their name exists, and Fibre Channel ports (an FC
interface type, or a WWN without a MAC address) take no part in the
leftover pairing, on either side. Interfaces with a MAC address,
converged adapter ports among them, are matched as before.

The NetBox FC interface types are added to the known interface types.

Fixes #343
@semx
semx requested a review from bb-Ricardo as a code owner October 10, 2026 01:40
@semx
semx merged commit 3359171 into development Oct 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant