Scott Baker | 5042166 | 2016-06-27 22:09:48 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | function cleanup_network { |
| 4 | NETWORK=$1 |
| 5 | SUBNETS=`neutron net-show $NETWORK | grep -i subnets | awk '{print $4}'` |
| 6 | if [[ $SUBNETS != "" ]]; then |
| 7 | PORTS=`neutron port-list | grep -i $SUBNETS | awk '{print $2}'` |
| 8 | for PORT in $PORTS; do |
| 9 | echo "Deleting port $PORT" |
| 10 | neutron port-delete $PORT |
| 11 | done |
| 12 | fi |
| 13 | neutron net-delete $NETWORK |
| 14 | } |
| 15 | |
| 16 | source ../setup/admin-openrc.sh |
| 17 | |
| 18 | echo "Deleting VMs" |
| 19 | # Delete all VMs |
| 20 | VMS=$( nova list --all-tenants|grep mysite|awk '{print $2}' ) |
| 21 | for VM in $VMS |
| 22 | do |
| 23 | nova delete $VM |
| 24 | done |
| 25 | |
| 26 | echo "Waiting 5 seconds..." |
| 27 | sleep 5 |
| 28 | |
| 29 | cleanup_network lan_network |
| 30 | cleanup_network wan_network |
| 31 | cleanup_network mysite_vsg-private |
| 32 | cleanup_network mysite_vsg-access |
| 33 | cleanup_network management |
| 34 | |
| 35 | echo "Deleting networks" |
| 36 | # Delete all networks beginning with mysite_ |
| 37 | NETS=$( neutron net-list --all-tenants|grep mysite|awk '{print $2}' ) |
| 38 | for NET in $NETS |
| 39 | do |
| 40 | neutron net-delete $NET |
| 41 | done |
| 42 | |
| 43 | neutron net-delete lan_network || true |
| 44 | neutron net-delete subscriber_network || true |
| 45 | neutron net-delete public_network || true |
| 46 | neutron net-delete hpc_client_network || true |
| 47 | neutron net-delete ceilometer_network || true |
| 48 | neutron net-delete management || true |
| 49 | neutron net-delete mysite_vsg-access || true |