From d526dada19a291932dd2c235fc2c40f0422ccdd7 Mon Sep 17 00:00:00 2001 From: "Zhang Rong(Jon)" Date: Fri, 14 Jun 2024 14:57:36 +0800 Subject: [PATCH] Fix install O2 on subcloud failed The O2 application installation on a subcloud will fail because the default region name is "RegionOne," while the subcloud has a different region name. This commit adds an environment variable that allows the user to set the region name, replacing the default one. Test Cases: 1. Successfully installed the O2 application on the subcloud. 2. Successfully installed the O2 application on the central cloud. Issue-ID: INF-467 Change-Id: I893680b8c2519667b1784b751950ea8a3f14cbce Signed-off-by: Zhang Rong(Jon) --- charts/templates/deployment.yaml | 2 ++ charts/values.yaml | 1 + o2common/config/config.py | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/charts/templates/deployment.yaml b/charts/templates/deployment.yaml index 19d74318..a1596e31 100644 --- a/charts/templates/deployment.yaml +++ b/charts/templates/deployment.yaml @@ -122,6 +122,8 @@ spec: value: {{ .Values.ocloud.OS_PASSWORD }} - name: OS_USERNAME value: {{ .Values.ocloud.OS_USERNAME }} + - name: OS_REGION_NAME + value: {{ .Values.ocloud.OS_REGION_NAME }} - name: PYTHONDONTWRITEBYTECODE value: "1" - name: REDIS_HOST diff --git a/charts/values.yaml b/charts/values.yaml index 83629c4f..ee88d9c3 100644 --- a/charts/values.yaml +++ b/charts/values.yaml @@ -77,6 +77,7 @@ ocloud: OS_AUTH_URL: "" OS_USERNAME: "" OS_PASSWORD: "" + OS_REGION_NAME: "RegionOne" K8S_KUBECONFIG: "" API_HOST_EXTERNAL_FLOATING: "" HELM_USER_PASSWD: "St8rlingX*" diff --git a/o2common/config/config.py b/o2common/config/config.py index f8eee94b..2ad1da36 100644 --- a/o2common/config/config.py +++ b/o2common/config/config.py @@ -63,6 +63,11 @@ def get_api_url(): return f"https://{host}:{port}" +def get_region_name(): + region_name = os.environ.get("OS_REGION_NAME", "RegionOne") + return region_name + + def get_stx_url(): try: return get_stx_client_args()["auth_url"] @@ -150,7 +155,8 @@ def is_ipv6(address): return False -def get_stx_access_info(region_name="RegionOne", subcloud_hostname: str = "", +def get_stx_access_info(region_name=get_region_name(), + subcloud_hostname: str = "", sub_is_https: bool = False): try: client_args = get_stx_client_args()