blob: 3a40cfac85b243174654fc2cd36d8f7a38be0a87 [file] [log] [blame]
Gary Wucc10f1c2018-01-03 11:19:28 -08001#!/bin/bash -x
2
3if [ -z "$WORKSPACE" ]; then
4 export WORKSPACE=`git rev-parse --show-toplevel`
5fi
6
7source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh
8
Gary Wuedcb04b2018-02-06 21:39:05 -08009# skip use of multi-vim APIs for now
Gary Wuf19734c2018-01-19 14:39:34 -080010# delete all Proxy Designate DNS records; do this first since we rely on multi-vim for this
Gary Wuedcb04b2018-02-06 21:39:05 -080011# $WORKSPACE/test/ete/scripts/dns-zones/delete-dns-zones.sh $OS_PROJECT_NAME
12# sleep 1
Gary Wucc10f1c2018-01-03 11:19:28 -080013
Gary Wu13709ea2018-02-15 11:28:50 -080014# delete all Desigate DNS zones belonging to this project
Gary Wu3c18c542018-01-19 15:10:37 -080015ZONES=$(openstack zone list -c "id" -f value)
Gary Wuf19734c2018-01-19 14:39:34 -080016for ZONE in ${ZONES}; do
Gary Wu13709ea2018-02-15 11:28:50 -080017 ZONE_PROJECT_ID=$(openstack zone show $ZONE -f json | jq -r '.project_id')
18 if [ "$OS_PROJECT_ID" == "$ZONE_PROJECT_ID" ]; then
19 openstack zone delete $ZONE
20 fi
Gary Wuf19734c2018-01-19 14:39:34 -080021done
22
Gary Wucc10f1c2018-01-03 11:19:28 -080023# delete all instances
24openstack server delete $(openstack server list -c ID -f value)
25sleep 1
26
27# miscellaneous cleanup
28openstack floating ip delete $(openstack floating ip list -c ID -f value)
29sleep 1
30
31ROUTERS=$(openstack router list -c ID -f value)
32echo $ROUTERS
33for ROUTER in $ROUTERS; do
Gary Wu808b13d2018-02-13 18:28:37 -080034 echo $ROUTER;
Gary Wucc10f1c2018-01-03 11:19:28 -080035 PORTS=$(openstack router show $ROUTER -c "interfaces_info" -f "value" | jq -r '.[].port_id')
36 for PORT in $PORTS; do
Gary Wu13709ea2018-02-15 11:28:50 -080037 openstack router remove port $ROUTER $PORT
Gary Wucc10f1c2018-01-03 11:19:28 -080038 done
39 openstack router delete $ROUTER
40done
41
42openstack port delete $(openstack port list -f value -c ID)
43openstack volume delete $(openstack volume list -f value -c ID)
44
45# delete all except "default" security group
Gary Wuedcb04b2018-02-06 21:39:05 -080046SECURITY_GROUPS=$(openstack security group list -c ID -f value | grep -v default)
Gary Wucc10f1c2018-01-03 11:19:28 -080047openstack security group delete $SECURITY_GROUPS
48sleep 1
49
50
51# Delete all existing stacks
52STACKS=$(openstack stack list -c "Stack Name" -f value)
53
54if [ ! -z "${STACKS}" ]; then
Gary Wucc10f1c2018-01-03 11:19:28 -080055 openstack stack delete -y $STACKS
56 for STACK in ${STACKS}; do
57 until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
58 sleep 2
59 done
60 done
61else
62 echo "No existing stacks to delete."
63fi