mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 01:06:11 -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
|
@property
|
||||||
def is_oob_ip(self):
|
def is_oob_ip(self):
|
||||||
if self.assigned_object:
|
if self.assigned_object:
|
||||||
|
parent = getattr(self.assigned_object, 'parent_object', None)
|
||||||
if self.family == 4:
|
if self.family == 4:
|
||||||
if self.assigned_object.device.oob_ip4:
|
if parent.oob_ip4:
|
||||||
if self.assigned_object.device.oob_ip4.pk == self.pk:
|
if parent.oob_ip4.pk == self.pk:
|
||||||
return True
|
return True
|
||||||
if self.family == 6:
|
if self.family == 6:
|
||||||
if self.assigned_object.device.oob_ip6:
|
if parent.oob_ip6:
|
||||||
if self.assigned_object.device.oob_ip6.pk == self.pk:
|
if parent.oob_ip6.pk == self.pk:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_primary_ip(self):
|
def is_primary_ip(self):
|
||||||
if self.assigned_object:
|
if self.assigned_object:
|
||||||
|
parent = getattr(self.assigned_object, 'parent_object', None)
|
||||||
if self.family == 4:
|
if self.family == 4:
|
||||||
if self.assigned_object.device.primary_ip4:
|
if parent.primary_ip4:
|
||||||
if self.assigned_object.device.primary_ip4.pk == self.pk:
|
if parent.primary_ip4.pk == self.pk:
|
||||||
return True
|
return True
|
||||||
if self.family == 6:
|
if self.family == 6:
|
||||||
if self.assigned_object.device.primary_ip6:
|
if parent.primary_ip6:
|
||||||
if self.assigned_object.device.primary_ip6.pk == self.pk:
|
if parent.primary_ip6.pk == self.pk:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user