blob: 60bfa638f7ff439815a5a632fd019529a5cf11b2 [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 Wuf19734c2018-01-19 14:39:34 -08009# delete all Proxy Designate DNS records; do this first since we rely on multi-vim for this
Gary Wucc10f1c2018-01-03 11:19:28 -080010$WORKSPACE/test/ete/scripts/dns-zones/delete-dns-zones.sh $OS_PROJECT_NAME
11sleep 1
12
Gary Wuf19734c2018-01-19 14:39:34 -080013# delete all Desigate DNS zones
Gary Wu3c18c542018-01-19 15:10:37 -080014ZONES=$(openstack zone list -c "id" -f value)
Gary Wuf19734c2018-01-19 14:39:34 -080015for ZONE in ${ZONES}; do
16 openstack zone delete $ZONE
17done
18
Gary Wucc10f1c2018-01-03 11:19:28 -080019# delete all instances
20openstack server delete $(openstack server list -c ID -f value)
21sleep 1
22
23# miscellaneous cleanup
24openstack floating ip delete $(openstack floating ip list -c ID -f value)
25sleep 1
26
27ROUTERS=$(openstack router list -c ID -f value)
28echo $ROUTERS
29for ROUTER in $ROUTERS; do
30 echo $ZONENAME;
31 PORTS=$(openstack router show $ROUTER -c "interfaces_info" -f "value" | jq -r '.[].port_id')
32 for PORT in $PORTS; do
33 openstack router remove port $ROUTER $PORT
34 done
35 openstack router delete $ROUTER
36done
37
38openstack port delete $(openstack port list -f value -c ID)
39openstack volume delete $(openstack volume list -f value -c ID)
40
41# delete all except "default" security group
42SECURITY_GROUPS=$(openstack security group list -c Name -f value | grep -v default)
43openstack security group delete $SECURITY_GROUPS
44sleep 1
45
46
47# Delete all existing stacks
48STACKS=$(openstack stack list -c "Stack Name" -f value)
49
50if [ ! -z "${STACKS}" ]; then
Gary Wucc10f1c2018-01-03 11:19:28 -080051 openstack stack delete -y $STACKS
52 for STACK in ${STACKS}; do
53 until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
54 sleep 2
55 done
56 done
57else
58 echo "No existing stacks to delete."
59fi