NONRTRIC-980: Service Manager - SMO deployment
[it/dep.git] / smo-install / scripts / sub-scripts / uninstall-nonrtric.sh
index 6c528e3..ee52b7c 100755 (executable)
@@ -1,12 +1,13 @@
 #!/bin/bash
 
 ###
-# ============LICENSE_START=======================================================
+# ============LICENSE_START========================================================
 # ORAN SMO Package
-# ================================================================================
+# =================================================================================
 # Copyright (C) 2021 AT&T Intellectual Property. All rights
 #                             reserved.
-# ================================================================================
+# Modification Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
+# =================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-# ============LICENSE_END============================================
-# ===================================================================
-# 
+# ============LICENSE_END==========================================================
+# =================================================================================
+#
 ###
 
+if ! jq --version > /dev/null 2>&1 ; then
+    sudo apt-get update
+    sudo apt-get install -y jq
+fi
+
+INSTALL_KONG=$(helm get values oran-nonrtric -n nonrtric -o json | jq '.nonrtric.installKong')
+if [ $? -ne 0 ]; then
+    echo "Failed to parse helm release value installKong with jq."
+    exit 1
+fi
+
+if [ "$INSTALL_KONG" = true ];then
+    echo "Warning - deleting Kong routes and services for ServiceManager."
+    SERVICEMANAGER_POD=$(kubectl get pods -o custom-columns=NAME:.metadata.name -l app.kubernetes.io/name=servicemanager --no-headers -n nonrtric)
+    if [[ -n $SERVICEMANAGER_POD ]]; then
+        kubectl exec $SERVICEMANAGER_POD -n nonrtric -- ./kongclearup
+    else
+        echo "Error - Servicemanager pod not found, didn't delete Kong routes and services for ServiceManager."
+    fi
+fi
+
 kubectl delete namespace nonrtric
 kubectl delete pv nonrtric-pv2
 kubectl delete pv nonrtric-pv1