Also update associated eventscript unit tests and ctdb stub.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
# 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)
# 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
# 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}"
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
# 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
;;
# 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
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)
_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'))"
_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"
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}\""
# 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}\" \"\""
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 ()
# 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
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.
}
# 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"
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 ;;
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
}
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)
;;
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
_status=0
fi
# Nobody looks at references
- echo ":${_iface}:${_status}:0"
+ echo "|${_iface}|${_status}|0|"
esac
done <"$_f" |
sort -u
$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
_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