Skip to content

Commit 780282d

Browse files
author
Anatole Denis
committed
Specify interface when assigning primary MAC address
MAC address objects are not necessarily unique in netbox, so when assigning the primary_interface_field match on the parent object to ensure uniqueness (example usecase: when using virtual VLAN interfaces on a physical interface, the children interface may use the same MAC. Then this update fails with an HTTP 400 because there are multiple netbox MAC address objects with the same MAC)
1 parent 123753a commit 780282d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

netbox_agent/network.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,12 @@ def batched(it, n):
551551
if version.parse(nb.version) < version.parse("4.2"):
552552
interface.mac_address = nic["mac"]
553553
else:
554-
interface.primary_mac_address = {"mac_address": nic["mac"]}
554+
interface.primary_mac_address = {
555+
"mac_address": nic["mac"],
556+
"interface": {
557+
"id": interface.id,
558+
},
559+
}
555560
nic_update += 1
556561

557562
if hasattr(interface, "mtu"):

0 commit comments

Comments
 (0)