mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
ctdb-scripts: Simplify "ctdb lvs ..." output
For "master", if there is a master then print the PNN, otherwise print nothing. For "list", print the PNN and IP addresses without a colon in between. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
e3a7178511
commit
dfe8de9e4a
@ -81,7 +81,7 @@ ipreallocated)
|
||||
"$CTDB_LVS_PUBLIC_IFACE" "$CTDB_LVS_PUBLIC_IP"
|
||||
|
||||
ctdb_get_pnn
|
||||
lvsmaster=$("${CTDB_HELPER_BINDIR}/ctdb_lvs" master | sed -n -e 's/Node \([0-9]*\) is LVS master/\1/p')
|
||||
lvsmaster=$("${CTDB_HELPER_BINDIR}/ctdb_lvs" master)
|
||||
if [ "$pnn" != "$lvsmaster" ] ; then
|
||||
# This node is not the LVS master so change the IP address
|
||||
# to have scope "host" so this node won't respond to ARPs
|
||||
@ -99,7 +99,7 @@ ipreallocated)
|
||||
|
||||
# Add all nodes (except this node) as LVS servers
|
||||
"${CTDB_HELPER_BINDIR}/ctdb_lvs" list |
|
||||
awk -F: -v pnn="$pnn" '$1 != pnn { print $2 }' |
|
||||
awk -v pnn="$pnn" '$1 != pnn { print $2 }' |
|
||||
while read ip ; do
|
||||
ipvsadm -a -t "$CTDB_LVS_PUBLIC_IP" -r $ip -g
|
||||
ipvsadm -a -u "$CTDB_LVS_PUBLIC_IP" -r $ip -g
|
||||
|
@ -743,7 +743,7 @@ MonitorInterval = 15
|
||||
Example output:
|
||||
</para>
|
||||
<screen>
|
||||
Node 2 is LVS master
|
||||
2
|
||||
</screen>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
@ -757,8 +757,8 @@ Node 2 is LVS master
|
||||
Example output:
|
||||
</para>
|
||||
<screen>
|
||||
2:10.0.0.13
|
||||
3:10.0.0.14
|
||||
2 10.0.0.13
|
||||
3 10.0.0.14
|
||||
</screen>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -27,10 +27,9 @@ not_implemented ()
|
||||
ctdb_lvs_master ()
|
||||
{
|
||||
if [ -n "$FAKE_CTDB_LVS_MASTER" ] ; then
|
||||
echo "Node ${FAKE_CTDB_LVS_MASTER} is LVS master"
|
||||
echo "$FAKE_CTDB_LVS_MASTER"
|
||||
return 0
|
||||
else
|
||||
echo "This is no LVS master"
|
||||
return 255
|
||||
fi
|
||||
}
|
||||
@ -39,7 +38,7 @@ ctdb_lvs_list ()
|
||||
{
|
||||
_pnn=0
|
||||
while read _ip _opts ; do
|
||||
echo "${_pnn}:${_ip}"
|
||||
echo "${_pnn} ${_ip}"
|
||||
_pnn=$(($_pnn + 1))
|
||||
done <"$CTDB_LVS_NODES"
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ VNNMAP
|
||||
#####
|
||||
|
||||
required_result 255 <<EOF
|
||||
There is no LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
|
@ -31,7 +31,7 @@ VNNMAP
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 0 is LVS master
|
||||
0
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
@ -41,9 +41,9 @@ EOF
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
0:192.168.20.41
|
||||
1:192.168.20.42
|
||||
2:192.168.20.43
|
||||
0 192.168.20.41
|
||||
1 192.168.20.42
|
||||
2 192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
|
@ -29,7 +29,7 @@ VNNMAP
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 0 is LVS master
|
||||
0
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
@ -39,8 +39,8 @@ EOF
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
0:192.168.20.41
|
||||
2:192.168.20.43
|
||||
0 192.168.20.41
|
||||
2 192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
|
@ -31,7 +31,7 @@ VNNMAP
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 1 is LVS master
|
||||
1
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
@ -41,8 +41,8 @@ EOF
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
1:192.168.20.42
|
||||
2:192.168.20.43
|
||||
1 192.168.20.42
|
||||
2 192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
|
@ -31,7 +31,7 @@ VNNMAP
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 0 is LVS master
|
||||
0
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
@ -41,9 +41,9 @@ EOF
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
0:192.168.20.41
|
||||
1:192.168.20.42
|
||||
2:192.168.20.43
|
||||
0 192.168.20.41
|
||||
1 192.168.20.42
|
||||
2 192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
|
@ -31,7 +31,7 @@ VNNMAP
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
Node 2 is LVS master
|
||||
2
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
@ -41,7 +41,7 @@ EOF
|
||||
#####
|
||||
|
||||
required_result 0 <<EOF
|
||||
2:192.168.20.43
|
||||
2 192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test list <<EOF
|
||||
|
@ -31,7 +31,6 @@ VNNMAP
|
||||
#####
|
||||
|
||||
required_result 255 <<EOF
|
||||
There is no LVS master
|
||||
EOF
|
||||
|
||||
simple_test master <<EOF
|
||||
|
@ -141,25 +141,6 @@ EOF
|
||||
echo "${_master_candidates%% *}"
|
||||
}
|
||||
|
||||
# Print the PNN of the LVS master node, verbose version
|
||||
show_master ()
|
||||
{
|
||||
_master_pnn=$(find_master)
|
||||
case "$?" in
|
||||
0)
|
||||
echo "Node ${_master_pnn} is LVS master"
|
||||
exit 0
|
||||
;;
|
||||
255)
|
||||
echo "There is no LVS master"
|
||||
exit 255
|
||||
;;
|
||||
*)
|
||||
exit 10
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# List all usable nodes in the LVS group
|
||||
nodes_list ()
|
||||
{
|
||||
@ -181,7 +162,7 @@ EOF
|
||||
*) exit 10 ;;
|
||||
esac
|
||||
|
||||
awk '{ print $1 ":" $2 }'<<EOF
|
||||
awk '{ print $1, $2 }'<<EOF
|
||||
$_usable_nodes
|
||||
EOF
|
||||
}
|
||||
@ -213,7 +194,7 @@ prog=$(basename "$0")
|
||||
cmd="$1"
|
||||
|
||||
case "$cmd" in
|
||||
master) show_master ;;
|
||||
master) find_master ;;
|
||||
list) nodes_list ;;
|
||||
status) nodes_status ;;
|
||||
*) usage ;;
|
||||
|
Loading…
Reference in New Issue
Block a user