################################################################################
-COMPONENTS="dashboard message-router ves mrsub mc-stack portal aaf"
+COMPONENTS="dashboard message-router ves mrsub mc-stack portal aaf infrastructure"
+RECIPE_NAMESPACE=$(kubectl get cm --all-namespaces | grep aux-recipe | awk '{print $1}')
+kubectl get configmap -n $RECIPE_NAMESPACE aux-recipe -o jsonpath='{.data.recipe}' > /tmp/recipe.yaml
-echo "Undeploying RIC aux components [$COMPONENTS]"
+if [ ! -s /tmp/recipe.yaml ]; then
+ echo "AUX recipe is not found. Are you sure the ric platform is 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}}}')
+AUXNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *aux:/{print $2}')
+INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}')
+RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}')
+echo "Undeploying AUX components [$COMPONENTS]"
-for component in $COMPONENTS; do
- RELEASE_LIST=$(helm list | grep "$component" | awk '{print $1}')
- if [ ! -z "$RELEASE_LIST" ];then
- helm delete --purge $RELEASE_LIST
- fi
+for component in $COMPONENTS; do
+ helm delete --purge ${RELEASE_PREFIX}-$component
done
+
+kubectl delete cm -n ${AUXNAMESPACE:-ricaux} ricaux-recipe
+
+kubectl delete ns ${INFRANAMESPACE:-ricinfra}
+kubectl delete ns ${AUXNAMESPACE:-ricaux}
+kubectl delete ns onap