cluster: RHEL55 - fence-agents: Add power_wait to fence_ipmilan
Marek Grác
marx at fedoraproject.org
Mon Oct 18 20:05:52 UTC 2010
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a6ada12cf1843daeb506957e52399c20937be000
Commit: a6ada12cf1843daeb506957e52399c20937be000
Parent: bbb7969d9cdcfa2b5a129b69148dde8034d071df
Author: Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate: Mon Oct 18 21:58:30 2010 +0200
Committer: Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Mon Oct 18 21:58:30 2010 +0200
fence-agents: Add power_wait to fence_ipmilan
Previous patch used power-wait which was inconsistent with
the rest of the fencing agents. Also, help information
for the new option was missing.
Resolves: rhbz#642700
Signed-off-by: Lon Hohberger <lhh at redhat.com>
Signed-off-by: Shane Bradley <sbradley at redhat.com>
---
fence/agents/ipmilan/ipmilan.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index d8d76ff..ca45fe5 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"
@@ -99,6 +100,7 @@ struct ipmi {
int i_verbose;
int i_lanplus;
int i_timeout;
+ int i_power_wait;
int i_cipher;
};
@@ -441,7 +443,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);
@@ -546,6 +548,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;
@@ -618,6 +621,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;
@@ -904,6 +908,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 in[256];
@@ -971,6 +976,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;
@@ -1017,6 +1026,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\n");
printf(" -t <timeout> Timeout (sec) for IPMI operation (default %d)\n",DEFAULT_TIMEOUT);
+printf(" -T <timeout> Wait X seconds after on/off operation\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");
@@ -1033,6 +1043,7 @@ printf(" option=<op> Same as -o\n");
printf(" operation=<op> Same as -o\n");
printf(" action=<op> Same as -o\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");
@@ -1057,6 +1068,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;
memset(ip, 0, sizeof(ip));
@@ -1070,7 +1082,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:")) != EOF) {
+ while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:T:C:M:")) != EOF) {
switch(opt) {
case 'A':
/* Auth type */
@@ -1106,6 +1118,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) {
@@ -1140,6 +1158,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)) != 0)
return 1;
}
@@ -1202,7 +1221,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