blob: 693c913ce6060d4b78421164b99e141acf4444c6 [file] [log] [blame]
Oleksandr Savatieiev91355c82018-09-07 12:14:34 +02001#!/bin/bash
2export OS_INTERFACE='admin'
Ievgeniia Zadorozhna6d6cb292022-01-11 17:26:48 +03003mask='rally_\|tempest_\|tempest-\|spt-'
Oleksandr Savatieiev91355c82018-09-07 12:14:34 +02004
5echo "Starting. Using mask '$mask'"
6
7echo "Delete users"
8for i in `openstack user list | grep $mask | awk '{print $2}'`; do openstack user delete $i; echo deleted $i; done
9
10echo "Delete roles"
11for i in `openstack role list | grep $mask | awk '{print $2}'`; do openstack role delete $i; echo deleted $i; done
12
13#echo "Delete projects"
14#for i in `openstack project list | grep $mask | awk '{print $2}'`; do openstack project delete $i; echo deleted $i; done
15
16echo "Delete servers"
17for i in `openstack server list --all | grep $mask | awk '{print $2}'`; do openstack server delete $i; echo deleted $i; done
18
19echo "Reset snapshot state and delete"
20for i in `openstack volume snapshot list --all | grep $mask | awk '{print $2}'`; do openstack snapshot set --state available $i; echo snapshot reset state is done for $i; done
21for i in `openstack volume snapshot list --all | grep $mask | awk '{print $2}'`; do openstack snapshot set --state available $i; echo deleted $i; done
22
23echo "Reset volume state and delete"
24for i in `openstack volume list --all | grep $mask | awk '{print $2}'`; do openstack volume set --state available $i; echo reset state is done for $i; done
25for i in `openstack volume list --all | grep $mask | awk '{print $2}'`; do openstack volume delete $i; echo deleted $i; done
26
27echo "Delete volume types"
28for i in `openstack volume type list | grep $mask | awk '{print $2}'`; do openstack volume type delete $i; done
29
30echo "Delete images"
31for i in `openstack image list | grep $mask | awk '{print $2}'`; do openstack image delete $i; echo deleted $i; done
32
33echo "Delete sec groups"
34for i in `openstack security group list --all | grep $mask | awk '{print $2}'`; do openstack security group delete $i; echo deleted $i; done
35
36echo "Delete keypairs"
37for i in `openstack keypair list | grep $mask | awk '{print $2}'`; do openstack keypair delete $i; echo deleted $i; done
38
39echo "Delete ports"
40for i in `openstack port list | grep $mask | awk '{print $2}'`; do openstack port delete $i; done
41
42echo "Delete Router ports (experimental)"
43neutron 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
44
45echo "Delete subnets"
46for i in `openstack subnet list | grep $mask | awk '{print $2}'`; do openstack subnet delete $i; done
47
48echo "Delete nets"
49for i in `openstack network list | grep $mask | awk '{print $2}'`; do openstack network delete $i; done
50
51echo "Delete routers"
52for i in `openstack router list | grep $mask | awk '{print $2}'`; do openstack router delete $i; done
53
54echo "Delete regions"
55for i in `openstack region list | grep $mask | awk '{print $2}'`; do openstack region delete $i; echo deleted $i; done
56
57echo "Delete stacks"
58for i in `openstack stack list | grep $mask | awk '{print $2}'`; do openstack stack check $i; done
59for i in `openstack stack list | grep $mask | awk '{print $2}'`; do openstack stack delete -y $i; echo deleted $i; done
60
61#echo "Delete containers"
62#for i in `openstack container list --all | grep $mask | awk '{print $2}'`; do openstack container delete $i; echo deleted $i; done
63echo "Done"
64
65# It is not recommended to remove projects until you are sure that there are no other leftovers.
66#echo "Delete projects"
67#for i in `openstack project list | grep $mask | awk '{print $2}'`; do openstack project delete $i; echo deleted $i; done