Fix install O2 on subcloud failed 63/12963/3 j-release master
authorZhang Rong(Jon) <rong.zhang@windriver.com>
Fri, 14 Jun 2024 06:57:36 +0000 (14:57 +0800)
committerZhang Rong(Jon) <rong.zhang@windriver.com>
Thu, 20 Jun 2024 08:07:08 +0000 (16:07 +0800)
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) <rong.zhang@windriver.com>
charts/templates/deployment.yaml
charts/values.yaml
o2common/config/config.py

index 19d7431..a1596e3 100644 (file)
@@ -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
index 83629c4..ee88d9c 100644 (file)
@@ -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*"
index f8eee94..2ad1da3 100644 (file)
@@ -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()