Eventscripts - new function ctdb_check_args()
authorMartin Schwenke <martin@meltin.net>
Tue, 23 Aug 2011 06:32:34 +0000 (16:32 +1000)
committerMartin Schwenke <martin@meltin.net>
Mon, 29 Aug 2011 23:33:47 +0000 (09:33 +1000)
Pass this "$@" to do common eventscript argument checking.

For regular use putting this in 00.ctdb would be enough.  However, for
developer testing it can be useful to call this in other eventscripts.
For example, 10.interfaces and 13.per_ip_routing currently check these
by hand.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/functions

index ce28cdbd4dcbe7cbe0d2694e7ade5d8d6af8b53b..e30e57dba0e977bf8eef125ad63bb7d30ade001a 100755 (executable)
@@ -82,6 +82,26 @@ debug ()
     fi
 }
 
+##############################################################
+# check number of args for different events
+ctdb_check_args ()
+{
+    case "$1" in
+       takeip|releaseip)
+           if [ $# != 4 ]; then
+               echo "ERROR: must supply interface, IP and maskbits"
+               exit 1
+           fi
+           ;;
+       updateip)
+           if [ $# != 5 ]; then
+               echo "ERROR: must supply old interface, new interface, IP and maskbits"
+               exit 1
+           fi
+           ;;
+    esac
+}
+
 ##############################################################
 # determine on what type of system (init style) we are running
 detect_init_style() {