X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=nonrtric%2Fbin%2Funinstall;fp=nonrtric%2Fbin%2Funinstall;h=23d2fc3fcf4e67089c5dbf4636f72daa0b7808b2;hb=65cb60991d2db2d2a4fafed25ea6c25a2207eb77;hp=0000000000000000000000000000000000000000;hpb=5e10316729da47c17161788a7185a70438506742;p=it%2Fdep.git diff --git a/nonrtric/bin/uninstall b/nonrtric/bin/uninstall new file mode 100755 index 00000000..23d2fc3f --- /dev/null +++ b/nonrtric/bin/uninstall @@ -0,0 +1,54 @@ +#!/bin/bash +################################################################################ +# Copyright (c) 2020 Nordix Foundation. # +# # +# 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 # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# 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. # +################################################################################ + + +COMPONENTS="a1simulator policymanagementservice" +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}') +SIMULATOR_BLOCK=$(cat /tmp/recipe.yaml | awk '/^ simulatorinstance:/{getline; while ($0 ~ /^ +.*|^ *$/) {print $0; if (getline == 0) {break}}}') +SIMULATOR_COUNT=$(echo "$SIMULATOR_BLOCK" | awk '/^ *count:/{print $2}') + +echo "Undeploying NONRTRIC components [$COMPONENTS]" + + +for component in $COMPONENTS; do + case "$component" in + a1simulator) + for((i=1;i<=$SIMULATOR_COUNT;i++)) ; do + echo "Undeploying SIMUALATOR INSTANCE $i" + helm delete --purge ${RELEASE_PREFIX}-$component-$i + done + ;; + *) + helm delete --purge ${RELEASE_PREFIX}-$component + + esac +done + +kubectl delete cm -n ${NONRTRIC_NAMESPACE:-nonrtric} nonrtric-recipe + +kubectl delete ns ${NONRTRIC_NAMESPACE:-nonrtric}