netbox-agent icon indicating copy to clipboard operation
netbox-agent copied to clipboard

Netbox agent fails at adding the mac address on bond interface.

Open licebmi opened this issue 10 months ago • 5 comments

Describe the bug Agent fails when adding a device with a bond interface. I get the following traceback:

DEBUG:urllib3.connectionpool:[https://<netbox_instance>:443](https://<netbox_instance>/) "PATCH /api/dcim/interfaces/852/ HTTP/1.1" 400 112
Traceback (most recent call last):
  File "/opt/netbox-agent/bin/netbox_agent", line 8, in <module>
    sys.exit(main())
  File "/opt/netbox-agent/lib/python3.9/site-packages/netbox_agent/cli.py", line 63, in main
    return run(config)
  File "/opt/netbox-agent/lib/python3.9/site-packages/netbox_agent/cli.py", line 56, in run
    server.netbox_create_or_update(config)
  File "/opt/netbox-agent/lib/python3.9/site-packages/netbox_agent/server.py", line 424, in netbox_create_or_update
    self.network.create_or_update_netbox_network_cards()
  File "/opt/netbox-agent/lib/python3.9/site-packages/netbox_agent/network.py", line 606, in create_or_update_netbox_network_cards
    interface.save()
  File "/opt/netbox-agent/lib/python3.9/site-packages/pynetbox/core/response.py", line 571, in save
    if req.patch(updates):
  File "/opt/netbox-agent/lib/python3.9/site-packages/pynetbox/core/query.py", line 398, in patch
    return self._make_call(verb="patch", data=data)
  File "/opt/netbox-agent/lib/python3.9/site-packages/pynetbox/core/query.py", line 260, in _make_call
    raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'primary_mac_address': ["Multiple objects match the provided attributes: {'mac_address': 'A0:36:9F:BD:0A:6C'}"]}

Expected behavior Netbox agent runs succesfully adding the right mac addresses.

Configuration file Paste here your netbox agent configuration file

Environment:

  • OS: Gentoo
  • Netbox agent version: pip installed version from master branch

Additional context

licebmi avatar Mar 03 '25 08:03 licebmi

Hello @licebmi Can you give me the Netbox version please ? It seems like you're running 4.2 and have created multiple MAC Address objects with the same value.

  • Is this MAC present on multiple interfaces and or devices ?
  • The error should go away if you delete one of the duplicates MAC objects in Netbox

CllaudiaB avatar Mar 04 '25 09:03 CllaudiaB

Having the same issue for bonded interfaces and in cases when IPMI is joined with regular interface (also having the same MAC)

dimm0 avatar Mar 25 '25 04:03 dimm0

I guess the common MAC here is the temporary one ? What settings do you use for network.nic_id and network.primary_mac ?

You shouldn't have issues with nic_id=name and primary_mac=permanent as it would use unique MACs.

On the other hand, if you need temporary MAC addresses with bondings and Netbox server 4.2+, it would require code changes.

ribetm avatar Mar 25 '25 06:03 ribetm

Works fine, please ignore (there was some weirdness from previous versions)

dimm0 avatar Apr 08 '25 00:04 dimm0

I have this problem also but on a vlan-bond interface. If I manually add the mac-address to the second vlan bond (bond.1513) and then run the network intentory it runs ok.

lboclboc avatar Sep 08 '25 14:09 lboclboc