From: vpachchi Date: Wed, 25 Jun 2025 16:45:19 +0000 (-0400) Subject: Unable to pull the DMS and resourcepool information due to invalid URL X-Git-Tag: 2.2.0~1 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=535d3ba9cd66b5b600d66d203b05c43b340f8421;p=pti%2Fo2.git Unable to pull the DMS and resourcepool information due to invalid URL - Fix parse URL issues with the IPV6 - Fix the deprecated link in the docs TestPlan: PASS : Build the container image PASS : Run a container from the image PASS : No log errors regarding the invalid URL Change-Id: I9e28f97b71bf734fbe9052319537c5cc95dd45c2 Signed-off-by: vpachchi --- diff --git a/docs/installation-guide.rst b/docs/installation-guide.rst index c70946f..f5ed29c 100644 --- a/docs/installation-guide.rst +++ b/docs/installation-guide.rst @@ -55,7 +55,7 @@ Backend `__. +Namespaces `__. Set up an OAuth 2.0 server and configure it to use either JWT with Shared Key or Token Introspection. Since the J-release, OAuth2 has diff --git a/o2common/config/config.py b/o2common/config/config.py index 98b0ad9..cac87b8 100644 --- a/o2common/config/config.py +++ b/o2common/config/config.py @@ -85,9 +85,16 @@ def get_dc_manager_url(): if auth_url is None: temp_url = get_stx_url() u = urlparse(temp_url) - u = u._replace(netloc=f"{u.hostname}:{_DCMANAGER_URL_PORT}") - u = u._replace(path=_DCMANAGER_URL_PATH) + hostname = u.hostname # always unbracketed + port = _DCMANAGER_URL_PORT + # Added to Properly handle IPv6 + if is_ipv6(hostname): + netloc = f'[{hostname}]:{port}' + else: + netloc = f'{hostname}:{port}' + u = u._replace(netloc=netloc, path=_DCMANAGER_URL_PATH) auth_url = u.geturl() + logger.info(f"Using default DC Manager URL: {auth_url}") return auth_url @@ -179,9 +186,9 @@ def get_stx_access_info(region_name=get_region_name(), os_client_args['insecure'] = CGTS_INSECURE_SSL if "" != subcloud_hostname: - if is_ipv6(subcloud_hostname): - subcloud_hostname = "[" + subcloud_hostname + "]" orig_auth_url = urlparse(get_stx_url()) + + # If the subcloud_hostname is an IPv6 address, we need to bracket it new_auth_url = orig_auth_url._replace( netloc=orig_auth_url.netloc.replace( orig_auth_url.hostname, subcloud_hostname)) @@ -216,11 +223,8 @@ 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(get_dc_manager_url()) - dcmanager_url = dcmanager_url._replace(netloc=dcmanager_url.netloc.replace( - dcmanager_url.hostname, hostname)) + dcmanager_url = dcmanager_url._replace(netloc=dcmanager_url.netloc) os_client_args['dcmanager_url'] = dcmanager_url.geturl() os_client_args['auth_url'] = auth_url.geturl() @@ -251,8 +255,6 @@ 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(get_stx_url()) new_auth_url = orig_auth_url._replace( netloc=orig_auth_url.netloc.replace( @@ -454,8 +456,11 @@ def get_es_access_info(ip=None): port = os.getenv('ES_PORT', port) path = os.getenv('ES_PATH', path) - # Use provided IP or fallback to environment variable - ip = ip or os.getenv('ES_IP', None) + # To handle IPv6 addresses, we need to bracket them. + if is_ipv6(ip): + ip = f'[{ip}]' or os.getenv('ES_IP', None) + else: + ip = ip or os.getenv('ES_IP', None) # Construct the URL url = f'https://{ip}:{port}{path}'