Repository navigation
Conversation
The VMware source derives the type of a host pNIC from its current link speed (or the first valid link speed without link). With a check_redfish source on the same hosts, which sets the type from the NIC hardware, both sources overwrote each other on every run, i.e. 10gbase-x-sfpp <> 1000base-t for an SFP+ port running at 1G. Keep the current type of an existing host interface if it is a physical type which supports the speed vCenter reports. A slower type is still updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
semx
left a comment
There was a problem hiding this comment.
The conflict between the two sources is real, but the speed heuristic changes behaviour for everyone:
- vCenter-only setups no longer get a too fast type corrected. Checked on 4.7.2 with vcsim: development sets vmnic0 back from 400gbase-x-qsfpdd to 1000base-t, this branch keeps 400G.
- A port without link: vCenter derives
other, itsvalid_typesvalue is a string, so the guard is skipped and the SFP+ type is still overwritten, the second case from the description. - The FC types are in Gbit (1..128) and the Ethernet ones in Mbit, so with
sync_host_fc_adaptersthey're compared across families.
I'd make this explicit instead: an overwrite_host_interface_type option like overwrite_device_interface_name, default True (current behaviour), and with False an existing physical type is kept. That covers redfish plus vCenter without guessing from speeds.
On the description: within one run the PATCH is cancelled again by the revert logic, what repeats is the log line, and the final type depends on the order of the sources.
Replace the link speed heuristic of the previous commit with an explicit option, as suggested in the review. The heuristic changed the behaviour for vCenter-only setups (a too fast type was no longer corrected), still overwrote the type of a port without link (derived as 'other') and compared FC types in Gbit with Ethernet types in Mbit. overwrite_host_interface_type defaults to True, the current behaviour. With False the type of an existing host interface is kept if it is a physical type, so a check_redfish source can own the type of the host interfaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Agreed. The speed comparison was guessing, and your three cases show it. I replaced it with
The title is now |
semx
left a comment
There was a problem hiding this comment.
Much simpler this way, thanks. I tried it on the vcsim setup: set two vmnics to SFP+ and one to other through the API. With the option off the SFP+ types stayed, other got the link speed type, and the next run didn't touch anything. With the default, vCenter put 1000base-t back like before.
|
Confirmed with |
The VMware source derives a host pNIC's type from its current link speed. If the NIC has no link, it uses the first valid link speed, or
other. The check_redfish source sets the type from the NIC hardware. With both sources on the same ESXi hosts, they disagree on every run:The first case is an SFP+ port running at 1G; the second is an SFP+ port without link. Within one run, the revert logic cancels the PATCH again. What repeats is the log line, and the final type depends on the order of the sources.
This adds an option to the VMware source, as suggested in the review:
The default
Truekeeps the current behaviour, so vCenter-only setups still get a wrong type corrected. WithFalse, the type of an existing host interface is kept if it's a physical type.virtual,bridge,lag,otheror no type are still set by vCenter. New interfaces get the type vCenter derives.Changes:
module/sources/vmware/config.py,settings-example.ini: new optionoverwrite_host_interface_type, defaultTrue.module/sources/vmware/connection.py: with the optionFalse, don't send a type for an existing host interface that has a physical type. NetBox returns the type as{"value": ..., "label": ...}, so the value is read from that dict.tests/test_vmware_host_nic_type.py: second-run tests. WithFalse, a physical type is kept andotheris still updated. With the default, a wrong type is still set from the link speed. The first test fails ondevelopment.Tested with the vcsim captures; see the tests above. Against NetBox 4.7.2 with a vCenter source and the check_redfish inventory files of HPE and Lenovo hosts, the first version of this PR stopped the
typechanges in the dry-run. Confirmed withoverwrite_host_interface_type: Falseon our test and prod instances: the dry-run logs notypechanges for host interfaces and no errors.pytest: 374 passed, 8 skipped (vcsim installed).🤖 Generated with Claude Code