Skip to content

--register doesn't create a impi interface and fails finding it later #395

@phil-flip

Description

@phil-flip

Describe the bug
When running netbox_agent --register it adds most of the stuff. But aborts with

DEBUG:urllib3.connectionpool:https://REDACTED:443 "GET /api/dcim/interfaces/?device_id=105&mgmt_only=True&limit=0 HTTP/1.1" 200 52
Traceback (most recent call last):
  File "/root/.local/bin/netbox_agent", line 7, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.local/pipx/venvs/netbox-agent/lib/python3.11/site-packages/netbox_agent/cli.py", line 63, in main
    return run(config)
           ^^^^^^^^^^^
  File "/root/.local/pipx/venvs/netbox-agent/lib/python3.11/site-packages/netbox_agent/cli.py", line 56, in run
    server.netbox_create_or_update(config)
  File "/root/.local/pipx/venvs/netbox-agent/lib/python3.11/site-packages/netbox_agent/server.py", line 425, in netbox_create_or_update
    self.network.create_or_update_netbox_network_cards()
  File "/root/.local/pipx/venvs/netbox-agent/lib/python3.11/site-packages/netbox_agent/network.py", line 507, in create_or_update_netbox_network_cards
    ret, interface = self.create_or_update_cable(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/pipx/venvs/netbox-agent/lib/python3.11/site-packages/netbox_agent/network.py", line 619, in create_or_update_cable
    nb_mgmt_ip = nb.ipam.ip_addresses.get(interface_id=nb_mgmt_int.id)
                                                       ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'

Because the OS is not aware of the impi mgmt port, so /api/dcim/interfaces/?device_id=105&mgmt_only=True&limit=0 returns no device as there were not created at an earlier step of the script.

Expected behavior
Add the hypervisor-server without any errors and finish linking all the Proxmox network interfaces together.

Configuration file

# Netbox configuration
netbox:
  url: 'https://REDACTED'
  token: REDACTED

# Network configuration
network:
  # Regex to ignore interfaces
  ignore_interfaces: "(dummy.*|docker.*|lo)"
  # Regex to ignore IP addresses
  ignore_ips: (127\.0\.0\..*)
  # enable auto-cabling by parsing LLDP answers
  lldp: true

device:
  server_role: "Server"

tenant:
  driver: "cmd:echo REDACTED"
  regex: "(.*)"

# Enable hypervisor support
virtual:
  # enables references to being a VM - 2025-11-03 REDACTED
  enabled: false
  hypervisor: true
  cluster_name: REDACTED
  list_guests_cmd: qm list | awk 'NR>1 {print $2}'

# Enable datacenter location feature in Netbox
datacenter_location:
  driver: "cmd:echo REDACTED"
  regex: "(.*)"

# Enable local inventory reporting
inventory: true
process_virtual_drives: true
force_disk_refresh: true

Environment:

  • OS: Debian GNU/Linux 12 (bookworm) - Proxmox Virtual Environment 8.0.3
  • NetBox Community v4.4.5-Docker-3.4.1
  • Netbox agent version: no idea where to find that...

Additional context

  • I had a different error before, but that was because the switch didnt have a port marked as a mgmt-port.
  • I was thinking about creating it manually, but it always attempts to remove it. So I was thinking about making a feature request to ignore any items with a certain tag in netbox. But if this is the only crash I am going to encounter, a feature like that might not be necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions