Browse Source

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

Jeremy Stretch 2 năm trước cách đây
mục cha
commit
06f2c6f867
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      netbox/ipam/models/ip.py

+ 3 - 3
netbox/ipam/models/ip.py

@@ -892,7 +892,7 @@ class IPAddress(PrimaryModel):
     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)
             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 True
         return False
         return False
 
 
@@ -900,9 +900,9 @@ class IPAddress(PrimaryModel):
     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)
             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
                 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 True
         return False
         return False