cluster: STABLE3 - fencing: Method to cause one node to delay fencing - ipmilan

Marek Grác marx at fedoraproject.org
Mon Aug 2 13:56:30 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=274e85bc92fa3ffc5405dc2598b190d8470d0b32
Commit:        274e85bc92fa3ffc5405dc2598b190d8470d0b32
Parent:        91450b013aefe5374c330b83b515da11f5daf338
Author:        Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate:    Mon Aug 2 15:26:31 2010 +0200
Committer:     Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Mon Aug 2 15:52:37 2010 +0200

fencing: Method to cause one node to delay fencing - ipmilan

Resolves: rhbz#614046
---
 fence/agents/ipmilan/ipmilan.c |   29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index 58a86c9..39c8fb1 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -166,6 +166,7 @@ struct xml_parameter_s xml_parameters[]={
   {"timeout","-t",0,"string",NULL,"Timeout (sec) for IPMI operation"},
   {"cipher","-C",0,"string",NULL,"Ciphersuite to use (same as ipmitool -C parameter)"},
   {"method","-M",0,"string",DEFAULT_METHOD,"Method to fence (onoff or cycle)"},
+  {"delay","-f",0,"string",NULL,"Wait X seconds before fencing is started"},
   {"verbose","-v",0,"boolean",NULL,"Verbose mode"}};
 
 /*
@@ -684,7 +685,8 @@ get_options_stdin(char *ip, size_t iplen,
 		  char *user, size_t userlen,
 		  char *op, size_t oplen,
 		  int *lanplus, int *verbose,int *timeout,
-	          int *cipher, char *method, int methodlen)
+	          int *cipher, char *method, int methodlen,
+	          char *delay, size_t delaylen)
 {
 	char in[256];
 	int line = 0;
@@ -764,6 +766,11 @@ get_options_stdin(char *ip, size_t iplen,
 				strncpy(op, val, oplen);
 			else
 				op[0] = 0;
+		} else if (!strcasecmp(name,"delay")) {
+			if (val)
+				strncpy(delay, val, delaylen);
+			else
+				delay[0] = 0;
 		}
 	}
 
@@ -797,6 +804,7 @@ printf("   -l <login>     Username/Login (if required) to control power\n"
 printf("   -o <op>        Operation to perform.\n");
 printf("                  Valid operations: on, off, reboot, status, list or monitor\n");
 printf("   -t <timeout>   Timeout (sec) for IPMI operation (default %d)\n",DEFAULT_TIMEOUT);
+printf("   -f <timeout>   Wait X seconds before fencing is started\n");
 printf("   -C <cipher>    Ciphersuite to use (same as ipmitool -C parameter)\n");
 printf("   -M <method>    Method to fence (onoff or cycle (default %s)\n", DEFAULT_METHOD);
 printf("   -V             Print version and exit\n");
@@ -812,6 +820,7 @@ printf("   login=<login>         Same as -u\n");
 printf("   option=<op>           Same as -o\n");
 printf("   operation=<op>        Same as -o\n");
 printf("   action=<op>           Same as -o\n");
+printf("   delay=<seconds>       Same as -f\n");
 printf("   timeout=<timeout>     Same as -t\n");
 printf("   cipher=<cipher>       Same as -C\n");
 printf("   method=<method>       Same as -M\n");
@@ -874,6 +883,7 @@ main(int argc, char **argv)
 	char user[64];
 	char op[64];
 	char method[64];
+	char delay[64];
 	char pwd_script[PATH_MAX] = { 0, };
 	int lanplus=0;
 	int verbose=0;
@@ -890,12 +900,13 @@ main(int argc, char **argv)
 	memset(user, 0, sizeof(user));
 	memset(op, 0, sizeof(op));
 	memset(method, 0, sizeof(method));
+	memset(delay, 0, sizeof(delay));
 
 	if (argc > 1) {
 		/*
 		   Parse command line options if any were specified
 		 */
-		while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:C:M:")) != EOF) {
+		while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:C:M:f:")) != EOF) {
 			switch(opt) {
 			case 'A':
 				/* Auth type */
@@ -925,6 +936,10 @@ main(int argc, char **argv)
 				/* Operation */
 				strncpy(op, optarg, sizeof(op));
 				break;
+			case 'f':
+				/* Delay */
+				strncpy(delay, optarg, sizeof(delay));
+				break;
 			case 't':
 				/* Timeout */
 				if ((sscanf(optarg,"%d",&timeout)!=1) || timeout<1) {
@@ -965,7 +980,8 @@ main(int argc, char **argv)
 					  pwd_script, sizeof(pwd_script),
 				      user, sizeof(user),
 				      op, sizeof(op), &lanplus, &verbose,&timeout,
-				      &cipher, method, sizeof(method)) != 0)
+				      &cipher, method, sizeof(method),
+				      delay, sizeof(delay)) != 0)
 			return 1;
 	}
 
@@ -1036,6 +1052,13 @@ main(int argc, char **argv)
 		fail_exit("cycle method supports only 'reboot' operation (not 'on' or 'off').");
 	}
 
+	/* Delay fencing if requested */
+	if (delay) {
+		if (!strcasecmp(op, "reboot") || !strcasecmp(op, "off")) {
+			sleep(atoi(delay));
+		}
+	}
+
 	/* Ok, set up the IPMI struct */
 	i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, cipher);
 	if (!i)


More information about the cluster-commits mailing list