blob: 9b742e8fd11a11d56df0d6993e1039c517211d6e [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 Wuf19734c2018-01-19 14:39:34 -080014# delete all Desigate DNS zones
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
17 openstack zone delete $ZONE
18done
19
Gary Wucc10f1c2018-01-03 11:19:28 -080020# delete all instances
21openstack server delete $(openstack server list -c ID -f value)
22sleep 1
23
24# miscellaneous cleanup
25openstack floating ip delete $(openstack floating ip list -c ID -f value)
26sleep 1
27
28ROUTERS=$(openstack router list -c ID -f value)
29echo $ROUTERS
30for ROUTER in $ROUTERS; do
31 echo $ZONENAME;
32 PORTS=$(openstack router show $ROUTER -c "interfaces_info" -f "value" | jq -r '.[].port_id')
33 for PORT in $PORTS; do
34 openstack router remove port $ROUTER $PORT
35 done
36 openstack router delete $ROUTER
37done
38
39openstack port delete $(openstack port list -f value -c ID)
40openstack volume delete $(openstack volume list -f value -c ID)
41
42# delete all except "default" security group
Gary Wuedcb04b2018-02-06 21:39:05 -080043SECURITY_GROUPS=$(openstack security group list -c ID -f value | grep -v default)
Gary Wucc10f1c2018-01-03 11:19:28 -080044openstack security group delete $SECURITY_GROUPS
45sleep 1
46
47
48# Delete all existing stacks
49STACKS=$(openstack stack list -c "Stack Name" -f value)
50
51if [ ! -z "${STACKS}" ]; then
Gary Wucc10f1c2018-01-03 11:19:28 -080052 openstack stack delete -y $STACKS
53 for STACK in ${STACKS}; do
54 until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
55 sleep 2
56 done
57 done
58else
59 echo "No existing stacks to delete."
60fi