summaryrefslogtreecommitdiffstats
path: root/ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw
diff options
context:
space:
mode:
Diffstat (limited to 'ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw')
-rwxr-xr-xctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw34
1 files changed, 34 insertions, 0 deletions
diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw b/ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw
new file mode 100755
index 0000000..e64a956
--- /dev/null
+++ b/ctdb/tests/UNIT/eventscripts/stubs/ctdb_natgw
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+prog="ctdb_natgw"
+
+not_implemented_exit_code=1
+
+not_implemented ()
+{
+ echo "${prog}: command \"$1\" not implemented in stub" >&2
+ exit $not_implemented_exit_code
+}
+
+ctdb_natgw_leader ()
+{
+ [ -r "$CTDB_NATGW_NODES" ] || \
+ die "error: missing CTDB_NATGW_NODES=${CTDB_NATGW_NODES}"
+
+ # Determine the leader node
+ _leader="-1 0.0.0.0"
+ _pnn=0
+ while read _ip ; do
+ if [ "$FAKE_CTDB_NATGW_LEADER" = "$_ip" ] ; then
+ _leader="${_pnn} ${_ip}"
+ break
+ fi
+ _pnn=$(($_pnn + 1))
+ done <"$CTDB_NATGW_NODES"
+ echo "$_leader"
+}
+
+case "$1" in
+ leader) ctdb_natgw_leader "$@" ;;
+ *) not_implemented "$1" ;;
+esac