cluster: RHEL56 - fence-agents: Add power-wait to fence_ipmilan

Lon Hohberger lon at fedoraproject.org
Thu Sep 16 18:42:26 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=18d6d10d0ba6f939b22e65978f0c85233dba1fa1
Commit:        18d6d10d0ba6f939b22e65978f0c85233dba1fa1
Parent:        6616b37f2a68650112926c06973955dcd9fa4aa4
Author:        Christine Caulfield <ccaulfie at redhat.com>
AuthorDate:    Thu Sep 16 14:23:51 2010 -0400
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Thu Sep 16 14:27:08 2010 -0400

fence-agents: Add power-wait to fence_ipmilan

Resolves: rhbz#548575

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 fence/agents/ipmilan/ipmilan.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index 163f0c6..016a0fb 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -54,6 +54,7 @@ do { \
 #define ST_CYCLE 4
 
 #define DEFAULT_TIMEOUT 20
+#define DEFAULT_POWER_WAIT 2
 
 #define DEFAULT_METHOD "onoff"
 
@@ -112,6 +113,7 @@ struct ipmi {
 	int i_verbose;
 	int i_lanplus;
 	int i_timeout;
+	int i_power_wait;
 	int i_cipher;
 };
 
@@ -478,7 +480,7 @@ ipmi_off(struct ipmi *ipmi)
 		if (ret != 0)
 			return ret;
 
-		sleep(2);
+		sleep(ipmi->i_power_wait);
 		--retries;
 		ret = ipmi_op(ipmi, ST_STATUS, power_status);
 
@@ -583,6 +585,7 @@ ipmi_destroy(struct ipmi *i)
 static struct ipmi *
 ipmi_init(struct ipmi *i, char *host, char *authtype,
 	  char *user, char *password, int lanplus, int verbose,int timeout,
+	  int power_wait,
 	  int cipher)
 {
 	const char *p;
@@ -655,6 +658,7 @@ ipmi_init(struct ipmi *i, char *host, char *authtype,
 	i->i_verbose = verbose;
 	i->i_lanplus = lanplus;
 	i->i_timeout = timeout;
+	i->i_power_wait = power_wait;
 	i->i_cipher = cipher;
 
 	return i;
@@ -941,6 +945,7 @@ 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 *power_wait,
 	          int *cipher, char *method, int methodlen,
 	          char *delay, size_t delaylen)
 {
@@ -1009,6 +1014,10 @@ get_options_stdin(char *ip, size_t iplen,
 			if ((sscanf(val,"%d",timeout)!=1) || *timeout<1) {
 			    *timeout=DEFAULT_TIMEOUT;
 			}
+		} else if (!strcasecmp(name,"power-wait")) {
+			if ((sscanf(val,"%d",power_wait)!=1) || *power_wait<1) {
+			    *power_wait=DEFAULT_POWER_WAIT;
+			}
 		} else if (!strcasecmp(name,"cipher")) {
 			if ((sscanf(val,"%d",cipher)!=1) || *cipher<0) {
 			    *cipher=-1;
@@ -1078,6 +1087,7 @@ 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("   power-wait=<time>     Same as -T\n");
 printf("   cipher=<cipher>       Same as -C\n");
 printf("   method=<method>       Same as -M\n");
 printf("   verbose               Same as -v\n\n");
@@ -1146,6 +1156,7 @@ main(int argc, char **argv)
 	char *pname = basename(argv[0]);
 	struct ipmi *i;
 	int timeout=DEFAULT_TIMEOUT;
+	int down_sleep=DEFAULT_POWER_WAIT;
 	int cipher=-1;
 	int print_final_status=1;
 	int translated_ret = -1;
@@ -1162,7 +1173,7 @@ main(int argc, char **argv)
 		/*
 		   Parse command line options if any were specified
 		 */
-		while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:C:M:f:")) != EOF) {
+		while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:T:C:M:f:")) != EOF) {
 			switch(opt) {
 			case 'A':
 				/* Auth type */
@@ -1202,6 +1213,12 @@ main(int argc, char **argv)
 				    fail_exit("Timeout option expects positive number parameter");
 				}
 				break;
+			case 'T':
+				/* Shutdown Sleep Time */
+				if ((sscanf(optarg,"%d",&down_sleep)!=1) || down_sleep<1) {
+				    fail_exit("Shutdown time option expects positive number parameter");
+				}
+				break;
 			case 'C':
 				/* Ciphersuite */
 				if ((sscanf(optarg,"%d",&cipher)!=1) || cipher<0) {
@@ -1236,6 +1253,7 @@ main(int argc, char **argv)
 					  pwd_script, sizeof(pwd_script),
 				      user, sizeof(user),
 				      op, sizeof(op), &lanplus, &verbose,&timeout,
+				      &down_sleep,
 				      &cipher, method, sizeof(method),
 				      delay, sizeof(delay)) != 0)
 			return 1;
@@ -1316,7 +1334,7 @@ main(int argc, char **argv)
 	}
 
 	/* Ok, set up the IPMI struct */
-	i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, cipher);
+	i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, down_sleep, cipher);
 	if (!i)
 		fail_exit("Failed to initialize\n");
 


More information about the cluster-commits mailing list