forked from jharriga/GCrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresetRGW.sh
94 lines (76 loc) · 2.84 KB
/
resetRGW.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# RESETRGW.sh
myPath="${BASH_SOURCE%/*}"
if [[ ! -d "$myPath" ]]; then
myPath="$PWD"
fi
# Variables
source "$myPath/vars.shinc"
#------------------------
# BEGIN FUNCTIONS
function delete_pools {
for pl in ${pool_list[@]}; do
if [ $pl != "rbd" ]; then
ceph osd pool delete $pl $pl --yes-i-really-really-mean-it
fi
done
sleep 5
ceph osd crush rule rm default.rgw.buckets.data
}
function create_pools {
if [ "$1" == "rep" ]; then
cmdtail="replicated"
elif [ "$1" == "ec" ]; then
cmdtail="erasure myprofile"
ceph osd erasure-code-profile rm myprofile
ceph osd erasure-code-profile set myprofile k=$k m=$m
## crush-failure-domain=osd # use default of 'host'
ceph osd crush rule create-erasure default.rgw.buckets.data myprofile
else
echo "unknown value for REPLICATION in create_pools"; exit
fi
for pl in ${pool_list[@]}; do
if [ $pl == "default.rgw.buckets.data" ]; then
ceph osd pool create $pl $pg_data $cmdtail
if [ "$1" == "rep" ]; then
ceph osd pool set $pl size "${numREPLICAS}"
fi
elif [ $pl == "default.rgw.buckets.index" ]; then
ceph osd pool create $pl $pg_index replicated
ceph osd pool set $pl size "${numREPLICAS}"
else
ceph osd pool create $pl $pg replicated
ceph osd pool set $pl size "${numREPLICAS}"
fi
done
# enable RGW on the pools
for pool in $(rados lspools); do
ceph osd pool application enable $pool rgw
done
}
# END FUNCTIONS
#------------------------
echo "$PROGNAME: Running with these values:"
echo "RGWhostname=$RGWhostname r=$REPLICATION k=$k m=$m pgdata=$pg_data pgindex=$pg_index \
pg=$pg f=$fast_read"
echo "Stopping RGWs"
ansible -m shell -a 'systemctl stop ceph-radosgw@rgw.`hostname -s`.service' rgws
echo "Removing existing/old pools"
delete_pools
echo "Creating new pools"
create_pools $REPLICATION
# echo "sleeping for $longPAUSE seconds..."; sleep "${longPAUSE}"
echo "sleeping for 30 seconds..."; sleep 30
echo "Starting RGWs"
ansible -m shell -a 'systemctl start ceph-radosgw@rgw.`hostname -s`.service' rgws
echo "Creating User - which generates a new Password"
ssh $RGWhostname 'radosgw-admin user create --uid=johndoe --display-name="John Doe" [email protected]' &&
ssh $RGWhostname 'radosgw-admin subuser create --uid=johndoe --subuser=johndoe:swift --access=full'
# Edit the Password into the XML workload files
echo "inserting new password into XML files $FILLxml, $EMPTYxml, $RUNTESTxml"
key=$(ssh $RGWhostname 'radosgw-admin user info --uid=johndoe | grep secret_key' | tail -1 | awk '{print $2}' | sed 's/"//g')
sed -i "s/password=.*;/password=$key;/g" ${FILLxml}
sed -i "s/password=.*;/password=$key;/g" ${EMPTYxml}
sed -i "s/password=.*;/password=$key;/g" ${RUNTESTxml}
echo "$PROGNAME: Done"
# DONE