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