-
Notifications
You must be signed in to change notification settings - Fork 2
/
4-delete.sh
executable file
·62 lines (54 loc) · 1.52 KB
/
4-delete.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
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
TOP_DIR=$(cd $(dirname "$0") && pwd)
pushd $TOP_DIR > /dev/null
pushd "/opt/devstack/" > /dev/null
source openrc admin admin
popd > /dev/null
echo "Sourced openrc"
OS_TOKEN=`curl -i \
-H "Content-Type: application/json" \
-d '
{ "auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": "admin",
"domain": { "id": "default" },
"password": "123456",
"tenantName": "admin"
}
}
},
"scope": {
"project": {
"name": "admin",
"domain": { "id": "default" }
}
}
}
}' \
http://localhost:5000/v3/auth/tokens | grep X-Subject-Token: | sed -e "s/X-Subject-Token: //"`
echo "Got token $OS_TOKEN"
TENANT=`openstack project list | grep " admin" | sed -e "s/ | admin |//" | sed -e "s/| //"` > /dev/null
echo "Got tenant id: $TENANT"
counter=0
for id in `nova list | awk '$2 && $2 != "ID" {print $2}'`
do
curl -i http://localhost:8774/v2.1/$TENANT/servers/$id -X DELETE -H "X-Auth-Project-Id: admin" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: $OS_TOKEN" 1>/dev/null 2>&1 &
echo "Sent request to delete $id"
let counter=counter+1
done
echo "Sent $counter requests"
wait_time=$((counter/20))
for (( c=$wait_time; c>=0; c-- ))
do
echo "Sleep $c seconds for nova list"
sleep 1
done
for file in `ls ./runtime_logs`; do
> "./runtime_logs/$file"
done
echo "Cleared the logs in ./runtime_logs/"
watch -n 5 "nova list"
popd > /dev/null