X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Frgw%2Ftest-rgw-common.sh;fp=src%2Fceph%2Fsrc%2Ftest%2Frgw%2Ftest-rgw-common.sh;h=20f2e0da05c9399600171e934c902fccdc1a638d;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/test/rgw/test-rgw-common.sh b/src/ceph/src/test/rgw/test-rgw-common.sh new file mode 100644 index 0000000..20f2e0d --- /dev/null +++ b/src/ceph/src/test/rgw/test-rgw-common.sh @@ -0,0 +1,156 @@ +#!/bin/bash + +rgw_flags="--debug-rgw=20 --debug-ms=1" + +function _assert { + src=$1; shift + lineno=$1; shift + [ "$@" ] || echo "$src: $lineno: assert failed: $@" || exit 1 +} + +assert="eval _assert \$BASH_SOURCE \$LINENO" + +function var_to_python_json_index { + echo "['$1']" | sed "s/\./'\]\['/g" +} + +function json_extract { +var="" +[ "$1" != "" ] && var=$(var_to_python_json_index $1) +shift +python - <&2 + eval "$@" +} + + +script_dir=`dirname $0` +root_path=`(cd $script_dir/../..; pwd)` + +mstart=$root_path/mstart.sh +mstop=$root_path/mstop.sh +mrun=$root_path/mrun +mrgw=$root_path/mrgw.sh + +function start_ceph_cluster { + [ $# -ne 1 ] && echo "start_ceph_cluster() needs 1 param" && exit 1 + + echo "$mstart $1" +} + +function rgw_admin { + [ $# -lt 1 ] && echo "rgw_admin() needs 1 param" && exit 1 + + echo "$mrun $1 radosgw-admin" +} + +function rgw { + [ $# -ne 2 ] && echo "rgw() needs 2 params" && exit 1 + + echo "$mrgw $1 $2 $rgw_flags" +} + +function init_first_zone { + [ $# -ne 7 ] && echo "init_first_zone() needs 7 params" && exit 1 + + cid=$1 + realm=$2 + zg=$3 + zone=$4 + endpoints=$5 + + access_key=$6 + secret=$7 + +# initialize realm + x $(rgw_admin $cid) realm create --rgw-realm=$realm + +# create zonegroup, zone + x $(rgw_admin $cid) zonegroup create --rgw-zonegroup=$zg --master --default + x $(rgw_admin $cid) zone create --rgw-zonegroup=$zg --rgw-zone=$zone --access-key=${access_key} --secret=${secret} --endpoints=$endpoints --default + x $(rgw_admin $cid) user create --uid=zone.user --display-name="Zone User" --access-key=${access_key} --secret=${secret} --system + + x $(rgw_admin $cid) period update --commit +} + +function init_zone_in_existing_zg { + [ $# -ne 8 ] && echo "init_zone_in_existing_zg() needs 8 params" && exit 1 + + cid=$1 + realm=$2 + zg=$3 + zone=$4 + master_zg_zone1_port=$5 + endpoints=$6 + + access_key=$7 + secret=$8 + + x $(rgw_admin $cid) realm pull --url=http://localhost:$master_zg_zone1_port --access-key=${access_key} --secret=${secret} --default + x $(rgw_admin $cid) zonegroup default --rgw-zonegroup=$zg + x $(rgw_admin $cid) zone create --rgw-zonegroup=$zg --rgw-zone=$zone --access-key=${access_key} --secret=${secret} --endpoints=$endpoints + x $(rgw_admin $cid) period update --commit --url=http://localhost:$master_zg_zone1_port --access-key=${access_key} --secret=${secret} +} + +function init_first_zone_in_slave_zg { + [ $# -ne 8 ] && echo "init_first_zone_in_slave_zg() needs 8 params" && exit 1 + + cid=$1 + realm=$2 + zg=$3 + zone=$4 + master_zg_zone1_port=$5 + endpoints=$6 + + access_key=$7 + secret=$8 + +# create zonegroup, zone + x $(rgw_admin $cid) realm pull --url=http://localhost:$master_zg_zone1_port --access-key=${access_key} --secret=${secret} + x $(rgw_admin $cid) realm default --rgw-realm=$realm + x $(rgw_admin $cid) zonegroup create --rgw-realm=$realm --rgw-zonegroup=$zg --endpoints=$endpoints --default + x $(rgw_admin $cid) zonegroup default --rgw-zonegroup=$zg + + x $(rgw_admin $cid) zone create --rgw-zonegroup=$zg --rgw-zone=$zone --access-key=${access_key} --secret=${secret} --endpoints=$endpoints + x $(rgw_admin $cid) zone default --rgw-zone=$zone + x $(rgw_admin $cid) zonegroup add --rgw-zonegroup=$zg --rgw-zone=$zone + + x $(rgw_admin $cid) user create --uid=zone.user --display-name="Zone User" --access-key=${access_key} --secret=${secret} --system + x $(rgw_admin $cid) period update --commit --url=localhost:$master_zg_zone1_port --access-key=${access_key} --secret=${secret} + +} + +function call_rgw_admin { + cid=$1 + shift 1 + x $(rgw_admin $cid) "$@" +}