blob: 88c2e8f52eaf95b1596376cb782df2ac455995b5 [file] [log] [blame]
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06001#!/bin/bash
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06002export OS_INTERFACE='admin'
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06003mask='rally_\|tempest_\|tempest-'
Oleksii Zhurba0aa46702018-02-07 16:17:39 -06004
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06005echo "Starting. Using mask '$mask'"
Oleksii Zhurba0aa46702018-02-07 16:17:39 -06006
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06007echo "Delete users"
8for i in `openstack user list | grep $mask | awk '{print $2}'`; do openstack user delete $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -06009
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060010echo "Delete roles"
11for i in `openstack role list | grep $mask | awk '{print $2}'`; do openstack role delete $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060012
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060013echo "Delete servers"
14for i in `openstack server list --all | grep $mask | awk '{print $2}'`; do openstack server delete $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060015
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060016echo "Delete snapshot"
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060017for 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
18for i in `cinder snapshot-list --all | grep $mask | awk '{print $2}'`; do cinder snapshot-delete $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060019
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060020echo "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
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060023
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060024echo "Delete volume types"
25for i in `cinder type-list | grep $mask | awk '{print $2}'`; do cinder type-delete $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060026
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060027echo "Delete images"
28for i in `openstack image list | grep $mask | awk '{print $2}'`; do openstack image delete $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060029
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060030echo "Delete sec groups"
31for i in `openstack security group list --all | grep $mask | awk '{print $2}'`; do openstack security group delete $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060032
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060033echo "Delete keypairs"
34for i in `openstack keypair list | grep $mask | awk '{print $2}'`; do openstack keypair delete $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060035
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060036echo "Delete ports"
37for i in `neutron port-list --all | grep $mask | awk '{print $2}'`; do neutron port-delete $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060038
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060039echo "Delete Router ports (experimental)"
40neutron 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
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060041
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060042echo "Delete subnets"
43for i in `neutron subnet-list --all | grep $mask | awk '{print $2}'`; do neutron subnet-delete $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060044
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060045echo "Delete nets"
46for i in `neutron net-list --all | grep $mask | awk '{print $2}'`; do neutron net-delete $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060047
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060048echo "Delete routers"
49for i in `neutron router-list --all | grep $mask | awk '{print $2}'`; do neutron router-delete $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060050
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060051echo "Delete regions"
52for i in `openstack region list | grep $mask | awk '{print $2}'`; do openstack region delete $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060053
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060054echo "Delete stacks"
55for i in `openstack stack list | grep $mask | awk '{print $2}'`; do openstack stack check $i; done
56for i in `openstack stack list | grep $mask | awk '{print $2}'`; do openstack stack delete -y $i; echo deleted $i; done
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060057
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060058#echo "Delete containers"
59#for i in `openstack container list --all | grep $mask | awk '{print $2}'`; do openstack container delete $i; echo deleted $i; done
60echo "Done"
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060061
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060062# It is not recommended to remove projects until you are sure that there are no other leftovers.
63#echo "Delete projects"
64#for i in `openstack project list | grep $mask | awk '{print $2}'`; do openstack project delete $i; echo deleted $i; done