From ad0c72436498c5d2dfd2499638fb0cc9b0ae36b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Tue, 7 Dec 2021 23:37:30 +0100 Subject: [PATCH] Use netaddr when comparing local_ip for changes In undercloud preflight validations the IP address in config is compared to the IP address on the deployed undercloud. For IPv6 the string discovered on the system may be in a different format, representing the same actual IP address and netmask but written using a different valid syntax. Load the existing IP and config IP as a netaddr.IPNetwork, and compare both the networks and IPs to ensure we compare the actuall address and network, not the strings. Closes-Bug: #1953552 Change-Id: I42531b4e6f7b3b18ae085cc2eb36234cb306b375 (cherry picked from commit 02b67f8e63833a783ad83ece6ecdb1f0eb080ed0) --- tripleoclient/v1/undercloud_preflight.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tripleoclient/v1/undercloud_preflight.py b/tripleoclient/v1/undercloud_preflight.py index 36bfb57bd..b20fb03a4 100644 --- a/tripleoclient/v1/undercloud_preflight.py +++ b/tripleoclient/v1/undercloud_preflight.py @@ -314,7 +314,10 @@ def _validate_no_ip_change(): # Nothing to check if br-ctlplane wasn't configured return existing_ip = ctlplane['addresses'][0]['ip_netmask'] - if existing_ip != CONF.local_ip: + conf_netaddr = netaddr.IPNetwork(CONF.local_ip) + existing_netaddr = netaddr.IPNetwork(existing_ip) + if (conf_netaddr != existing_netaddr + or conf_netaddr.ip != existing_netaddr.ip): message = _('Changing the local_ip is not allowed. Existing IP: ' '{0}, Configured IP: {1}').format( existing_ip, CONF.local_ip)