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