-
Notifications
You must be signed in to change notification settings - Fork 4
/
clean.sh
executable file
·51 lines (44 loc) · 1.36 KB
/
clean.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -x
# Delete the grinder lock file that corresponds to the grinder run about to happen
policy_lock=/tmp/grinder-policy-lock.$(echo $OS_AUTH_URL |sed "s|http://||g" | sed s/:/_/g | sed "s|/|_|g")_
echo "Cleaning up lock file: ${policy_lock}"
rm -f ${policy_lock}
stall=0
for uuid in $(nova list | grep -v 'BLESSED' | tail -n +4 | head -n -1 | awk '{print $2;}'); do
nova delete $uuid
stall=$(($stall+3))
done
sleep $stall
stall=0
for uuid in $(nova list | grep -E '(BLESSED)' | awk '{print $2;}'); do
nova discard $uuid
stall=$(($stall+3))
done
sleep $stall
for uuid in $(nova secgroup-list | grep -i 'created by grinder' | awk '{print $2}'); do
nova secgroup-delete $uuid;
done
stall=0
for disk in $(cinder list | grep 'grindervol-' | awk '{print $2}'); do
cinder delete $disk;
stall=$(($stall+3))
done
sleep $stall
stall=0
for snap in $(cinder snapshot-list | grep 'snapshot for ' | awk '{print $2}'); do
cinder snapshot-delete $snap;
stall=$(($stall+3))
done
sleep $stall
stall=0
for disk in $(cinder list | grep 'grindervol-' | awk '{print $2}'); do
cinder delete $disk;
stall=$(($stall+3))
done
sleep $stall
# Instances in ERROR state that remain after all of the above, are probably failed
# live-image-create entries
for uuid in $(nova list | awk '{print $2}' | grep -v ID); do
echo $uuid; nova discard $uuid;
done