ctdb-scripts: Update eventscripts to use ctdb -X instead of ctdb -Y
authorMartin Schwenke <martin@meltin.net>
Thu, 20 Nov 2014 03:32:46 +0000 (14:32 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 5 Dec 2014 20:02:39 +0000 (21:02 +0100)
Also update associated eventscript unit tests and ctdb stub.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/events.d/10.interface
ctdb/config/events.d/13.per_ip_routing
ctdb/config/events.d/62.cnfs
ctdb/config/events.d/70.iscsi
ctdb/config/functions
ctdb/config/statd-callout
ctdb/tests/eventscripts/scripts/local.sh
ctdb/tests/eventscripts/stubs/ctdb

index 018f767e4447f53f299aa97ecc35ef16f80b1cf1..8207fd3b20db417baecef78fdb7adfd3f391cf0d 100755 (executable)
@@ -46,7 +46,7 @@ get_all_interfaces ()
 
     # Get the interfaces for which CTDB has public IPs configured.
     # That is, for all but the 1st line, get the 1st field.
-    ctdb_ifaces=$(ctdb -Y ifaces | sed -e '1d' -e 's@^:@@' -e 's@:.*@@')
+    ctdb_ifaces=$(ctdb -X ifaces | sed -e '1d' -e 's@^|@@' -e 's@|.*@@')
 
     # Add $ctdb_interfaces and uniquify
     all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort -u)
index ee83632024356a8205769b547324694b941c6ecd..cd0020e559ea2f2ee37e76cc573a91aed3137d12 100755 (executable)
@@ -290,7 +290,7 @@ flush_rules_and_routes ()
 # routes.
 add_missing_routes ()
 {
-    ctdb ip -v -Y | {
+    ctdb ip -v -X | {
        read _x # skip header line
 
        # Read the rest of the lines.  We're only interested in the
@@ -299,7 +299,7 @@ add_missing_routes ()
        # non-local addresses.  For each IP local address we check if
        # the relevant routing table is populated and populate it if
        # not.
-       while IFS=":" read _x _ip _x _iface _x ; do
+       while IFS="|" read _x _ip _x _iface _x ; do
            [ -n "$_iface" ] || continue
            
            _table_id="${table_id_prefix}${_ip}"
@@ -317,7 +317,7 @@ add_missing_routes ()
 remove_bogus_routes ()
 {
     # Get a IPs current hosted by this node, each anchored with '@'.
-    _ips=$(ctdb ip -v -Y | awk -F: 'NR > 1 && $4 != "" {printf "@%s@\n", $2}')
+    _ips=$(ctdb ip -v -X | awk -F'|' 'NR > 1 && $4 != "" {printf "@%s@\n", $2}')
 
     ip rule show |
     while read _p _x _i _x _t ; do
index da02acc27c693729738a214087079dfca4a7aa7c..a6ca0c47e2527f2f6710668517f38bc33eb3a379 100755 (executable)
@@ -53,7 +53,7 @@ case "$1" in
 
         # Wait until we no longer serve any ip addresses at all
         PNN=`ctdb pnn | cut -d: -f2`
-        while `ctdb -Y ip | cut -d: -f3 | egrep "^$PNN$" >/dev/null`; do
+        while `ctdb -X ip | cut -d'|' -f3 | egrep "^$PNN$" >/dev/null`; do
                 sleep 1
         done
         ;;
index cedaf40434edabc4a3507dccc3164671d118ec3e..4627822e9c5f1b828ba97f444455e8990903a855 100755 (executable)
@@ -36,7 +36,7 @@ case "$1" in
        # start the iscsi daemon
        tgtd >/dev/null 2>/dev/null
 
-       ips=$(ctdb -Y ip | awk -F: -v pnn=$this_node '$3 == pnn {print $2}')
+       ips=$(ctdb -X ip | awk -F'|' -v pnn=$this_node '$3 == pnn {print $2}')
        for ip in $ips ; do
            script="${CTDB_START_ISCSI_SCRIPTS}/${ip}.sh"
            if [ -x "$script" ] ; then
index 77c3ffbac36588ffba6a720382c3562924caa24b..6e986be2baa4caf29c4488f6860c844cf736d3f4 100755 (executable)
@@ -1120,19 +1120,19 @@ ctdb_reconfigure_release_lock ()
 ctdb_replay_monitor_status ()
 {
     echo "Replaying previous status for this script due to reconfigure..."
-    # Leading colon (':') is missing in some versions...
-    _out=$(ctdb scriptstatus -Y | grep -E "^:?monitor:${script_name}:")
+    # Leading separator ('|') is missing in some versions...
+    _out=$(ctdb scriptstatus -X | grep -E "^\|?monitor\|${script_name}\|")
     # Output looks like this:
-    # :monitor:60.nfs:1:ERROR:1314764004.030861:1314764004.035514:foo bar:
+    # |monitor|60.nfs|1|ERROR|1314764004.030861|1314764004.035514|foo bar|
     # This is the cheapest way of getting fields in the middle.
-    set -- $(IFS=":" ; echo $_out)
+    set -- $(IFS="|" ; echo $_out)
     _code="$3"
     _status="$4"
     # The error output field can include colons so we'll try to
     # preserve them.  The weak checking at the beginning tries to make
-    # this work for both broken (no leading ':') and fixed output.
-    _out="${_out%:}"
-    _err_out="${_out#*monitor:${script_name}:*:*:*:*:}"
+    # this work for both broken (no leading '|') and fixed output.
+    _out="${_out%|}"
+    _err_out="${_out#*monitor|${script_name}|*|*|*|*|}"
     case "$_status" in
        OK) : ;;  # Do nothing special.
        TIMEDOUT)
@@ -1395,7 +1395,7 @@ update_tickles ()
        _pnn=$(ctdb pnn) ; _pnn=${_pnn#PNN:}
 
        # What public IPs do I hold?
-       _ips=$(ctdb -Y ip | awk -F: -v pnn=$_pnn '$3 == pnn {print $2}')
+       _ips=$(ctdb -X ip | awk -F'|' -v pnn=$_pnn '$3 == pnn {print $2}')
 
        # IPs as a regexp choice
        _ipschoice="($(echo $_ips | sed -e 's/ /|/g' -e 's/\./\\\\./g'))"
@@ -1412,8 +1412,8 @@ update_tickles ()
        _my_tickles="${tickledir}/${_port}.tickles"
        rm -f "$_my_tickles"
        for _i in $_ips ; do
-               ctdb -Y gettickles $_i $_port | 
-               awk -F: 'NR > 1 { printf "%s:%s %s:%s\n", $2, $3, $4, $5 }'
+               ctdb -X gettickles $_i $_port |
+               awk -F'|' 'NR > 1 { printf "%s:%s %s:%s\n", $2, $3, $4, $5 }'
        done |
        sort >"$_my_tickles"
 
index 53b408d55447d18408a8c4e87686ce5924328ac4..5e8eb0e789ccf8aff90f4a2346f452c16c1c2ab8 100755 (executable)
@@ -37,12 +37,12 @@ case "$1" in
        cip="$2"
        pnn=$(ctdb xpnn | sed -e 's/.*://')
        date=$(date '+%s')
-       ctdb ip -Y |
+       ctdb ip -X |
        tail -n +2 | {
            # This all needs to be in the end of the pipe so it
            # doesn't get lost
            items=""
-           while IFS=":" read x sip node x ; do
+           while IFS="|" read x sip node x ; do
                [ "$node" = "$pnn" ] || continue # not us
                key="statd-state@${sip}@${cip}"
                item="\"${key}\" \"${date}\""
@@ -58,12 +58,12 @@ case "$1" in
        # so we must add it to all the IPs that we serve
        cip="$2"
        pnn=$(ctdb xpnn | sed -e 's/.*://')
-       ctdb ip -Y |
+       ctdb ip -X |
        tail -n +2 | {
            # This all needs to be in the end of the pipe so it
            # doesn't get lost
            items=""
-           while IFS=":" read x sip node x ; do
+           while IFS="|" read x sip node x ; do
                [ "$node" = "$pnn" ] || continue # not us
                key="statd-state@${sip}@${cip}"
                item="\"${key}\" \"\""
index cea6c4daf89ed18e54aa1b27c5fa3e9502ebdbcd..23a64815c9b755ce5b4f7995e87dfd0242cd21ef 100644 (file)
@@ -355,7 +355,7 @@ Swap:         5719        246       5473"
 ctdb_get_interfaces ()
 {
     # The echo/subshell forces all the output onto 1 line.
-    echo $(ctdb ifaces -Y | awk -F: 'FNR > 1 {print $2}')
+    echo $(ctdb ifaces -X | awk -F'|' 'FNR > 1 {print $2}')
 }
 
 ctdb_get_1_interface ()
@@ -378,10 +378,10 @@ ctdb_get_all_public_addresses ()
 # Each line is suitable for passing to takeip/releaseip
 ctdb_get_my_public_addresses ()
 {
-    ctdb ip -v -Y | {
+    ctdb ip -v -X | {
        read _x # skip header line
 
-       while IFS=":" read _x _ip _x _iface _x ; do
+       while IFS="|" read _x _ip _x _iface _x ; do
            [ -n "$_iface" ] || continue
            while IFS="/$IFS" read _i _maskbits _x ; do
                if [ "$_ip" = "$_i" ] ; then
index b8b3e67a42eb8a7614379d00b591899badff577f..c44419672d5cd884a36fb70d5d563b2c8c4143e3 100755 (executable)
@@ -13,7 +13,7 @@ not_implemented_exit_code=1
 usage ()
 {
     cat >&2 <<EOF
-Usage: $prog [-Y] cmd
+Usage: $prog [-X] cmd
 
 A fake CTDB stub that prints items depending on the variables
 FAKE_CTDB_PNN (default 0) depending on command-line options.
@@ -28,7 +28,7 @@ not_implemented ()
 }
 
 # Don't set $POSIXLY_CORRECT here.
-_temp=$(getopt -n "$prog" -o "Yvhn:" -l help -- "$@") || \
+_temp=$(getopt -n "$prog" -o "Xvhn:" -l help -- "$@") || \
     usage
 
 eval set -- "$_temp"
@@ -41,7 +41,7 @@ args="$*"
 
 while true ; do
     case "$1" in
-       -Y) machine_readable=true ; shift ;;
+       -X) machine_readable=true ; shift ;;
        -v) verbose=true ; shift ;;
        -n) nodespec="$2" ; shift 2 ;;
        --) shift ; break ;;
@@ -173,9 +173,9 @@ ctdb_ip ()
            if [ "$_pnn" = "$_mypnn" ]; then
                _my_iface="$_first_iface"
            fi
-           echo ":${_ip}:${_pnn}:${_my_iface}:${_first_iface}:${_ifaces}:"
+           echo "|${_ip}|${_pnn}|${_my_iface}|${_first_iface}|${_ifaces}|"
        else
-           echo ":${_ip}:${_pnn}:"
+           echo "|${_ip}|${_pnn}|"
        fi
     done
 }
@@ -307,9 +307,9 @@ ctdb_natgwlist ()
 case "$1" in
     gettickles)
        setup_tickles
-       echo ":source ip:port:destination ip:port:"
+       echo "|source ip|port|destination ip|port|"
        while read src dst ; do
-           echo ":${src}:${dst}:"
+           echo "|${src}|${dst}|"
        done <"$tickles_file"
        ;;
     addtickle)
@@ -331,7 +331,7 @@ case "$1" in
        ;;
     ifaces)
        # Assume -Y.
-       echo ":Name:LinkStatus:References:"
+       echo "|Name|LinkStatus|References|"
        _f="${CTDB_PUBLIC_ADDRESSES:-${CTDB_BASE}/public_addresses}"
        if [ -r "$_f" ] ; then
            while read _ip _iface ; do
@@ -344,7 +344,7 @@ case "$1" in
                            _status=0
                        fi
                        # Nobody looks at references
-                       echo ":${_iface}:${_status}:0"
+                       echo "|${_iface}|${_status}|0|"
                esac
            done <"$_f" |
            sort -u
@@ -374,7 +374,7 @@ case "$1" in
        $machine_readable || not_implemented "$1, without -Y"
        [ "$2" != "all" ] || not_implemented "scriptstatus all"
        # For now just assume everything is good.
-       echo ":Type:Name:Code:Status:Start:End:Error Output...:"
+       echo "|Type|Name|Code|Status|Start|End|Error Output...|"
        for _i in "$CTDB_BASE/events.d/"*.* ; do
            _d1=$(date '+%s.%N')
            _b="${_i##*/}" # basename
@@ -392,7 +392,7 @@ case "$1" in
                _err_out=""
            fi
            _d2=$(date '+%s.%N')
-           echo ":${2:-monitor}:${_b}:${_code}:${_status}:${_d1}:${_d2}:${_err_out}:"
+           echo "|${2:-monitor}|${_b}|${_code}|${_status}|${_d1}|${_d2}|${_err_out}|"
        done
        ;;
     gratiousarp) : ;;  # Do nothing for now