5 usage() { echo "Usage: $0 [-n <string>] [-r]" 1>&2; exit 1; }
7 while getopts ":rqn:" o; do
11 echo "The following command will delete all information relating to onap within your enviroment"
12 read -p "Are you certain this is what you want? (type y to confirm):" answer
14 if [ $answer = "y" ] || [ $answer = "Y" ] || [ $answer = "yes" ] || [ $answer = "Yes"]; then
15 echo "This may delete the work of other colleages within the same enviroment"
16 read -p "Are you certain this is what you want? (type y to confirm):" answer2
18 if [ $answer2 = "y" ] || [ $answer2 = "Y" ] || [ $answer2 = "yes" ] || [ $answer2 = "Yes"]; then
33 install_name=${OPTARG}
43 if [ -z "$WORKSPACE" ]; then
44 export WORKSPACE=`git rev-parse --show-toplevel`
47 source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
49 if [ "$full_deletion" = true ];then
50 echo "Commencing delete, press CRTL-C to stop"
53 # delete all instances
54 openstack server delete $(openstack server list -c ID -f value)
57 # miscellaneous cleanup
58 openstack floating ip delete $(openstack floating ip list -c ID -f value)
61 ROUTERS=$(openstack router list -c ID -f value)
63 for ROUTER in $ROUTERS; do
65 PORTS=$(openstack router show $ROUTER -c "interfaces_info" -f "value" | jq -r '.[].port_id')
66 for PORT in $PORTS; do
67 openstack router remove port $ROUTER $PORT
69 openstack router delete $ROUTER
72 openstack port delete $(openstack port list -f value -c ID)
73 openstack volume delete $(openstack volume list -f value -c ID)
75 # delete all except "default" security group
76 SECURITY_GROUPS=$(openstack security group list -c ID -f value | grep -v default)
77 openstack security group delete $SECURITY_GROUPS
81 # Delete all existing stacks
82 STACKS=$(openstack stack list -c "Stack Name" -f value)
84 if [ ! -z "${STACKS}" ]; then
85 openstack stack delete -y $STACKS
86 for STACK in ${STACKS}; do
87 until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
92 echo "No existing stacks to delete."
97 echo "Restrained teardown"
101 if [ ! -z "${STACK}" ]; then
102 openstack stack delete $STACK
104 until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
108 echo "No existing stack with the name $install_name."