blob: 9080e20aca14c1457ae011b5eaf0e03e5a281433 [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 Wucc10f1c2018-01-03 11:19:28 -08009# delete all instances
10openstack server delete $(openstack server list -c ID -f value)
11sleep 1
12
13# miscellaneous cleanup
14openstack floating ip delete $(openstack floating ip list -c ID -f value)
15sleep 1
16
17ROUTERS=$(openstack router list -c ID -f value)
18echo $ROUTERS
19for ROUTER in $ROUTERS; do
Gary Wu808b13d2018-02-13 18:28:37 -080020 echo $ROUTER;
Gary Wucc10f1c2018-01-03 11:19:28 -080021 PORTS=$(openstack router show $ROUTER -c "interfaces_info" -f "value" | jq -r '.[].port_id')
22 for PORT in $PORTS; do
Gary Wu13709ea2018-02-15 11:28:50 -080023 openstack router remove port $ROUTER $PORT
Gary Wucc10f1c2018-01-03 11:19:28 -080024 done
25 openstack router delete $ROUTER
26done
27
28openstack port delete $(openstack port list -f value -c ID)
29openstack volume delete $(openstack volume list -f value -c ID)
30
31# delete all except "default" security group
Gary Wuedcb04b2018-02-06 21:39:05 -080032SECURITY_GROUPS=$(openstack security group list -c ID -f value | grep -v default)
Gary Wucc10f1c2018-01-03 11:19:28 -080033openstack security group delete $SECURITY_GROUPS
34sleep 1
35
36
37# Delete all existing stacks
38STACKS=$(openstack stack list -c "Stack Name" -f value)
39
40if [ ! -z "${STACKS}" ]; then
Gary Wucc10f1c2018-01-03 11:19:28 -080041 openstack stack delete -y $STACKS
42 for STACK in ${STACKS}; do
43 until [ "DELETE_IN_PROGRESS" != "$(openstack stack show -c stack_status -f value $STACK)" ]; do
44 sleep 2
45 done
46 done
47else
48 echo "No existing stacks to delete."
49fi