mirror of
https://github.com/bb-Ricardo/netbox-sync.git
synced 2026-05-08 11:00:12 -05:00
Added/changed where the fhrp group ip address updating prevention occured to prevent a duplicate ip address from being created, causing errors.
This commit is contained in:
@@ -2163,18 +2163,6 @@ class NBIPAddress(NetBoxObject):
|
||||
# get current device to make sure to unset primary ip before moving IP address
|
||||
previous_ip_device_vm = self.get_device_vm()
|
||||
|
||||
# Skip IP assignments when the IP is already assigned to FHRP groups when config option
|
||||
# skip_fhrp_group_ips is set to True, or if the IP is manually assigned to an FHRP group (no source)
|
||||
if source is not None:
|
||||
if source.source_type == "vmware":
|
||||
config_relation = source.get_object_relation(assigned_object, "skip_fhrp_group_ips")
|
||||
if config_relation == True and object_type == "ipam.fhrpgroup":
|
||||
log.debug(f"IP address with id '{assigned_object}' assigned to FHRP group. Skipping.")
|
||||
return
|
||||
elif object_type == "ipam.fhrpgroup":
|
||||
log.debug(f"IP address with id '{assigned_object}' assigned to FHRP group. It was manually created. Skipping.")
|
||||
return
|
||||
|
||||
if grab(previous_ip_device_vm, "data.primary_ip4") is self:
|
||||
is_primary_ipv4_of_previous_device = True
|
||||
if grab(previous_ip_device_vm, "data.primary_ip6") is self:
|
||||
|
||||
@@ -443,6 +443,12 @@ class SourceBase:
|
||||
this_ip_object = None
|
||||
skip_this_ip = False
|
||||
for ip in self.inventory.get_all_items(NBIPAddress):
|
||||
# stops fhrp group assigned ip addresses from being overridden and assigned to another object type
|
||||
# if the config skip_fhrp_group_ips is set to True
|
||||
if grab(ip, "data.assigned_object_type", fallback="") == "ipam.fhrpgroup" and self.settings.skip_fhrp_group_ips:
|
||||
log.info(f"Ip address {grab(ip, "data.address")} is assigned to an FHRP Group and skip_fhrp_group_ips is set to {self.settings.skip_fhrp_group_ips}, skipping.")
|
||||
skip_this_ip = True
|
||||
continue
|
||||
|
||||
# check if address matches (without prefix length)
|
||||
ip_address_string = grab(ip, "data.address", fallback="")
|
||||
|
||||
Reference in New Issue
Block a user