3 rgw_flags="--debug-rgw=20 --debug-ms=1"
8 [ "$@" ] || echo "$src: $lineno: assert failed: $@" || exit 1
11 assert="eval _assert \$BASH_SOURCE \$LINENO"
13 function var_to_python_json_index {
14 echo "['$1']" | sed "s/\./'\]\['/g"
17 function json_extract {
19 [ "$1" != "" ] && var=$(var_to_python_json_index $1)
29 function python_array_len {
36 function project_python_array_field {
37 var=$(var_to_python_json_index $1)
43 s += '"' + str(x$var) + '" '
56 script_dir=`dirname $0`
57 root_path=`(cd $script_dir/../..; pwd)`
59 mstart=$root_path/mstart.sh
60 mstop=$root_path/mstop.sh
62 mrgw=$root_path/mrgw.sh
64 function start_ceph_cluster {
65 [ $# -ne 1 ] && echo "start_ceph_cluster() needs 1 param" && exit 1
71 [ $# -lt 1 ] && echo "rgw_admin() needs 1 param" && exit 1
73 echo "$mrun $1 radosgw-admin"
77 [ $# -ne 2 ] && echo "rgw() needs 2 params" && exit 1
79 echo "$mrgw $1 $2 $rgw_flags"
82 function init_first_zone {
83 [ $# -ne 7 ] && echo "init_first_zone() needs 7 params" && exit 1
95 x $(rgw_admin $cid) realm create --rgw-realm=$realm
97 # create zonegroup, zone
98 x $(rgw_admin $cid) zonegroup create --rgw-zonegroup=$zg --master --default
99 x $(rgw_admin $cid) zone create --rgw-zonegroup=$zg --rgw-zone=$zone --access-key=${access_key} --secret=${secret} --endpoints=$endpoints --default
100 x $(rgw_admin $cid) user create --uid=zone.user --display-name="Zone User" --access-key=${access_key} --secret=${secret} --system
102 x $(rgw_admin $cid) period update --commit
105 function init_zone_in_existing_zg {
106 [ $# -ne 8 ] && echo "init_zone_in_existing_zg() needs 8 params" && exit 1
112 master_zg_zone1_port=$5
118 x $(rgw_admin $cid) realm pull --url=http://localhost:$master_zg_zone1_port --access-key=${access_key} --secret=${secret} --default
119 x $(rgw_admin $cid) zonegroup default --rgw-zonegroup=$zg
120 x $(rgw_admin $cid) zone create --rgw-zonegroup=$zg --rgw-zone=$zone --access-key=${access_key} --secret=${secret} --endpoints=$endpoints
121 x $(rgw_admin $cid) period update --commit --url=http://localhost:$master_zg_zone1_port --access-key=${access_key} --secret=${secret}
124 function init_first_zone_in_slave_zg {
125 [ $# -ne 8 ] && echo "init_first_zone_in_slave_zg() needs 8 params" && exit 1
131 master_zg_zone1_port=$5
137 # create zonegroup, zone
138 x $(rgw_admin $cid) realm pull --url=http://localhost:$master_zg_zone1_port --access-key=${access_key} --secret=${secret}
139 x $(rgw_admin $cid) realm default --rgw-realm=$realm
140 x $(rgw_admin $cid) zonegroup create --rgw-realm=$realm --rgw-zonegroup=$zg --endpoints=$endpoints --default
141 x $(rgw_admin $cid) zonegroup default --rgw-zonegroup=$zg
143 x $(rgw_admin $cid) zone create --rgw-zonegroup=$zg --rgw-zone=$zone --access-key=${access_key} --secret=${secret} --endpoints=$endpoints
144 x $(rgw_admin $cid) zone default --rgw-zone=$zone
145 x $(rgw_admin $cid) zonegroup add --rgw-zonegroup=$zg --rgw-zone=$zone
147 x $(rgw_admin $cid) user create --uid=zone.user --display-name="Zone User" --access-key=${access_key} --secret=${secret} --system
148 x $(rgw_admin $cid) period update --commit --url=localhost:$master_zg_zone1_port --access-key=${access_key} --secret=${secret}
152 function call_rgw_admin {
155 x $(rgw_admin $cid) "$@"