Repository navigation
vmware: DNS-name and fallback-VLAN based primary IPv4 selection - #13
Merged
Merged
Conversation
Refactor VM primary-IPv4 determination into a 3-tier get_vm_primary_ip4():
1. vm_primary_ip4_by_dns_name (new, opt-in, default off): forward-resolve
the VM's synced name and prefer an interface IP that matches its A
record. Helps appliances that default-route out a data-plane interface
instead of the management interface.
2. default-gateway subnet match — existing behavior, unchanged when the
new options are unset.
3. vm_primary_ip4_fallback_vlans (new): ordered last-resort mgmt-VLAN list
used only when neither DNS name nor default gateway yields a primary.
Adds perform_forward_lookups()/forward_lookup() to common/support.py (async
aiodns A-record resolution mirroring reverse_lookup) and registers both new
VMware source options in config.py with parsing/validation. No behavior
change unless the new options are configured.
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.
Summary
Refactors VM primary-IPv4 selection into a 3-tier
get_vm_primary_ip4():vm_primary_ip4_by_dns_name(new, opt-in, default off) — forward-resolve the VM's synced name; prefer an interface IP matching its A record. Helps appliances that default-route out a data-plane interface instead of mgmt.vm_primary_ip4_fallback_vlans(new) — ordered last-resort mgmt-VLAN list, used only when neither DNS name nor default gateway yields a primary.Adds
perform_forward_lookups()/forward_lookup()tocommon/support.py(async aiodns A-record resolution mirroringreverse_lookup) and registers both options inconfig.pywith parsing/validation.Why
Fixes the two
unknown config optionwarnings fromsettings.ini(vm_primary_ip4_by_dns_name,vm_primary_ip4_fallback_vlans) which referenced this never-committed feature, and makes primary-IP selection deterministic for multi-homed VMs / appliances whose default gateway isn't on the mgmt network.Testing
Dry-run (
-n) against live vcs01a + NetBox 4.5.9: connects, no unknown-option warnings, no errors, forward-lookup path exercised (invalid-hostname edge case handled). No behavior change unless the new options are set.