feat(network): opt-in VIP detection (CARP/tunnel/loopback) with IP roles - #409
Open
eric-eisenhart wants to merge 2 commits into
Open
feat(network): opt-in VIP detection (CARP/tunnel/loopback) with IP roles#409eric-eisenhart wants to merge 2 commits into
eric-eisenhart wants to merge 2 commits into
Conversation
Network.scan() read interface facts exclusively from Linux sysfs (/sys/class/net), so it could not run on *BSD. Abstract the OS-specific bits behind small helpers that use sysfs when present and fall back to parsing `ifconfig -a` otherwise: - Add netbox_agent/ifconfig.py: parse `ifconfig -a` for per-interface MAC and MTU (the facts scan() reads from /sys on Linux). - scan() enumerates interfaces and reads MAC/MTU/bonding/virtual via _use_sysfs()-guarded helpers; the Linux path is behaviorally unchanged. - ethtool is already skipped when the binary is absent, so *BSD NICs get ethtool=None (interface type falls back to Other), which downstream already handles. - Guard the MTU update so a missing (None) MTU never clears a known one. - Add a fixture + test parsing real FreeBSD `ifconfig` output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Detect virtual IPs from runtime signals and set the matching NetBox IP role
so hosts sharing a VIP each keep their own record instead of stealing it.
Three independent detectors, each opt-in via config and all default off, so
default behavior is unchanged:
- network.vip_carp: CARP VIPs (addresses carrying a vhid in ifconfig, *BSD)
-> CARP role. Ifconfig now also collects carp_addresses.
- network.vip_tunnel: a /32 or /128 on an IP-tunnel interface (IPIP/IP6IP6/
SIT/GRE, via the /sys ARPHRD type) -> VIP role (e.g. LVS-TUN real servers).
- network.vip_loopback: non-localhost addresses on a loopback interface -> VIP.
vip_roles() aggregates them to {address: role}. In
create_or_update_netbox_ip_on_interface a detected role is set when the IP is
created/adopted, and the multi-assignable branch now handles any such role,
not just Anycast.
Also fix that branch to use assigned_object_id instead of the `.interface`
attribute removed from the NetBox API, so Anycast handling works again. With
all detectors off, behavior is identical to before apart from that fix.
Adds the config options + example, and extends the ifconfig test to cover
CARP address extraction.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
eric-eisenhart
force-pushed
the
feat/vip-detection
branch
from
August 4, 2026 18:39
ed28481 to
c70cb52
Compare
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.
This is additional feature after #408 -- if you like that one and merge it, this should show just the features to detect VIPs.
Detect virtual IPs from runtime signals and set the matching NetBox IP role
so hosts sharing a VIP each keep their own record instead of stealing it.
Three independent detectors, each opt-in via config and all default off, so
default behavior is unchanged:
-> CARP role. Ifconfig now also collects carp_addresses.
SIT/GRE, via the /sys ARPHRD type) -> VIP role (e.g. LVS-TUN real servers).
vip_roles() aggregates them to {address: role}. In
create_or_update_netbox_ip_on_interface a detected role is set when the IP is
created/adopted, and the multi-assignable branch now handles any such role,
not just Anycast.
Also fix that branch to use assigned_object_id instead of the
.interfaceattribute removed from the NetBox API, so Anycast handling works again. With
all detectors off, behavior is identical to before apart from that fix.
Adds the config options + example, and extends the ifconfig test to cover
CARP address extraction.