From 91d5edee80fd103827b12c867081ad8573aaef22 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 30 Aug 2011 16:27:04 +1000 Subject: Tests - eventscripts - ctdb stub - implement scriptstatus, tweaks Signed-off-by: Martin Schwenke (This used to be ctdb commit edc34d01a1ad83b1335c976593a006166b196569) --- ctdb/tests/eventscripts/stubs/ctdb | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/ctdb/tests/eventscripts/stubs/ctdb b/ctdb/tests/eventscripts/stubs/ctdb index 8d6409363e..5b18473ec1 100755 --- a/ctdb/tests/eventscripts/stubs/ctdb +++ b/ctdb/tests/eventscripts/stubs/ctdb @@ -11,10 +11,13 @@ Usage: $prog [-Y] cmd A fake CTDB stub that prints items depending on the variables FAKE_CTDB_PNN (default 0) depending on command-line options. - -Note that -Y is ignored. - EOF + exit 1 +} + +not_implemented () +{ + echo "${prog}: command \"$1\" not implemented in stub" >&2 exit $not_implemented_exit_code } @@ -25,10 +28,11 @@ _temp=$(getopt -n "$prog" -o "Yvh" -l help -- "$@") || \ eval set -- "$_temp" verbose=false +machine_readable=false while true ; do case "$1" in - -Y) shift ;; + -Y) machine_readable=true ; shift ;; -v) verbose=true ; shift ;; --) shift ; break ;; -h|--help|*) usage ;; # * shouldn't happen, so this is reasonable. @@ -54,8 +58,7 @@ setup_pstore () # For testing backward compatibility... for i in $CTDB_NOT_IMPLEMENTED ; do if [ "$i" = "$1" ] ; then - echo "${prog}: command \"$i\" not implemented" >&2 - usage + not_implemented "$i" fi done @@ -194,8 +197,24 @@ EOF exit 0 ;; + scriptstatus) + $machine_readable || not_implemented "$1, without -Y" + [ "$2" != "all" ] || not_implemented "scriptstatus all" + # For now just assume everything is good. + _d1=$(date '+%s.%N') + _d2=$(date '+%s.%N') + echo ":Type:Name:Code:Status:Start:End:Error Output...:" + for _i in "$CTDB_BASE/events.d/"*.* ; do + _b="${_i##*/}" # basename + _status="OK" + _code="0" + if [ ! -x "$_i" ] ; then + _status="DISABLED" + _code="-8" + fi + echo ":${2:-monitor}:${_b}:${_code}:${_status}:${_d1}:${_d2}::" + done + ;; *) - echo "${prog}: command \"$1\" not implemented in stub" - usage + not_implemented "$1" esac - -- cgit