blob: c0e696c4916d5d3cdb725968300c0c72e45c9181 [file] [log] [blame]
Mandeep Khindad6ea9872017-06-24 11:49:37 -04001#!/bin/bash
Borislav Glozman5197e2e2017-07-24 10:45:28 +03002
3. $(dirname "$0")/setenv.bash
4
Mandeep Khindad6ea9872017-06-24 11:49:37 -04005delete_namespace() {
Borislav Glozman5197e2e2017-07-24 10:45:28 +03006 _NS=$1-$2
7 kubectl delete namespace $_NS
Mandeep Khinda0e8f8892017-08-25 03:31:17 +00008 printf "Waiting for namespace $_NS termination...\n"
9 while kubectl get namespaces $_NS > /dev/null 2>&1; do
10 sleep 2
11 done
Borislav Glozman5197e2e2017-07-24 10:45:28 +030012 printf "Namespace $_NS deleted.\n\n"
13}
14
15delete_registry_key() {
Mandeep Khinda0e8f8892017-08-25 03:31:17 +000016 kubectl --namespace $1-$2 delete secret ${1}-docker-registry-key
Mandeep Khindad6ea9872017-06-24 11:49:37 -040017}
18
kerenj74d723a2017-08-22 15:27:04 +000019delete_app_helm() {
kerenj78eff212017-08-29 09:56:36 +000020 helm delete $1-$2 --purge
kerenj74d723a2017-08-22 15:27:04 +000021}
22
Mandeep Khindad6ea9872017-06-24 11:49:37 -040023usage() {
24 cat <<EOF
25Usage: $0 [PARAMs]
26-u : Display usage
27-n [NAMESPACE] : Kubernetes namespace (required)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040028-a [APP] : Specify a specific ONAP component (default: all)
29 from the following choices:
Dusan Rozman7704d2a2017-09-26 16:04:12 -040030 sdc, aai ,mso, message-router, robot, vid, aaf
31 sdnc, portal, policy, appc, multicloud, clamp, consul, vnfsdk
Mandeep Khindad6ea9872017-06-24 11:49:37 -040032EOF
33}
34
35#MAINs
36NS=
37INCL_SVC=false
38APP=
39
Keren Joseph4b7026e2017-09-12 10:13:15 +030040while getopts ":n:u:s:a:" PARAM; do
Mandeep Khindad6ea9872017-06-24 11:49:37 -040041 case $PARAM in
42 u)
43 usage
44 exit 1
45 ;;
46 n)
47 NS=${OPTARG}
48 ;;
Mandeep Khindad6ea9872017-06-24 11:49:37 -040049 a)
50 APP=${OPTARG}
51 if [[ -z $APP ]]; then
52 usage
53 exit 1
54 fi
55 ;;
56 ?)
57 usage
58 exit
59 ;;
60 esac
61done
62
63if [[ -z $NS ]]; then
64 usage
65 exit 1
66fi
67
68if [[ ! -z "$APP" ]]; then
kerenj80102842017-08-24 13:54:21 +000069 HELM_APPS=($APP)
Mandeep Khindad6ea9872017-06-24 11:49:37 -040070fi
71
72printf "\n********** Cleaning up ONAP: ${ONAP_APPS[*]}\n"
73
Mandeep Khindad6ea9872017-06-24 11:49:37 -040074
kerenj74d723a2017-08-22 15:27:04 +000075for i in ${HELM_APPS[@]}; do
76
kerenj78eff212017-08-29 09:56:36 +000077 delete_app_helm $NS $i
kerenj74d723a2017-08-22 15:27:04 +000078 delete_namespace $NS $i
79
80done
81
Mandeep Khindad6ea9872017-06-24 11:49:37 -040082
83printf "\n********** Gone **********\n"