ctdb-tests: Extend ctdb stub to support "ip" with and without -X
authorMartin Schwenke <martin@meltin.net>
Fri, 27 Feb 2015 04:15:18 +0000 (15:15 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 4 Mar 2015 09:42:26 +0000 (10:42 +0100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/eventscripts/stubs/ctdb

index 5baef4a9ce67cabee615c11159ae4e7af49949fe..7dbb6b41f45ddadf448f4f0a4e70fb2ded7c4351 100755 (executable)
@@ -146,14 +146,18 @@ ctdb_ip ()
     # If nobody has done any IP-fu then generate a layout.
     [ -f "$FAKE_CTDB_IP_LAYOUT" ] || ip_reallocate
 
-    if $verbose ; then
-       echo ":Public IP:Node:ActiveInterface:AvailableInterfaces:ConfiguredInterfaces:"
+    _mypnn=$(ctdb_pnn | sed -e 's@PNN:@@')
+
+    if $machine_readable ; then
+       if $verbose ; then
+           echo "|Public IP|Node|ActiveInterface|AvailableInterfaces|ConfiguredInterfaces|"
+       else
+           echo "|Public IP|Node|"
+       fi
     else
-       echo ":Public IP:Node:"
+       echo "Public IPs on node ${_mypnn}"
     fi
 
-    _mypnn=$(ctdb_pnn | sed -e 's@PNN:@@')
-
     # Join public addresses file with $FAKE_CTDB_IP_LAYOUT, and
     # process output line by line...
     _pa="${CTDB_PUBLIC_ADDRESSES:-${CTDB_BASE}/public_addresses}"
@@ -167,9 +171,17 @@ ctdb_ip ()
            if [ "$_pnn" = "$_mypnn" ]; then
                _my_iface="$_first_iface"
            fi
-           echo "|${_ip}|${_pnn}|${_my_iface}|${_first_iface}|${_ifaces}|"
+           if $machine_readable ; then
+               echo "|${_ip}|${_pnn}|${_my_iface}|${_first_iface}|${_ifaces}|"
+           else
+               echo "${_ip} node[${_pnn}] active[${_my_iface}] available[${_first_iface}] configured[[${_ifaces}]"
+           fi
        else
-           echo "|${_ip}|${_pnn}|"
+           if $machine_readable ; then
+               echo "|${_ip}|${_pnn}|"
+           else
+               echo "${_ip} ${_pnn}"
+           fi
        fi
     done
 }
@@ -469,7 +481,7 @@ case "$1" in
        exit 0
        ;;
     scriptstatus)
-       $machine_readable || not_implemented "$1, without -Y"
+       $machine_readable || not_implemented "$1, without -X"
        [ "$2" != "all" ] || not_implemented "scriptstatus all"
        # For now just assume everything is good.
        echo "|Type|Name|Code|Status|Start|End|Error Output...|"