Fixes #13632: Avoid raising exception when checking if FHRP group IP address is primary

This commit is contained in:
Jeremy Stretch 2023-08-31 08:08:10 -04:00
parent 272d2c54d4
commit 06f2c6f867

View File

@ -892,7 +892,7 @@ class IPAddress(PrimaryModel):
def is_oob_ip(self):
if self.assigned_object:
parent = getattr(self.assigned_object, 'parent_object', None)
if hasattr(parent, "oob_ip_id") and parent.oob_ip_id == self.pk:
if hasattr(parent, 'oob_ip') and parent.oob_ip_id == self.pk:
return True
return False
@ -900,9 +900,9 @@ class IPAddress(PrimaryModel):
def is_primary_ip(self):
if self.assigned_object:
parent = getattr(self.assigned_object, 'parent_object', None)
if self.family == 4 and parent.primary_ip4_id == self.pk:
if self.family == 4 and hasattr(parent, 'primary_ip4') and parent.primary_ip4_id == self.pk:
return True
if self.family == 6 and parent.primary_ip6_id == self.pk:
if self.family == 6 and hasattr(parent, 'primary_ip6') and parent.primary_ip6_id == self.pk:
return True
return False