Skip to content

vmware: DNS-name and fallback-VLAN based primary IPv4 selection - #13

Merged
dirtycache merged 1 commit into
mainfrom
feat/vm-primary-ip4-by-dns-name
Sep 2, 2026
Merged

dirtycache merged 1 commit into
mainfrom
feat/vm-primary-ip4-by-dns-name

Conversation

@dirtycache

Copy link
Copy Markdown
Owner

Summary

Refactors VM primary-IPv4 selection 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; prefer an interface IP matching its A record. Helps appliances that default-route out a data-plane interface instead of mgmt.
  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 options in config.py with parsing/validation.

Why

Fixes the two unknown config option warnings from settings.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.

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.
@dirtycache
dirtycache merged commit 4f3606f into main Sep 2, 2026
@dirtycache
dirtycache deleted the feat/vm-primary-ip4-by-dns-name branch September 2, 2026 19:35
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.

1 participant