WIP: fixes last commit #91

This commit is contained in:
Ricardo Bartels
2021-09-17 19:31:49 +02:00
parent 716ee29446
commit 60dfd8ad13
2 changed files with 7 additions and 4 deletions

View File

@@ -441,18 +441,18 @@ def add_ip_address(source_handler, nic_ip, nic_object, site):
else:
log_text = f"No matching NetBox prefix for '{ip_object}' found"
if isinstance(ip_object, (IPv6Address, IPv4Address)):
if type(ip_object) in [IPv6Address, IPv4Address]:
log.warning(f"{log_text}. Unable to add IP address to NetBox.")
return None
else:
log.debug2(log_text)
if matching_ip_prefix is not None and isinstance(ip_object, (IPv6Address, IPv4Address)):
if matching_ip_prefix is not None and type(ip_object) in [IPv6Address, IPv4Address]:
this_prefix = grab(matching_ip_prefix, "data.prefix")
if isinstance(this_prefix, (IPv4Network, IPv6Network)):
if type(ip_object) in [IPv4Network, IPv6Network]:
ip_object = ip_interface(f"{ip_object}/{this_prefix.prefixlen}")
else:
log.warning(f"{this_prefix.name} got wrong format. Unable to add IP to NetBox")
log.warning(f"{matching_ip_prefix.name} got wrong format. Unable to add IP to NetBox")
return None
# try to find matching IP address object

View File

@@ -906,6 +906,9 @@ class VMWareHandler:
ip_object = add_ip_address(self, nic_ip, nic_object, site_name)
if ip_object is None:
continue
# continue if address is not a primary IP
if nic_ip not in [p_ipv4, p_ipv6]:
continue