Skip to content

Commit cf64f3c

Browse files
authored
Merge pull request #18444 from netbox-community/18433-fix-macaddress-primary-for-interface
Fixes: #18433 - Fix missing is_primary property on MACAddress model
2 parents 57fa1dd + ee5d7cf commit cf64f3c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

netbox/dcim/models/devices.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,13 @@ def __init__(self, *args, **kwargs):
15311531
self._original_assigned_object_id = self.__dict__.get('assigned_object_id')
15321532
self._original_assigned_object_type_id = self.__dict__.get('assigned_object_type_id')
15331533

1534+
@cached_property
1535+
def is_primary(self):
1536+
if self.assigned_object and hasattr(self.assigned_object, 'primary_mac_address'):
1537+
if self.assigned_object.primary_mac_address and self.assigned_object.primary_mac_address.pk == self.pk:
1538+
return True
1539+
return False
1540+
15341541
def clean(self, *args, **kwargs):
15351542
super().clean()
15361543
if self._original_assigned_object_id and self._original_assigned_object_type_id:

0 commit comments

Comments
 (0)