@@ -2150,18 +2150,6 @@ def resolve_relations(self):
21502150 def update (self , data = None , read_from_netbox = False , source = None ):
21512151 object_type = data .get ("assigned_object_type" )
21522152 assigned_object = data .get ("assigned_object_id" )
2153-
2154- # Skip IP assignments when the IP is assigned to FHRP groups when config option
2155- # skip_fhrp_group_ips is set to True, or if the IP is manually assigned to an FHRP group (no source)
2156- if source is not None :
2157- if source .source_type == "vmware" :
2158- config_relation = source .get_object_relation (assigned_object , "skip_fhrp_group_ips" )
2159- if config_relation == True and object_type == "ipam.fhrpgroup" :
2160- log .debug (f"IP address with id '{ assigned_object } ' assigned to FHRP group. Skipping." )
2161- return
2162- elif object_type == "ipam.fhrpgroup" :
2163- log .debug (f"IP address with id '{ assigned_object } ' assigned to FHRP group. It was manually created. Skipping." )
2164- return
21652153
21662154 # used to track changes in object primary IP assignments
21672155 previous_ip_device_vm = None
@@ -2173,6 +2161,19 @@ def update(self, data=None, read_from_netbox=False, source=None):
21732161
21742162 # get current device to make sure to unset primary ip before moving IP address
21752163 previous_ip_device_vm = self .get_device_vm ()
2164+
2165+ # Skip IP assignments when the IP is already assigned to FHRP groups when config option
2166+ # skip_fhrp_group_ips is set to True, or if the IP is manually assigned to an FHRP group (no source)
2167+ if source is not None :
2168+ if source .source_type == "vmware" :
2169+ config_relation = source .get_object_relation (assigned_object , "skip_fhrp_group_ips" )
2170+ if config_relation == True and grab (previous_ip_device_vm , "data.assigned_object_type" ) == "ipam.fhrpgroup" :
2171+ log .debug (f"IP address with id '{ assigned_object } ' assigned to FHRP group. Skipping." )
2172+ return
2173+ elif grab (previous_ip_device_vm , "data.assigned_object_type" ) == "ipam.fhrpgroup" :
2174+ log .debug (f"IP address with id '{ assigned_object } ' assigned to FHRP group. It was manually created. Skipping." )
2175+ return
2176+
21762177 if grab (previous_ip_device_vm , "data.primary_ip4" ) is self :
21772178 is_primary_ipv4_of_previous_device = True
21782179 if grab (previous_ip_device_vm , "data.primary_ip6" ) is self :
@@ -2213,7 +2214,7 @@ def get_interface(self):
22132214 o_id = self .data .get ("assigned_object_id" )
22142215 o_type = self .data .get ("assigned_object_type" )
22152216
2216- if isinstance (o_id , (NBInterface , NBVMInterface )):
2217+ if isinstance (o_id , (NBInterface , NBVMInterface , NBFHRPGroupItem )):
22172218 return o_id
22182219
22192220 if o_type is None or not isinstance (o_id , int ):
@@ -2235,6 +2236,8 @@ def get_device_vm(self):
22352236 return o_interface .data .get ("device" )
22362237 elif isinstance (o_interface , NBVMInterface ):
22372238 return o_interface .data .get ("virtual_machine" )
2239+ elif isinstance (o_interface , NBFHRPGroupItem ):
2240+ return o_interface .data .get ("fhrp_group" )
22382241
22392242 def remove_interface_association (self ):
22402243 o_id = self .data .get ("assigned_object_id" )
0 commit comments