summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2011-06-28 15:53:54 +1000
committerMartin Schwenke <martin@meltin.net>2011-08-12 14:43:15 +1000
commitbb5db84021bb459781c55ebca5fa463f328cdafd (patch)
treea17ea073f6415d8bfbae3e481571562c427cccc4
parentf9e58b502fe84b2a7d0f08c19f2df265089766ba (diff)
downloadsamba-bb5db84021bb459781c55ebca5fa463f328cdafd.tar.gz
samba-bb5db84021bb459781c55ebca5fa463f328cdafd.tar.xz
samba-bb5db84021bb459781c55ebca5fa463f328cdafd.zip
Eventscripts: 10.interfaces cleanup - new functions mark_up(), mark_down().
The same few lines of logic are used every time an interface up or down. This encapsulates those few lines in 2 new functions. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit ab443c4d7d282f282792abc6a6ac224ab06abe30)
-rwxr-xr-xctdb/config/events.d/10.interface36
1 files changed, 20 insertions, 16 deletions
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface
index baf317166f..a82e4295dd 100755
--- a/ctdb/config/events.d/10.interface
+++ b/ctdb/config/events.d/10.interface
@@ -16,6 +16,18 @@ loadconfig
exit 0
}
+mark_up ()
+{
+ ok=1
+ ctdb setifacelink $1 up >/dev/null 2>&1
+}
+
+mark_down ()
+{
+ fail=1
+ ctdb setifacelink $1 down >/dev/null 2>&1
+}
+
monitor_interfaces()
{
INTERFACES=`cat $CTDB_PUBLIC_ADDRESSES |
@@ -47,39 +59,33 @@ monitor_interfaces()
bi=$(get_proc "net/bonding/$REALIFACE" 2>/dev/null) && {
echo "$bi" | grep -q 'Currently Active Slave: None' && {
echo "ERROR: No active slaves for bond device $REALIFACE"
- fail=1
- ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
+ mark_down $IFACE
continue;
}
echo "$bi" | grep -q '^MII Status: up' || {
echo "ERROR: public network interface $REALIFACE is down"
- fail=1
- ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
+ mark_down $IFACE
continue;
}
echo "$bi" | grep -q '^Bonding Mode: IEEE 802.3ad Dynamic link aggregation' && {
echo "$bi" | grep 'MII Status:' | tail -n +2 | grep -q '^MII Status: up' || {
echo No active slaves for 802.ad bond device $REALIFACE
- ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
- fail=1
+ mark_down $IFACE
continue
}
}
- ok=1 # we only set ok for interfaces known to ctdbd
- ctdb setifacelink $IFACE up >/dev/null 2>/dev/null
+ mark_up $IFACE
continue;
}
case $IFACE in
lo*)
# loopback is always working
- ok=1 # we only set ok for interfaces known to ctdbd
- ctdb setifacelink $IFACE up >/dev/null 2>/dev/null
+ mark_up $IFACE
;;
ib*)
# we dont know how to test ib links
- ok=1 # we only set ok for interfaces known to ctdbd
- ctdb setifacelink $IFACE up >/dev/null 2>/dev/null
+ mark_up $IFACE
;;
*)
[ -z "$IFACE" ] || {
@@ -92,13 +98,11 @@ monitor_interfaces()
ip link set $IFACE up
ethtool $IFACE | grep -q 'Link detected: yes' || {
echo "ERROR: No link on the public network interface $IFACE"
- fail=1
- ctdb setifacelink $IFACE down >/dev/null 2>/dev/null
+ mark_down $IFACE
continue
}
}
- ok=1 # we only set ok for interfaces known to ctdbd
- ctdb setifacelink $IFACE up >/dev/null 2>/dev/null
+ mark_up $IFACE
}
;;
esac