misc/e2fsprogs-libuuid \
misc/getopt \
textproc/expat2 \
+ textproc/gsed \
textproc/libxml2 \
textproc/xmlstarlet \
textproc/jq \
echo "Missing xmlstarlet binary!"
exit 1
fi
+if [ `uname` = FreeBSD ]; then
+ SED=gsed
+else
+ SED=sed
+fi
#! @file ceph-helpers.sh
# @brief Toolbox to manage Ceph cluster dedicated to testing
#
ceph osd getcrushmap > $dir/map || return 1
crushtool -d $dir/map -o $dir/map.txt || return 1
- sed -i \
+ ${SED} -i \
-e '/device 0 osd.0/s/$/ class ssd/' \
-e '/step take default/s/$/ class ssd/' \
$dir/map.txt || return 1
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
CEPH_ARGS+="--mon-host=$CEPH_MON "
- local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+ local funcs=${@:-$(set | ${SED} -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
for func in $funcs ; do
setup $dir || return 1
$func $dir || return 1
ceph osd getcrushmap -o $dir/original_map
crushtool -d $dir/original_map -o $dir/decoded_original_map
#manipulate the rulesets , to make the rule_id != ruleset_id
- sed -i 's/ruleset 0/ruleset 3/' $dir/decoded_original_map
- sed -i 's/ruleset 2/ruleset 0/' $dir/decoded_original_map
- sed -i 's/ruleset 1/ruleset 2/' $dir/decoded_original_map
+ ${SED} -i 's/ruleset 0/ruleset 3/' $dir/decoded_original_map
+ ${SED} -i 's/ruleset 2/ruleset 0/' $dir/decoded_original_map
+ ${SED} -i 's/ruleset 1/ruleset 2/' $dir/decoded_original_map
crushtool -c $dir/decoded_original_map -o $dir/new_map
ceph osd setcrushmap -i $dir/new_map
CEPH_ARGS+="--fsid=$(uuidgen) --auth-supported=none "
CEPH_ARGS+="--mon-host=$CEPH_MON "
- local funcs=${@:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+ local funcs=${@:-$(set | ${SED} -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
for func in $funcs ; do
$func $dir || return 1
done
ceph osd getcrushmap -o "$dir/map1" || return 1
crushtool -d "$dir/map1" -o "$dir/map1.txt"|| return 1
- local var=`ceph osd crush dump|grep -w id|grep '-'|grep -Eo '[0-9]+'|sort|uniq|sed -n '$p'`
+ local var=`ceph osd crush dump|grep -w id|grep '-'|grep -Eo '[0-9]+'|sort|uniq|${SED} -n '$p'`
local id=`expr $var + 1`
- local item=`sed -n '/^root/,/}/p' $dir/map1.txt|grep 'item'|head -1`
- local weight=`sed -n '/^root/,/}/p' $dir/map1.txt|grep 'item'|head -1|awk '{print $4}'`
+ local item=`${SED} -n '/^root/,/}/p' $dir/map1.txt|grep 'item'|head -1`
+ local weight=`${SED} -n '/^root/,/}/p' $dir/map1.txt|grep 'item'|head -1|awk '{print $4}'`
local bucket="host test {\n id -$id\n # weight $weight\n alg straw \n hash 0 # rjenkins1 \n $item\n}\n"
- sed -i "/# buckets/a\ $bucket" "$dir/map1.txt"
+ ${SED} -i "/# buckets/a\ $bucket" "$dir/map1.txt"
crushtool -c "$dir/map1.txt" -o "$dir/map1.bin" 2>"$dir/rev"
local result=$(cat "$dir/rev")
if [ "$result" != "" ];