From 4940f191d37b5deadc8b1edf0cd516674e5d5d64 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 20 Nov 2014 14:32:46 +1100 Subject: [PATCH] ctdb-scripts: Update eventscripts to use ctdb -X instead of ctdb -Y Also update associated eventscript unit tests and ctdb stub. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/config/events.d/10.interface | 2 +- ctdb/config/events.d/13.per_ip_routing | 6 +++--- ctdb/config/events.d/62.cnfs | 2 +- ctdb/config/events.d/70.iscsi | 2 +- ctdb/config/functions | 20 ++++++++++---------- ctdb/config/statd-callout | 8 ++++---- ctdb/tests/eventscripts/scripts/local.sh | 6 +++--- ctdb/tests/eventscripts/stubs/ctdb | 22 +++++++++++----------- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface index 018f767e444..8207fd3b20d 100755 --- a/ctdb/config/events.d/10.interface +++ b/ctdb/config/events.d/10.interface @@ -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) diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing index ee836320243..cd0020e559e 100755 --- a/ctdb/config/events.d/13.per_ip_routing +++ b/ctdb/config/events.d/13.per_ip_routing @@ -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 diff --git a/ctdb/config/events.d/62.cnfs b/ctdb/config/events.d/62.cnfs index da02acc27c6..a6ca0c47e25 100755 --- a/ctdb/config/events.d/62.cnfs +++ b/ctdb/config/events.d/62.cnfs @@ -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 ;; diff --git a/ctdb/config/events.d/70.iscsi b/ctdb/config/events.d/70.iscsi index cedaf40434e..4627822e9c5 100755 --- a/ctdb/config/events.d/70.iscsi +++ b/ctdb/config/events.d/70.iscsi @@ -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 diff --git a/ctdb/config/functions b/ctdb/config/functions index 77c3ffbac36..6e986be2baa 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -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" diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index 53b408d5544..5e8eb0e789c 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -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}\" \"\"" diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh index cea6c4daf89..23a64815c9b 100644 --- a/ctdb/tests/eventscripts/scripts/local.sh +++ b/ctdb/tests/eventscripts/scripts/local.sh @@ -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 diff --git a/ctdb/tests/eventscripts/stubs/ctdb b/ctdb/tests/eventscripts/stubs/ctdb index b8b3e67a42e..c44419672d5 100755 --- a/ctdb/tests/eventscripts/stubs/ctdb +++ b/ctdb/tests/eventscripts/stubs/ctdb @@ -13,7 +13,7 @@ not_implemented_exit_code=1 usage () { cat >&2 <