mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -06:00
make is_oob_ip and is_primary_ip generic for other models
This commit is contained in:
parent
9c681e63dc
commit
a3275a9b6b
@ -852,26 +852,28 @@ class IPAddress(PrimaryModel):
|
||||
@property
|
||||
def is_oob_ip(self):
|
||||
if self.assigned_object:
|
||||
parent = getattr(self.assigned_object, 'parent_object', None)
|
||||
if self.family == 4:
|
||||
if self.assigned_object.device.oob_ip4:
|
||||
if self.assigned_object.device.oob_ip4.pk == self.pk:
|
||||
if parent.oob_ip4:
|
||||
if parent.oob_ip4.pk == self.pk:
|
||||
return True
|
||||
if self.family == 6:
|
||||
if self.assigned_object.device.oob_ip6:
|
||||
if self.assigned_object.device.oob_ip6.pk == self.pk:
|
||||
if parent.oob_ip6:
|
||||
if parent.oob_ip6.pk == self.pk:
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def is_primary_ip(self):
|
||||
if self.assigned_object:
|
||||
parent = getattr(self.assigned_object, 'parent_object', None)
|
||||
if self.family == 4:
|
||||
if self.assigned_object.device.primary_ip4:
|
||||
if self.assigned_object.device.primary_ip4.pk == self.pk:
|
||||
if parent.primary_ip4:
|
||||
if parent.primary_ip4.pk == self.pk:
|
||||
return True
|
||||
if self.family == 6:
|
||||
if self.assigned_object.device.primary_ip6:
|
||||
if self.assigned_object.device.primary_ip6.pk == self.pk:
|
||||
if parent.primary_ip6:
|
||||
if parent.primary_ip6.pk == self.pk:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user