Repository navigation
Conversation
…_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
left a comment
There was a problem hiding this comment.
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.
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
match_host_by_serial) → asset tag → MAC addresses → primary IP.disable_host_mac_matching(defaultFalse) skips the MAC fallback for hosts.match_vm_by_mac_address/match_vm_by_serial/match_vm_by_ip_address.config.pyandsettings-example.ini.Tests
tests/test_vmware_host_matching.py, covering:disable_host_mac_matchingmatch_host_by_serial = FalseMatch 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.