From e8ff5efa3329701580ce5318b6b457f1f4f8346f Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Wed, 29 May 2024 11:04:31 +0200 Subject: [PATCH] Fix ost map nets --- IM/connectors/OpenStack.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 67982cfe..e6a7c962 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -725,12 +725,19 @@ def setIPsFromInstance(self, vm, node): ip_net_map = {} for net_name, ips in node.extra['addresses'].items(): + # Check if the network is private using only IPv4 IP + is_private = None for ipo in ips: ip = ipo['addr'] if IPAddress(ip).version == 4: is_private = any([IPAddress(ip) in IPNetwork(mask) for mask in Config.PRIVATE_NET_MASKS]) - else: - is_private = IPAddress(ip).is_ipv6_unique_local() + if is_private is None: + self.log_warn("Error getting network type for network %s. Asumming public." % net_name) + is_private = False + + # Now map the IPs + for ipo in ips: + ip = ipo['addr'] if 'OS-EXT-IPS:type' in ipo and ipo['OS-EXT-IPS:type'] == 'floating': ip_net_map[ip] = (None, not is_private)