ctdb-tools: Simplify "ctdb pnn" output format
authorMartin Schwenke <martin@meltin.net>
Fri, 22 Jul 2016 06:19:23 +0000 (16:19 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 25 Jul 2016 19:29:46 +0000 (21:29 +0200)
Just print the PNN.

Update dependent code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/functions
ctdb/tests/eventscripts/stubs/ctdb
ctdb/tests/scripts/integration.bash
ctdb/tools/ctdb.c
ctdb/tools/onnode

index c9fe207167bc6927266e547e0470fddb59af63a9..a29daf58f6e6889d66cf453211599a6906fe25a4 100755 (executable)
@@ -249,7 +249,7 @@ ctdb_get_pnn ()
 {
     _pnn_file="${CTDB_SCRIPT_VARDIR}/my-pnn"
     if [ ! -f "$_pnn_file" ] ; then
-       $CTDB pnn | sed -e 's@.*:@@' >"$_pnn_file"
+       $CTDB pnn >"$_pnn_file"
     fi
 
     cat "$_pnn_file"
index 4c4278dd5be4915175074fce52c200cc7f721b08..a1cba702105f011fb4a31ba207c7d75196aac8ad 100755 (executable)
@@ -66,8 +66,7 @@ parse_nodespec ()
     elif [ -n "$nodespec" ] ; then
        nodes="$(echo $nodespec | sed -e 's@,@ @g')"
     else
-       _t=$(ctdb_pnn)
-       nodes="${_t#PNN:}"
+       node=$(ctdb_pnn)
     fi
 }
 
@@ -81,7 +80,7 @@ done
 ctdb_pnn ()
 {
     # Defaults to 0
-    echo "PNN:${FAKE_CTDB_PNN:-0}"
+    echo "${FAKE_CTDB_PNN:-0}"
 }
 
 ######################################################################
@@ -139,7 +138,7 @@ ctdb_ip ()
     # If nobody has done any IP-fu then generate a layout.
     [ -f "$FAKE_CTDB_IP_LAYOUT" ] || ip_reallocate
 
-    _mypnn=$(ctdb_pnn | sed -e 's@PNN:@@')
+    _mypnn=$(ctdb_pnn)
 
     if $machine_readable ; then
        if $verbose ; then
index 67f4106adb597af65021cf901ec38f2761274229..12deb7534553cb3507e810e35fc855760374a704 100644 (file)
@@ -231,7 +231,7 @@ get_test_ip_mask_and_iface ()
 
 ctdb_get_all_pnns ()
 {
-    try_command_on_node -q all "$CTDB pnn | sed -e 's@PNN:@@'"
+    try_command_on_node -q all "$CTDB pnn"
     all_pnns="$out"
 }
 
index e65cbf8c783cd2cbf80966614eb7f42d8b3ee13d..917b84d533b8d409a868fdf01231bce6415caec9 100644 (file)
@@ -873,7 +873,7 @@ static int control_pnn(struct ctdb_context *ctdb, int argc, const char **argv)
 
        mypnn = getpnn(ctdb);
 
-       printf("PNN:%d\n", mypnn);
+       printf("%u\n", mypnn);
        return 0;
 }
 
index e7317b75f300cc7bb4a8c61fb37028d3d38a8563..b3efe91c85b5ff179d8403649bd4e68901f99db1 100755 (executable)
@@ -199,9 +199,9 @@ get_any_available_node ()
     # We do a recursive onnode to find which nodes are up and running.
     local out line
     out=$("$0" -pq all ctdb pnn 2>&1)
-    while read line ; do 
-       local pnn="${line#PNN:}"
-       if [ "$pnn" != "$line" ] ; then
+    while read line ; do
+       if [[ "$line" =~ ^[0-9]+$ ]] ; then
+           local pnn="$line"
            # Intentional multi-word expansion
            # shellcheck disable=SC2086
            echo_nth "$pnn" $all_nodes