]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Common: Rewrite check_pgs 1584/head
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 5 Jun 2017 09:21:32 +0000 (11:21 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 12 Jun 2017 08:59:16 +0000 (10:59 +0200)
Rewrite the check_pgs by using json parsing instead of complex regexp to
parse the `ceph -s` output.

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
roles/ceph-common/templates/restart_osd_daemon.sh.j2

index 05e3ef9ce2a5c9028613dc8b9c5fbab3cb5b41dc..5d1d04597b52a9de9eeae84855f5ea949c314ed4 100644 (file)
@@ -6,7 +6,7 @@ CEPH_CLI="--name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/{{ c
 
 check_pgs() {
   while [ $RETRIES -ne 0 ]; do
-    test "$(ceph $CEPH_CLI -s | grep pgmap | sed -r 's/.*: ([0-9]+) pgs.*/\1/g')" -eq "$(ceph $CEPH_CLI -s | egrep '\sactive\+clean' | sed -r 's/[^0-9]*//g')" && ceph $CEPH_CLI health | egrep -sq "HEALTH_OK|HEALTH_WARN"
+    test "[""$(ceph $CEPH_CLI -s -f json | python -c 'import sys, json; print(json.load(sys.stdin)["pgmap"]["num_pgs"])')""]" == "$(ceph $CEPH_CLI -s -f json | python -c 'import sys, json; print [ i["count"] for i in json.load(sys.stdin)["pgmap"]["pgs_by_state"] if i["state_name"] == "active+clean"]')"
     RET=$?
     test $RET -eq 0 && exit 0
     sleep $DELAY