Skip to content

network: resolve primary_mac_address by MAC object id#406

Open
tomatomov wants to merge 1 commit into
Solvik:masterfrom
tomatomov:fix/primary-mac-ambiguous
Open

network: resolve primary_mac_address by MAC object id#406
tomatomov wants to merge 1 commit into
Solvik:masterfrom
tomatomov:fix/primary-mac-ambiguous

Conversation

@tomatomov
Copy link
Copy Markdown

On NetBox 4.2+ MAC addresses are first-class objects and the same MAC string can legitimately exist on multiple interfaces (VLAN/VXLAN stacks inherit the lower device's MAC, bonded slaves share the bond MAC, IPMI sometimes overlaps with a regular NIC, etc.).

Sending primary_mac_address = {"mac_address": "<str>"} makes NetBox resolve the FK by string, which fails as soon as more than one MAC object matches:

400 Bad Request: {'primary_mac_address':
  ["Multiple objects match the provided attributes:
    {'mac_address': 'AE:72:10:EA:FA:60'}"]}

Resolve the MAC object scoped to the current interface (which is always unique) and assign primary_mac_address by its numeric id instead. Fall back to the previous behaviour if the object can't be found.

Fixes: #371

On NetBox 4.2+ MAC addresses are first-class objects and the same MAC
string can legitimately exist on multiple interfaces (VLAN/VXLAN stacks
inherit the lower device's MAC, bonded slaves share the bond MAC, IPMI
sometimes overlaps with a regular NIC, etc.).

Sending `primary_mac_address = {"mac_address": "<str>"}` makes NetBox
resolve the FK by string, which fails as soon as more than one MAC
object matches:

    400 Bad Request: {'primary_mac_address':
      ["Multiple objects match the provided attributes:
        {'mac_address': 'A6:73:11:EE:F7:64'}"]}

Resolve the MAC object scoped to the current interface (which is always
unique) and assign primary_mac_address by its numeric id instead. Fall
back to the previous behaviour if the object can't be found.

Fixes: Solvik#371
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.

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

1 participant