diff options
| author | Martin Schwenke <martin@meltin.net> | 2014-11-20 14:32:46 +1100 |
|---|---|---|
| committer | Martin Schwenke <martins@samba.org> | 2014-12-05 21:02:39 +0100 |
| commit | 4940f191d37b5deadc8b1edf0cd516674e5d5d64 (patch) | |
| tree | 30f80af0de414c3f468c3a8b0f7988371a1d087c | |
| parent | 7428f809a76044fcbc98fd5f718e331ce183941d (diff) | |
| download | samba-4940f191d37b5deadc8b1edf0cd516674e5d5d64.tar.gz samba-4940f191d37b5deadc8b1edf0cd516674e5d5d64.tar.xz samba-4940f191d37b5deadc8b1edf0cd516674e5d5d64.zip | |
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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
| -rwxr-xr-x | ctdb/config/events.d/10.interface | 2 | ||||
| -rwxr-xr-x | ctdb/config/events.d/13.per_ip_routing | 6 | ||||
| -rwxr-xr-x | ctdb/config/events.d/62.cnfs | 2 | ||||
| -rwxr-xr-x | ctdb/config/events.d/70.iscsi | 2 | ||||
| -rwxr-xr-x | ctdb/config/functions | 20 | ||||
| -rwxr-xr-x | ctdb/config/statd-callout | 8 | ||||
| -rw-r--r-- | ctdb/tests/eventscripts/scripts/local.sh | 6 | ||||
| -rwxr-xr-x | 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 018f767e44..8207fd3b20 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 ee83632024..cd0020e559 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 da02acc27c..a6ca0c47e2 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 cedaf40434..4627822e9c 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 77c3ffbac3..6e986be2ba 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 53b408d554..5e8eb0e789 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 cea6c4daf8..23a64815c9 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 b8b3e67a42..c44419672d 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 <<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 |
