Gary Wu | cc10f1c | 2018-01-03 11:19:28 -0800 | [diff] [blame] | 1 | #!/bin/bash -x |
| 2 | |
| 3 | if [ -z "$WORKSPACE" ]; then |
| 4 | export WORKSPACE=`git rev-parse --show-toplevel` |
| 5 | fi |
| 6 | |
| 7 | source $WORKSPACE/test/ete/scripts/install_openstack_cli.sh |
| 8 | |
Gary Wu | f19734c | 2018-01-19 14:39:34 -0800 | [diff] [blame] | 9 | # delete all Proxy Designate DNS records; do this first since we rely on multi-vim for this |
Gary Wu | cc10f1c | 2018-01-03 11:19:28 -0800 | [diff] [blame] | 10 | $WORKSPACE/test/ete/scripts/dns-zones/delete-dns-zones.sh $OS_PROJECT_NAME |
| 11 | sleep 1 |
| 12 | |
Gary Wu | f19734c | 2018-01-19 14:39:34 -0800 | [diff] [blame] | 13 | # delete all Desigate DNS zones |
Gary Wu | 3c18c54 | 2018-01-19 15:10:37 -0800 | [diff] [blame] | 14 | ZONES=$(openstack zone list -c "id" -f value) |
Gary Wu | f19734c | 2018-01-19 14:39:34 -0800 | [diff] [blame] | 15 | for ZONE in ${ZONES}; do |
| 16 | openstack zone delete $ZONE |
| 17 | done |
| 18 | |
Gary Wu | cc10f1c | 2018-01-03 11:19:28 -0800 | [diff] [blame] | 19 | # delete all instances |
| 20 | openstack server delete $(openstack server list -c ID -f value) |
| 21 | sleep 1 |
| 22 | |
| 23 | # miscellaneous cleanup |
| 24 | openstack floating ip delete $(openstack floating ip list -c ID -f value) |
| 25 | sleep 1 |
| 26 | |
| 27 | ROUTERS=$(openstack router list -c ID -f value) |
| 28 | echo $ROUTERS |
| 29 | for 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 |
| 36 | done |
| 37 | |
| 38 | openstack port delete $(openstack port list -f value -c ID) |
| 39 | openstack volume delete $(openstack volume list -f value -c ID) |
| 40 | |
| 41 | # delete all except "default" security group |
| 42 | SECURITY_GROUPS=$(openstack security group list -c Name -f value | grep -v default) |
| 43 | openstack security group delete $SECURITY_GROUPS |
| 44 | sleep 1 |
| 45 | |
| 46 | |
| 47 | # Delete all existing stacks |
| 48 | STACKS=$(openstack stack list -c "Stack Name" -f value) |
| 49 | |
| 50 | if [ ! -z "${STACKS}" ]; then |
Gary Wu | cc10f1c | 2018-01-03 11:19:28 -0800 | [diff] [blame] | 51 | 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 |
| 57 | else |
| 58 | echo "No existing stacks to delete." |
| 59 | fi |