_select_test_node_and_ips ()
{
try_command_on_node any \
- "$CTDB ip -X -n all | awk -F'|' 'NR > 1 { print \$2, \$3 }'"
+ "$CTDB ip -X all | awk -F'|' 'NR > 1 { print \$2, \$3 }'"
test_node="" # this matches no PNN
test_node_ips=""
echo "$test_ip/$mask is on $iface"
}
+ctdb_get_all_pnns ()
+{
+ try_command_on_node -q all "$CTDB pnn"
+ all_pnns="$out"
+}
+
+# The subtlety is that "ctdb delip" will fail if the IP address isn't
+# configured on a node...
+delete_ip_from_all_nodes ()
+{
+ _ip="$1"
+
+ ctdb_get_all_pnns
+
+ _nodes=""
+
+ for _pnn in $all_pnns ; do
+ all_ips_on_node $_pnn
+ while read _i _n ; do
+ if [ "$_ip" = "$_i" ] ; then
+ _nodes="${_nodes}${_nodes:+,}${_pnn}"
+ fi
+ done <<<"$out" # bashism
+ done
+
+ try_command_on_node -pq "$_nodes" "$CTDB delip $_ip"
+}
+
#######################################
# Wait until either timeout expires or command succeeds. The command
_cluster_is_recovered ()
{
- node_has_status all recovered
+ node_has_status 0 recovered
}
_cluster_is_ready ()
#######################################
-_ctdb_hack_options ()
+_service_ctdb ()
{
- local ctdb_options="$*"
-
- case "$ctdb_options" in
- *--start-as-stopped*)
- export CTDB_START_AS_STOPPED="yes"
- esac
-}
-
-restart_ctdb_1 ()
-{
- _ctdb_hack_options "$@"
+ cmd="$1"
if [ -e /etc/redhat-release ] ; then
- service ctdb restart
+ service ctdb "$cmd"
else
- /etc/init.d/ctdb restart
+ /etc/init.d/ctdb "$cmd"
fi
}
# Restart CTDB on all nodes. Override for local daemons.
_restart_ctdb_all ()
{
- onnode -p all $CTDB_TEST_WRAPPER restart_ctdb_1 "$@"
+ onnode -p all $CTDB_TEST_WRAPPER _service_ctdb restart
}
# Nothing needed for a cluster. Override for local daemons.
:
}
-restart_ctdb ()
+start_ctdb_1 ()
+{
+ onnode "$1" $CTDB_TEST_WRAPPER _service_ctdb start
+}
+
+stop_ctdb_1 ()
{
- # "$@" is passed to restart_ctdb_all.
+ onnode "$1" $CTDB_TEST_WRAPPER _service_ctdb stop
+}
+restart_ctdb_1 ()
+{
+ onnode "$1" $CTDB_TEST_WRAPPER _service_ctdb restart
+}
+
+restart_ctdb ()
+{
echo -n "Restarting CTDB"
if $ctdb_test_restart_scheduled ; then
echo -n " (scheduled)"
local i
for i in $(seq 1 5) ; do
- _restart_ctdb_all "$@" || {
+ _restart_ctdb_all || {
echo "Restart failed. Trying again in a few seconds..."
sleep_for 5
continue
ip addr show to "${_addr}/${_bits}" 2>/dev/null | \
awk -v family="${_family}" \
- 'NR == 1 { iface = gensub(":$", "", 1, $2) } \
- $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }'
+ 'NR == 1 { iface = $2; sub(":$", "", iface) } \
+ $1 ~ /inet/ { mask = $2; sub(".*/", "", mask); \
+ print mask, iface, family }'
}
drop_ip ()