blob: e0d58b66e6034c1e79c456fc5ac78d51854a1054 [file] [log] [blame]
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06001#!/bin/bash
2#mask='rally_'
3#mask='tempest'
4export OS_ENDPOINT_TYPE=internal
5#export OS_ENDPOINT_TYPE='adminURL'
6export OS_INTERFACE='admin'
7#export OS_INSECURE=True
8mask='rally_\|tempest_\|tempest-'
9echo "Starting. Using mask '$mask'"
10echo "Delete users"
11for i in `openstack user list | grep $mask | awk '{print $2}'`; do openstack user delete $i; echo deleted $i; done
12echo "Delete roles"
13for i in `openstack role list | grep $mask | awk '{print $2}'`; do openstack role delete $i; echo deleted $i; done
14echo "Delete servers"
15for i in `openstack server list --all | grep $mask | awk '{print $2}'`; do openstack server delete $i; echo deleted $i; done
16echo "Delete snapshot"
17#[--force]
18for i in `cinder snapshot-list --all | grep $mask | awk '{print $2}'`; do cinder snapshot-reset-state $i; echo snapshot reset state is done for $i; done
19for i in `cinder snapshot-list --all | grep $mask | awk '{print $2}'`; do cinder snapshot-delete $i; echo deleted $i; done
20echo "Delete volumes"
21for i in `openstack volume list --all | grep $mask | awk '{print $2}'`; do cinder reset-state $i --state available; echo reset state is done for $i; done
22for i in `openstack volume list --all | grep $mask | awk '{print $2}'`; do openstack volume delete $i; echo deleted $i; done
23echo "Delete volume types"
24for i in `cinder type-list | grep $mask | awk '{print $2}'`; do cinder type-delete $i; done
25echo "Delete images"
26for i in `openstack image list | grep $mask | awk '{print $2}'`; do openstack image delete $i; echo deleted $i; done
27echo "Delete sec groups"
28for i in `openstack security group list --all | grep $mask | awk '{print $2}'`; do openstack security group delete $i; echo deleted $i; done
29echo "Delete keypairs"
30for i in `openstack keypair list | grep $mask | awk '{print $2}'`; do openstack keypair delete $i; echo deleted $i; done
31echo "Delete ports"
32for i in `neutron port-list --all | grep $mask | awk '{print $2}'`; do neutron port-delete $i; done
33echo "Delete Router ports (experimental)"
34neutron router-list|grep $mask|awk '{print $2}'|while read line; do echo $line; neutron router-port-list $line|grep subnet_id|awk '{print $11}'|sed 's/^\"//;s/\",//'|while read interface; do neutron router-interface-delete $line $interface; done; done
35echo "Delete subnets"
36for i in `neutron subnet-list --all | grep $mask | awk '{print $2}'`; do neutron subnet-delete $i; done
37echo "Delete nets"
38for i in `neutron net-list --all | grep $mask | awk '{print $2}'`; do neutron net-delete $i; done
39echo "Delete routers"
40for i in `neutron router-list --all | grep $mask | awk '{print $2}'`; do neutron router-delete $i; done
41echo "Delete regions"
42for i in `openstack region list | grep $mask | awk '{print $2}'`; do openstack region delete $i; echo deleted $i; done
43echo "Delete stacks"
44for i in `openstack stack list | grep $mask | awk '{print $2}'`; do openstack stack check $i; done
45for i in `openstack stack list | grep $mask | awk '{print $2}'`; do openstack stack delete -y $i; echo deleted $i; done
46#echo "Delete containers"
47#for i in `openstack container list --all | grep $mask | awk '{print $2}'`; do openstack container delete $i; echo deleted $i; done
48echo "Done"
49# It is not recommended to remove projects until you are sure that there are no other leftovers.
50#echo "Delete projects"
51#for i in `openstack project list | grep $mask | awk '{print $2}'`; do openstack project delete $i; echo deleted $i; done