Skip to content

Commit 758e864

Browse files
committed
ignore reassignment and deletion if IP has role anycast #344
1 parent e798b30 commit 758e864

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

module/netbox/object_classes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,7 @@ def __init__(self, *args, **kwargs):
19021902
"assigned_object_type": ["dcim.interface", "virtualization.vminterface", "ipam.fhrpgroup"],
19031903
"assigned_object_id": [NBInterface, NBVMInterface, NBFHRPGroupItem],
19041904
"description": 200,
1905+
"role": ["loopback", "secondary", "anycast", "vip", "vrrp", "hsrp", "glbp", "carp"],
19051906
"dns_name": 255,
19061907
"tags": NBTagList,
19071908
"tenant": NBTenant,

module/sources/common/source_base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ def add_update_interface(self, interface_object, device_object, interface_data,
499499

500500
this_ip_object = ip
501501

502+
if grab(ip, "data.role.value") == "anycast":
503+
log.debug(f"{ip.name} '{ip.get_display_name()}' is an Anycast address and "
504+
f"can be assigned to multiple interfaces at the same time.")
505+
skip_this_ip = True
506+
break
507+
502508
if current_nic_enabled == this_nic_enabled:
503509

504510
this_log_handler = log.warning
@@ -587,6 +593,11 @@ def add_update_interface(self, interface_object, device_object, interface_data,
587593
if skip_ip_handling is True:
588594
continue
589595

596+
if grab(current_ip, "data.role.value") == "anycast":
597+
log.debug2(f"{ip.name} '{ip.get_display_name()}' is an Anycast address and will "
598+
f"NOT be deleted from interface")
599+
continue
600+
590601
if current_ip not in ip_address_objects:
591602
log.info(f"{current_ip.name} is no longer assigned to {interface_object.get_display_name()} and "
592603
f"therefore removed from this interface")

0 commit comments

Comments
 (0)