From: Zhang Rong(Jon) Date: Thu, 20 Jan 2022 08:01:53 +0000 (+0800) Subject: Fix: the IMS and DMS endpoint URL not correct when started in helm chart X-Git-Tag: 2.0.0-rc1~62 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=330e15935177e9d9e8442eb67354f9122f2871b1;p=pti%2Fo2.git Fix: the IMS and DMS endpoint URL not correct when started in helm chart 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) Change-Id: I35f009d3dada3a9f7e0b369637e804a2461e9e6f --- diff --git a/charts/templates/deployment.yaml b/charts/templates/deployment.yaml index bdfe964..7497d9f 100644 --- a/charts/templates/deployment.yaml +++ b/charts/templates/deployment.yaml @@ -83,6 +83,8 @@ spec: image: "{{ .Values.o2ims.image.repository }}:{{ .Values.o2ims.image.tag }}" command: ["/bin/bash", "/opt/o2watcher_start.sh"] env: + - name: API_HOST_EXTERNAL_FLOATING + value: {{ .Values.ocloud.API_HOST_EXTERNAL_FLOATING }} - name: DB_HOST value: postgres - name: DB_PASSWORD diff --git a/charts/values.yaml b/charts/values.yaml index f14a81d..d58033b 100644 --- a/charts/values.yaml +++ b/charts/values.yaml @@ -42,3 +42,4 @@ ocloud: OS_USERNAME: "" OS_PASSWORD: "" K8S_KUBECONFIG: "" + API_HOST_EXTERNAL_FLOATING: "" diff --git a/docker-compose.yml b/docker-compose.yml index 135537e..962d36d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/docs/installation-guide.rst b/docs/installation-guide.rst index 617ec4f..3c92bd3 100644 --- a/docs/installation-guide.rst +++ b/docs/installation-guide.rst @@ -135,6 +135,10 @@ The following instruction should be done outside of INF platform controller host export OS_USERNAME= export OS_PASSWORD= + # 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= + cat <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 diff --git a/o2common/config/config.py b/o2common/config/config.py index 8a869da..b0d3c0f 100644 --- a/o2common/config/config.py +++ b/o2common/config/config.py @@ -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(): diff --git a/o2ims/service/auditor/ocloud_handler.py b/o2ims/service/auditor/ocloud_handler.py index 7548d58..4cc8ec7 100644 --- a/o2ims/service/auditor/ocloud_handler.py +++ b/o2ims/service/auditor/ocloud_handler.py @@ -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,