Repository navigation
vmware: sync Fibre Channel HBAs of hosts as interfaces - #591
Merged
Merged
Conversation
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
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fibre Channel HBAs of ESXi hosts as NetBox interfaces, for #343, behind
sync_host_fc_adapters(default off).For every
vim.host.FibreChannelHbaof 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 the21:00:F4:C7:AA:9E:28:E6form NetBox stores, model and driver as description,enabledfrom 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
vmhba4and 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_filterapplied to the adapter names. Ondevelopmentwithout 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 asdevelopmenton vc001: 324 objects, byte-identical canonical dump.