From 62a478cb5f25c1d879252f195b501e86768a74bc Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 21 May 2017 16:32:59 +0800 Subject: [PATCH] tools/ceph-monstore-update-crush.sh: switch from xmlstarlet to jq Signed-off-by: Kefu Chai --- src/tools/ceph-monstore-update-crush.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/tools/ceph-monstore-update-crush.sh b/src/tools/ceph-monstore-update-crush.sh index 73c6dd0bccf0c..e2fd73cf30210 100755 --- a/src/tools/ceph-monstore-update-crush.sh +++ b/src/tools/ceph-monstore-update-crush.sh @@ -19,12 +19,8 @@ verbose= test -d ../src && export PATH=$PATH:. -if type xmlstarlet > /dev/null 2>&1; then - XMLSTARLET=xmlstarlet -elif type xml > /dev/null 2>&1; then - XMLSTARLET=xml -else - echo "Missing xmlstarlet binary!" +if ! which jq ; then + echo "Missing jq binary!" exit 1 fi @@ -43,8 +39,8 @@ function osdmap_get() { $CEPH_BIN/ceph-monstore-tool $store_path get osdmap -- \ $epoch -o $osdmap > /dev/null || return - echo $($CEPH_BIN/osdmaptool --dump xml $osdmap 2> /dev/null | \ - $XMLSTARLET sel -t -m "$query" -v .) + echo $($CEPH_BIN/osdmaptool --dump json $osdmap 2> /dev/null | \ + jq "$query") rm -f $osdmap } @@ -132,11 +128,11 @@ function main() { # try accessing the store; if it fails, likely means a mon is running local last_osdmap_epoch local max_osd - last_osdmap_epoch=$(osdmap_get $store_path "/osdmap/epoch") || \ + last_osdmap_epoch=$(osdmap_get $store_path ".epoch") || \ die "error accessing mon store at $store_path" # get the max_osd # in last osdmap epoch, crushtool will use it to check # the crush maps in previous osdmaps - max_osd=$(osdmap_get $store_path "/osdmap/max_osd" $last_osdmap_epoch) + max_osd=$(osdmap_get $store_path ".max_osd" $last_osdmap_epoch) local good_crush local good_epoch -- 2.39.5