Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion netbox_agent/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,16 @@ def batched(it, n):
if version.parse(nb.version) < version.parse("4.2"):
interface.mac_address = nic["mac"]
else:
interface.primary_mac_address = {"mac_address": nic["mac"]}
# Resolve the MAC object scoped to THIS interface so the
# lookup is unambiguous when the same MAC string exists on
# multiple interfaces (e.g. vlan/vxlan stacks, bonds, ipmi).
nb_mac_obj = self.nb_net.mac_addresses.get(
interface_id=interface.id, mac_address=nic["mac"]
)
if nb_mac_obj:
interface.primary_mac_address = nb_mac_obj.id
else:
interface.primary_mac_address = {"mac_address": nic["mac"]}
nic_update += 1

if hasattr(interface, "mtu"):
Expand Down