Fix the watcher cannot parse with IPv6
[pti/o2.git] / o2common / config / config.py
index d045315..61c8c69 100644 (file)
@@ -193,9 +193,11 @@ def get_dc_access_info():
     for key, val in client_args.items():
         os_client_args['os_{key}'.format(key=key)] = val
     auth_url = urlparse(os_client_args.pop('os_auth_url'))
+    hostname = f"[{auth_url.hostname}]" if is_ipv6(auth_url.hostname) \
+        else auth_url.hostname
     dcmanager_url = urlparse(_DEFAULT_DCMANAGER_URL)
     dcmanager_url = dcmanager_url._replace(netloc=dcmanager_url.netloc.replace(
-        dcmanager_url.hostname, auth_url.hostname))
+        dcmanager_url.hostname, hostname))
 
     os_client_args['dcmanager_url'] = dcmanager_url.geturl()
     os_client_args['auth_url'] = auth_url.geturl()
@@ -231,6 +233,8 @@ def get_fm_access_info(subcloud_hostname: str = "",
     os_client_args['auth_url'] = auth_url.geturl()
 
     if "" != subcloud_hostname:
+        subcloud_hostname = f"[{subcloud_hostname}]" if \
+            is_ipv6(subcloud_hostname) else subcloud_hostname
         orig_auth_url = urlparse(_DEFAULT_STX_URL)
         new_auth_url = orig_auth_url._replace(
             netloc=orig_auth_url.netloc.replace(