X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bin%2Fundeploy-nonrtric;h=be6dff7e101afdfe1e8c48de7aae1c3d765c5749;hb=ff0523096e0bf2443e0f5aaf511e08f5b10bb6e5;hp=2a6c3fd45e0253b19bcc8c167bbd213351001a71;hpb=7e09001c5b58dab96d014fe3f9c41f89b53f3cc3;p=it%2Fdep.git diff --git a/bin/undeploy-nonrtric b/bin/undeploy-nonrtric index 2a6c3fd4..be6dff7e 100755 --- a/bin/undeploy-nonrtric +++ b/bin/undeploy-nonrtric @@ -17,5 +17,40 @@ # This script to undeploy the NONRTRIC -ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -$ROOT_DIR/../nonrtric/bin/uninstall + +COMPONENTS="controlpanel a1controller a1simulator policymanagementservice informationservice rappcatalogueservice nonrtricgateway dmaapadapterservice dmaapmediatorservice helmmanager orufhrecovery ransliceassurance" +RECIPE_NAMESPACE=$(kubectl get cm --all-namespaces | grep nonrtric-recipe | awk '{print $1}') +kubectl get configmap -n $RECIPE_NAMESPACE nonrtric-recipe -o jsonpath='{.data.recipe}' > /tmp/recipe.yaml + +if [ ! -s /tmp/recipe.yaml ]; then + echo "NONRTRIC recipe is not found. Are you sure it's deployed successfully?" + exit 0 +fi + +COMMON_BLOCK=$(cat /tmp/recipe.yaml | awk '/^common:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}') +NAMESPACE_BLOCK=$(cat /tmp/recipe.yaml | awk '/^ namespace:/{getline; while ($0 ~ /^ .*|^ *$/) {print $0; if (getline == 0) {break}}}') +NONRTRIC_NAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *nonrtric:/{print $2}') +RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}') +INSTALL_KONG=$(cat /tmp/recipe.yaml | awk '/^ installKong:/{print $2}') + +if [ "$INSTALL_KONG" = true ];then + echo "Uninstalling Kong" + helm delete kong-nonrtric --namespace kong +fi + +echo "Undeploying NONRTRIC components [$COMPONENTS]" + +IS_HELM3=$(helm version -c --short|grep -e "^v3") +HELM_FLAG='' +if [ $IS_HELM3 ] +then + HELM_FLAG=' -n '${NONRTRIC_NAMESPACE:-nonrtric} +else + HELM_FLAG='--purge' +fi + +helm delete ${HELM_FLAG} ${RELEASE_PREFIX} + +kubectl delete cm -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe + +kubectl delete ns ${NONRTRIC_NAMESPACE:-nonrtric}