Skip to content

Configurable ESXi Host Matching Params - #588

Open
lukify85 wants to merge 1 commit into
bb-Ricardo:developmentfrom
lukify85:host-serial-matching
Open

lukify85 wants to merge 1 commit into
bb-Ricardo:developmentfrom
lukify85:host-serial-matching

Conversation

@lukify85

@lukify85 lukify85 commented Oct 9, 2026

Copy link
Copy Markdown

Problem

ESXi hosts are matched by MAC address before serial number. With MAC address pooling (e.g. Cisco UCS), the same MAC can be used by blades in different sites. A host can then be matched to the wrong NetBox device, which moves the device and its IPs to the wrong site.

Changes

  • Host matching order is now: name+site → serial (if match_host_by_serial) → asset tag → MAC addresses → primary IP.
  • New option disable_host_mac_matching (default False) skips the MAC fallback for hosts.
  • VM matching is unchanged and still controlled by match_vm_by_mac_address / match_vm_by_serial / match_vm_by_ip_address.
  • The new option is documented in config.py and settings-example.ini.

Tests

  • Adds tests/test_vmware_host_matching.py, covering:
    • a pooled MAC shared by two sites, where the serial must win
    • the MAC fallback when no serial matches
    • disable_host_mac_matching
    • match_host_by_serial = False
    • a host that reports no serial
  • Adds the new setting to the settings stubs in two existing tests.

Match ESXi hosts by serial/asset tag before MAC; add disable_host_mac_matching

With MAC address pooling (e.g. Cisco UCS) the same MAC can be used by blades in different sites, so matching hosts by MAC first could attach a host to a device in the wrong site. Hosts are now matched by name+site, serial number (if match_host_by_serial), asset tag, MAC addresses, then primary IP.

The new option 'disable_host_mac_matching' (default False) skips the MAC fallback for hosts. VM matching is unchanged and still controlled by match_vm_by_mac_address / match_vm_by_serial / match_vm_by_ip_address.

Rebuilt on top of upstream 1.9.0, replacing 6ff1d2a and d54a320. Also fixes a regression in 6ff1d2a where the serial lookup ran regardless of match_host_by_serial and with a missing serial, matching the first device without a serial.

…_matching

With MAC address pooling (e.g. Cisco UCS) the same MAC can be used by blades
in different sites, so matching hosts by MAC first could attach a host to a
device in the wrong site. Hosts are now matched by name+site, serial number
(if match_host_by_serial), asset tag, MAC addresses, then primary IP.

The new option 'disable_host_mac_matching' (default False) skips the MAC
fallback for hosts. VM matching is unchanged and still controlled by
match_vm_by_mac_address / match_vm_by_serial / match_vm_by_ip_address.

Rebuilt on top of upstream 1.9.0, replacing 6ff1d2a and d54a320. Also fixes
a regression in 6ff1d2a where the serial lookup ran regardless of
match_host_by_serial and with a missing serial, matching the first device
without a serial.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@semx
semx changed the base branch from main to development October 9, 2026 23:11

@semx semx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, pooled MACs are a real problem and the tests read well. Two asks before this goes in.

Retarget to development, please; main only receives releases (I can switch the base from here if you prefer).

The default order changes for everyone, not only for pooled-MAC setups: with match_host_by_serial = True, the default, serial now beats MAC. That hurts hosts whose BIOS reports a placeholder serial, which the option text already warns about and which we have seen in reports here ("Default string", "To be filled by O.E.M."). Repro on your branch: two devices with serial To be filled by O.E.M., vmnic0 …:AA on one and …:BB on the other; a host named esxi-b-renamed reporting that serial and MAC …:BB is matched to the first device carrying the serial (get_by_data returns the first hit), where development matches the right one by MAC. I can push that test as a suggestion.

So I'd keep the current order by default and let the new option switch it, e.g. host_match_serial_before_mac; or keep disable_host_mac_matching as the only new behavior, since with MAC matching off the order no longer matters for pooled MACs. Either way nothing changes for existing setups unless they opt in.

Your branch merges cleanly onto development and the full suite passes (285), so once the default is settled this is ready. It is a feature, so it goes into 1.10 rather than a patch release.

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.

2 participants