Fix: the IMS and DMS endpoint URL not correct when started in helm chart 91/7591/2
authorZhang Rong(Jon) <rong.zhang@windriver.com>
Thu, 20 Jan 2022 08:01:53 +0000 (16:01 +0800)
committerZhang Rong(Jon) <rong.zhang@windriver.com>
Thu, 20 Jan 2022 08:05:07 +0000 (16:05 +0800)
1. Add OS environment to specify the k8s service floating IP that makes the IMS and DMS return the correct endpoint

Signed-off-by: Zhang Rong(Jon) <rong.zhang@windriver.com>
Change-Id: I35f009d3dada3a9f7e0b369637e804a2461e9e6f

charts/templates/deployment.yaml
charts/values.yaml
docker-compose.yml
docs/installation-guide.rst
o2common/config/config.py
o2ims/service/auditor/ocloud_handler.py

index bdfe964..7497d9f 100644 (file)
@@ -83,6 +83,8 @@ spec:
           image: "{{ .Values.o2ims.image.repository }}:{{ .Values.o2ims.image.tag }}"\r
           command: ["/bin/bash", "/opt/o2watcher_start.sh"]\r
           env:\r
+            - name: API_HOST_EXTERNAL_FLOATING\r
+              value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }}\r
             - name: DB_HOST\r
               value: postgres\r
             - name: DB_PASSWORD\r
index f14a81d..d58033b 100644 (file)
@@ -42,3 +42,4 @@ ocloud:
   OS_USERNAME: ""
   OS_PASSWORD: ""
   K8S_KUBECONFIG: ""
+  API_HOST_EXTERNAL_FLOATING: ""
index 135537e..962d36d 100644 (file)
@@ -74,6 +74,7 @@ services:
     depends_on:
       - redis_pubsub
     environment:
+      - API_HOST_EXTERNAL_FLOATING=${API_HOST_EXTERNAL_FLOATING}
       - DB_HOST=postgres
       - DB_PASSWORD=o2ims123
       - REDIS_HOST=redis
index 617ec4f..3c92bd3 100644 (file)
@@ -135,6 +135,10 @@ The following instruction should be done outside of INF platform controller host
   export OS_USERNAME=<INF username e.g.: admin>
   export OS_PASSWORD=<INF password for user e.g.: adminpassword>
 
+  # If the external OAM IP same as OS_AUTH_URL's IP address, you can use the below command to set the environment
+  # export API_HOST_EXTERNAL_FLOATING=$(echo ${OS_AUTH_URL/$(echo ${OS_AUTH_URL} | grep :// | sed -e's,^\(.*//\).*,\1,g')} | cut -d/ -f1 | sed -e 's,:.*,,g')
+  export API_HOST_EXTERNAL_FLOATING=<INF external_oam_floating_address e.g.: 128.10.10.10>
+
   cat <<EOF>o2service-override.yaml
   o2ims:
     imagePullSecrets: admin-orano2-registry-secret
@@ -149,6 +153,7 @@ The following instruction should be done outside of INF platform controller host
     OS_USERNAME: "${OS_USERNAME}"
     OS_PASSWORD: "${OS_PASSWORD}"
     K8S_KUBECONFIG: "/opt/k8s_kube.conf"
+    API_HOST_EXTERNAL_FLOATING: "${API_HOST_EXTERNAL_FLOATING}"
   EOF
 
 
index 8a869da..b0d3c0f 100644 (file)
@@ -28,8 +28,15 @@ def get_postgres_uri():
 
 
 def get_api_url():
-    host = os.environ.get("API_HOST", "localhost")
-    port = 5005 if host == "localhost" else 80
+    host_interal = os.environ.get("API_HOST", "localhost")
+    host_external = os.environ.get("API_HOST_EXTERNAL_FLOATING")
+    host = host_interal if host_external is None or host_external == '' \
+        else host_external
+
+    port_internal = 5005 if host == "localhost" else 80
+    port_external = 30205
+    port = port_internal if host_external is None or host_external == '' \
+        else port_external
     return f"http://{host}:{port}"
 
 
@@ -46,7 +53,7 @@ def get_provision_api_base():
 
 
 def get_o2dms_api_base():
-    return get_root_api_base() + "o2dms"
+    return get_root_api_base() + "o2dms/v1"
 
 
 def get_redis_host_and_port():
index 7548d58..4cc8ec7 100644 (file)
@@ -81,7 +81,7 @@ def is_outdated(ocloud: Ocloud, stxobj: StxGenericModel):
 
 
 def create_by(stxobj: StxGenericModel) -> Ocloud:
-    imsendpoint = config.get_api_url() + config.get_o2ims_api_base()
+    imsendpoint = config.get_api_url() + config.get_o2ims_api_base() + '/'
     globalcloudId = stxobj.id  # to be updated
     description = "An ocloud"
     ocloud = Ocloud(stxobj.id, stxobj.name, imsendpoint,