Skip to content

feat: add use_oob_ip field for vendor-agnostic OOB IP resolution#129

Open
berlikm wants to merge 21 commits into
OpensourceICTSolutions:mainfrom
berlikm:feature/oob-ip-support
Open

feat: add use_oob_ip field for vendor-agnostic OOB IP resolution#129
berlikm wants to merge 21 commits into
OpensourceICTSolutions:mainfrom
berlikm:feature/oob-ip-support

Conversation

@berlikm

@berlikm berlikm commented Jul 16, 2026

Copy link
Copy Markdown

Summary

Add a use_oob_ip boolean field to ZabbixHostInterface that, when enabled, resolves the interface IP from the device's canonical NetBox oob_ip field instead of primary_ip4.

Motivation

Physical servers (Dell, HP, Supermicro) have two independent network interfaces:

  • Management (e.g. ESXi vmk0) — monitored via agent/HTTP on primary_ip4
  • OOB/ BMC (iDRAC, iLO, IPMI) — monitored via SNMP on a separate oob_ip

This patch lets nbxsync automatically create a second SNMP interface on the same Zabbix host, using the OOB IP for hardware-level monitoring (fans, temperature, power supply, disk health).

Design

  • New BooleanField use_oob_ip on ZabbixHostInterface (default False)
  • Migration 0013_zabbixhostinterface_use_oob_ip
  • In HostInterfaceSync.get_create_params(): when use_oob_ip=True and no static IP is set, resolve from instance.oob_ip
  • If the device has no oob_ip: return {} to skip interface creation (no useless empty-IP interfaces in Zabbix)
  • clean() updated to allow no static IP when use_oob_ip is enabled

Why oob_ip over mgmt_only interface matching

  • oob_ip is NetBox's canonical first-class field for OOB management (since NetBox 3.5)
  • Always one value, no ambiguity, no picking logic
  • Vendor-agnostic: works for iDRAC, iLO, BMC, Cisco CIMC, Supermicro IPMI — anything with oob_ip set
  • VMs don't have oob_ip — this feature is device-only by nature

Usage

  1. Import the OOB monitoring template (e.g. Dell iDRAC by SNMP) into Zabbix
  2. Create a ZabbixHostInterface with type=SNMP, use_oob_ip=True, assigned at Manufacturer level (e.g. Dell)
  3. During sync:
    • Devices with oob_ip → SNMP interface created on OOB IP
    • Devices without oob_ip → interface skipped entirely (no noise)
    • Non-matching devices → interface not inherited

Files changed

  • nbxsync/models/zabbixhostinterface.py — new field + clean() validation (2 changed lines)
  • nbxsync/utils/sync/hostinterfacesync.py — 10 lines in get_create_params()
  • nbxsync/migrations/0013_zabbixhostinterface_use_oob_ip.py — new migration

Migration note

On the upstream main branch, the last migration is 0012. This PR adds 0013 — the correct next number. If the upstream has merged other migrations by the time this is reviewed, the number can be adjusted during rebase.

@berlikm
berlikm force-pushed the feature/oob-ip-support branch from 370b65c to b7a54b4 Compare July 16, 2026 14:56
berlikm added 2 commits July 16, 2026 16:00
Add a 'use_oob_ip' boolean field to ZabbixHostInterface that, when
enabled, resolves the interface IP from the device's canonical NetBox
'oob_ip' field instead of primary_ip4.

Design:
- New BooleanField 'use_oob_ip' on ZabbixHostInterface (default False)
- Migration 0013_zabbixhostinterface_use_oob_ip
- In HostInterfaceSync.get_create_params(), when use_oob_ip=True and
  no static IP is set, resolve from instance.oob_ip
- If the device has no oob_ip, return {} to skip interface creation
  (no useless empty-IP interfaces in Zabbix)
- clean() updated to allow no static IP when use_oob_ip is enabled

Why oob_ip over mgmt_only interface matching:
- oob_ip is NetBox's canonical first-class field for OOB management
  (Device.oob_ip, since NetBox 3.5)
- Always one value, no ambiguity, no picking logic
- Vendor-agnostic: works for iDRAC, iLO, BMC, Cisco CIMC, Supermicro IPMI
- VMs don't have oob_ip — feature is device-only by nature

Usage:
1. Create ZabbixHostInterface with type=SNMP, use_oob_ip=True, assigned
   at Manufacturer level (e.g. 'Dell')
2. During sync, Dell servers WITH oob_ip get SNMP interface on OOB IP
3. Dell servers WITHOUT oob_ip skip the interface entirely ({})
4. Non-Dell devices unaffected (interface not inherited)
When a ZabbixHostInterface has use_oob_ip=True but the device being
synced has no oob_ip, the interface type must be excluded from
get_hostinterface_types(). Otherwise, the iDRAC SNMP template
(requirement: SNMP interface type=2) passes the interface check
and gets linked to VMs that have no actual SNMP interface.

Flow:
- VM (no oob_ip) inherits Dell Manufacturer iDRAC interface (use_oob_ip=True)
- get_hostinterface_types() skips it → SNMP type not in list
- get_template_attributes() sees no SNMP → iDRAC template requirement fails
- Template not linked → no conflict with agent template

Dell ESXi host (has oob_ip):
- Interface not skipped → SNMP type in list
- iDRAC template passes check → linked correctly
@berlikm
berlikm force-pushed the feature/oob-ip-support branch from b7a54b4 to ada7bda Compare July 16, 2026 16:01
berlikm added 2 commits July 16, 2026 16:09
When use_oob_ip=True but the device has no oob_ip, get_create_params()
returns {} to signal that the interface should be skipped. Without this
guard, try_create() would call the Zabbix API with no parameters,
causing 'bool object is not subscriptable' errors.
Replace the per-method filtering in get_hostinterface_types() with a
single filter point in sync_host(). After get_assigned_zabbixobjects()
returns, immediately remove any interface with use_oob_ip=True when the
device has no oob_ip.

This fixes all downstream consumers simultaneously:
- get_hostinterface_types() → no SNMP type for VMs → iDRAC template not linked
- get_snmp_macros() → no OOB SNMP credentials pushed
- get_hostinterface_attributes() → no TLS/IPMI from OOB interface
- hostinterface sort loop → no 'IP cannot be empty' errors

3 lines in one place instead of patching 4 methods.
The migration was applied to the DB on the NetBox VM but the .py file
was lost during a git reset (only the .pyc survived in __pycache__).
This caused Django to not recognize the use_oob_ip column, breaking
ORM-based ZabbixHostInterface creation with a NotNullViolation.
berlikm added a commit to berlikm/nbxsync that referenced this pull request Jul 17, 2026
…ng migration fix)

Merges the completed feature/oob-ip-support branch including the
missing 0017 migration. Resolves conflicts in hostinterfacesync.py
(merged oob_ip + primary_ip4 fallback paths) and syncbase.py
(kept early-return-on-empty-params from oob branch + _should_persist
guard from integration-test). Removed duplicate 0013 migration
(kept 0017 which is already applied to the DB).
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.

5 participants