Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 157944 Details for
Bug 245221
IPMI Fence Agent does not support IPMIv2.0 protocol (aka "lanplus")
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Untested patch; compiles
rhcs3-ipmilanplus.diff (text/x-patch), 10.57 KB, created by
Lon Hohberger
on 2007-06-26 19:27:22 UTC
(
hide
)
Description:
Untested patch; compiles
Filename:
MIME Type:
Creator:
Lon Hohberger
Created:
2007-06-26 19:27:22 UTC
Size:
10.57 KB
patch
obsolete
>Index: ipmilan.c >=================================================================== >RCS file: /cvs/devel/clumanager/src/stonithlib/ipmilan.c,v >retrieving revision 1.4 >diff -u -r1.4 ipmilan.c >--- ipmilan.c 23 Mar 2005 16:19:00 -0000 1.4 >+++ ipmilan.c 26 Jun 2007 19:20:21 -0000 >@@ -68,16 +68,30 @@ > #define IPMIID "IPMI over LAN driver" > #define NOTIPMI "Destroyed IPMI over LAN driver" > >+ >+#define dbg_printf(i, lvl, fmt, args...) \ >+do { \ >+ if ( (i)->i_verbose >= lvl) { \ >+ printf(fmt, ##args); \ >+ fflush(stdout); \ >+ } \ >+} while (0) >+ >+ >+ > struct ipmi { > char *i_id; > const char *i_ipmitool; > char *i_host; > char *i_user; >+ char *i_authtype; > char *i_password; > int i_rdfd; > int i_wrfd; > pid_t i_pid; > int i_config; >+ int i_verbose; >+ int i_lanplus; > }; > > >@@ -159,19 +173,40 @@ > { > char cmd[2048]; > char arg[2048]; >+ int x; > > /* Store path */ >- snprintf(cmd, sizeof(cmd), "%s -I lan -H %s", ipmi->i_ipmitool, >- ipmi->i_host); >+ if (ipmi->i_lanplus) { >+ snprintf(cmd, sizeof(cmd), "%s -I lanplus -H %s", >+ ipmi->i_ipmitool, ipmi->i_host); >+ } else { >+ snprintf(cmd, sizeof(cmd), "%s -I lan -H %s", ipmi->i_ipmitool, >+ ipmi->i_host); >+ } > > if (ipmi->i_user) { > snprintf(arg, sizeof(arg), " -U %s", ipmi->i_user); > strncat(cmd, arg, sizeof(cmd) - strlen(arg)); > } > >+ if (ipmi->i_authtype) { >+ snprintf(arg, sizeof(arg), " -A %s", ipmi->i_authtype); >+ strncat(cmd, arg, sizeof(cmd) - strlen(arg)); >+ } >+ > if (ipmi->i_password) { > snprintf(arg, sizeof(arg), " -P %s", ipmi->i_password); > strncat(cmd, arg, sizeof(cmd) - strlen(arg)); >+ } else { >+ snprintf(arg, sizeof(arg), " -P ''"); >+ strncat(cmd, arg, sizeof(cmd) - strlen(arg)); >+ } >+ >+ /* Tack on the -v flags for ipmitool; in most cases, i_verbose >+ will be 0 */ >+ for (x = 0; x < ipmi->i_verbose; x++) { >+ snprintf(arg, sizeof(arg), " -v"); >+ strncat(cmd, arg, sizeof(cmd) - strlen(arg)); > } > > switch(op) { >@@ -197,20 +232,26 @@ > static int > ipmi_spawn(struct ipmi *ipmi, const char *cmd) > { >+ dbg_printf(ipmi, 1, "Spawning: '%s'...\n", cmd); > if (!ipmi) { > errno = EINVAL; > return -1; > } > > if (ipmi->i_pid != -1) { >+ dbg_printf(ipmi, 1, "Can't spawn: PID %d running\n", >+ (int)ipmi->i_pid); > errno = EINPROGRESS; > return -1; > } > > if ((ipmi->i_pid = StartProcess(cmd, &ipmi->i_rdfd, > &ipmi->i_wrfd, >- EXP_STDERR|EXP_NOCTTY)) >= 0) >+ EXP_STDERR|EXP_NOCTTY)) >= 0) { >+ dbg_printf(ipmi, 2, "Spawned: '%s' - PID %d\n", cmd, >+ (int)ipmi->i_pid); > return 0; >+ } > return -1; > } > >@@ -219,6 +260,7 @@ > ipmi_reap(struct ipmi *ipmi) > { > if (ipmi->i_pid >= 0) { >+ dbg_printf(ipmi, 2, "Reaping pid %d\n", ipmi->i_pid); > kill(ipmi->i_pid, 9); > waitpid(ipmi->i_pid, NULL, 0); > } >@@ -239,10 +281,25 @@ > ipmi_expect(struct ipmi *ipmi, struct Etoken *toklist, int timeout) > { > int ret; >+ char buf[32768]; /* XX hope this is enough */ > >- ret = ExpectToken(ipmi->i_rdfd, toklist, timeout, NULL, 0); >- if (ret == -1) >+ dbg_printf(ipmi, 3, "Looking for: \n"); >+ for (ret = 0; toklist[ret].string; ret++) { >+ dbg_printf(ipmi, 3, " '%s', val = %d\n", >+ toklist[ret].string, >+ toklist[ret].toktype); >+ } >+ >+ ret = ExpectToken(ipmi->i_rdfd, toklist, timeout, buf, sizeof(buf)); >+ dbg_printf(ipmi, 3, "ExpectToken returned %d\n", ret); >+ if (ret == -1) { > ret = errno; >+ dbg_printf(ipmi, 3, "ExpectToken failed. Info returned:\n"); >+ dbg_printf(ipmi, 3, ">>>>>\n%s\n<<<<<\nError = %d (%s)\n", >+ buf, >+ ret, >+ strerror(ret)); >+ } > > return ret; > } >@@ -263,7 +320,9 @@ > ipmi_reap(ipmi); > > while ((ret == EAGAIN || ret == ETIMEDOUT) && retries > 0) { >+ dbg_printf(ipmi, 3, "Sleeping 5 ...\n"); > sleep(5); >+ dbg_printf(ipmi, 1, "Retrying ...\n"); > --retries; > > if (ipmi_spawn(ipmi, cmd) != 0) >@@ -405,7 +464,8 @@ > or update an existing one, or both. > */ > static struct ipmi * >-ipmi_init(struct ipmi *i, char *host, char *user, char *password) >+ipmi_init(struct ipmi *i, char *host, char *authtype, >+ char *user, char *password, int lanplus, int verbose) > { > const char *p; > >@@ -443,10 +503,25 @@ > } else > i->i_password = NULL; > >+ if (authtype && strlen(authtype)) { >+ i->i_authtype = strdup(authtype); >+ if (!i->i_authtype) { >+ free(i->i_host); >+ if (i->i_password) >+ free(i->i_password); >+ free(i); >+ return NULL; >+ } >+ } else >+ i->i_authtype = NULL; >+ >+ > if (user && strlen(user)) { > i->i_user= strdup(user); > if (!i->i_user) { > free(i->i_host); >+ if (i->i_authtype) >+ free(i->i_authtype); > if (i->i_password) > free(i->i_password); > free(i); >@@ -459,6 +534,8 @@ > i->i_wrfd = -1; > i->i_pid = -1; > i->i_id = IPMIID; >+ i->i_verbose = verbose; >+ i->i_lanplus = lanplus; > > return i; > } >@@ -503,7 +580,7 @@ > } > > memset((void *)i, 0, sizeof(*i)); >- ipmi_init(i, NULL, NULL, NULL); >+ ipmi_init(i, NULL, NULL, NULL, NULL, 0, 0); > return i; > } > >@@ -587,6 +664,7 @@ > char *end = NULL; > struct ipmi *i; > size_t len; >+ int lanplus = 0; > > if (!ISIPMI(s)) > return S_OOPS; >@@ -601,6 +679,10 @@ > if (user) { > *user = 0; > user++; >+ if (*user && *user == '+') { >+ lanplus = 1; >+ user++; >+ } > } > > /* No separator or end of string reached */ >@@ -631,7 +713,8 @@ > if (!*user || !strcmp(user, "(null)")) > user = NULL; > >- i = ipmi_init(i, host, user, passwd); >+ /* IPMI auth type not supported on RHEL3 */ >+ i = ipmi_init(i, host, NULL, user, passwd, lanplus, 0); > if (!i) > return S_OOPS; > i->i_config = 1; >@@ -732,10 +815,11 @@ > */ > int > get_options_stdin(char *ip, size_t iplen, >+ char *authtype, size_t atlen, > char *passwd, size_t pwlen, > char *user, size_t userlen, > char *op, size_t oplen, >- int *verbose) >+ int *lanplus, int *verbose) > { > char in[256]; > int line = 0; >@@ -769,6 +853,13 @@ > else > ip[0] = 0; > >+ } else if (!strcasecmp(name, "auth")) { >+ /* Authtype to use */ >+ if (val) >+ strncpy(authtype, val, atlen); >+ else >+ authtype[0] = 0; >+ > } else if (!strcasecmp(name, "passwd")) { > /* password */ > if (val) >@@ -776,13 +867,16 @@ > else > passwd[0] = 0; > >- } else if (!strcasecmp(name, "user")) { >+ } else if (!strcasecmp(name, "user") || >+ !strcasecmp(name, "login")) { > /* username */ > if (val) > strncpy(user, val, userlen); > else > user[0] = 0; > >+ } else if (!strcasecmp(name, "lanplus")) { >+ (*lanplus) = 1; > } else if (!strcasecmp(name, "option") || > !strcasecmp(name, "operation") || > !strcasecmp(name, "action")) { >@@ -790,11 +884,6 @@ > strncpy(op, val, oplen); > else > op[0] = 0; >- } else { >- fprintf(stderr, >- "parse error: illegal name on line %d\n", >- line); >- return 1; > } > } > >@@ -816,18 +905,21 @@ > usage_exit(char *pname) > { > printf("usage: %s <options>\n", pname); >-printf(" -i <ipaddr> IPMI Lan IP to talk to\n"); >+printf(" -A <authtype> IPMI Lan Auth type (md5, password, or none)\n"); >+printf(" -a <ipaddr> IPMI Lan IP to talk to\n"); >+printf(" -i <ipaddr> IPMI Lan IP to talk to (deprecated, use -i)\n"); > printf(" -p <password> Password (if required) to control power on\n" > " IPMI device\n"); > printf(" -l <login> Username/Login (if required) to control power\n" > " on IPMI device\n"); > printf(" -o <op> Operation to perform.\n"); >-printf(" Valid operations: on, off, reboot\n"); >+printf(" Valid operations: on, off, reboot, status\n"); > printf(" -V Print version and exit\n"); > printf(" -v Verbose mode\n\n"); > printf("If no options are specified, the following options will be read\n"); > printf("from standard input (one per line):\n\n"); >-printf(" ipaddr=<#> Same as -i\n"); >+printf(" auth=<auth> Same as -A\n"); >+printf(" ipaddr=<#> Same as -a\n"); > printf(" passwd=<pass> Same as -p\n"); > printf(" login=<login> Same as -u\n"); > printf(" option=<op> Same as -o\n"); >@@ -843,24 +935,33 @@ > { > extern char *optarg; > int opt, ret = -1; >+ char authtype[64]; > char ip[64]; > char passwd[64]; > char user[64]; > char op[64]; >+ int lanplus=0; > int verbose=0; > char *pname = basename(argv[0]); > struct ipmi *i; > > memset(ip, 0, sizeof(ip)); >+ memset(authtype, 0, sizeof(authtype)); > memset(passwd, 0, sizeof(passwd)); > memset(user, 0, sizeof(user)); >+ memset(op, 0, sizeof(op)); > > if (argc > 1) { > /* > Parse command line options if any were specified > */ >- while ((opt = getopt(argc, argv, "i:l:p:o:vV?hH")) != EOF) { >+ while ((opt = getopt(argc, argv, "A:a:i:l:p:Po:vV?hH")) != EOF) { > switch(opt) { >+ case 'A': >+ /* Auth type */ >+ strncpy(authtype, optarg, sizeof(authtype)); >+ break; >+ case 'a': > case 'i': > /* IP address */ > strncpy(ip, optarg, sizeof(ip)); >@@ -873,6 +974,9 @@ > /* password */ > strncpy(passwd, optarg, sizeof(passwd)); > break; >+ case 'P': >+ lanplus = 1; >+ break; > case 'o': > /* Operation */ > strncpy(op, optarg, sizeof(op)); >@@ -896,9 +1000,10 @@ > No command line args? Get stuff from stdin > */ > if (get_options_stdin(ip, sizeof(ip), >- user, sizeof(user), >+ authtype, sizeof(authtype), > passwd, sizeof(passwd), >- op, sizeof(op), &verbose) != 0) >+ user, sizeof(user), >+ op, sizeof(op), &lanplus, &verbose) != 0) > return 1; > } > >@@ -908,13 +1013,26 @@ > if (strlen(ip) == 0) > fail_exit("no IP address specified"); > >+ if (!strlen(op)) >+ snprintf(op,sizeof(op), "reboot"); >+ > if (strcasecmp(op, "off") && strcasecmp(op, "on") && >- strcasecmp(op, "reboot")) { >- fail_exit("operation must be 'on', 'off', or 'reboot'"); >+ strcasecmp(op, "status") && strcasecmp(op, "reboot")) { >+ fail_exit("operation must be 'on', 'off', 'status', " >+ "or 'reboot'"); > } > >+ if (strlen(authtype) && >+ strcasecmp(authtype, "md5") && >+ strcasecmp(authtype, "password") && >+ strcasecmp(authtype, "none")) { >+ fail_exit("authtype, if included, must be 'md5', 'password'," >+ " 'none'."); >+ } >+ >+ > /* Ok, set up the IPMI struct */ >- i = ipmi_init(NULL, ip, user, passwd); >+ i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose); > if (!i) > fail_exit("Failed to initialize\n"); > >@@ -938,8 +1056,27 @@ > printf("Powering off machine @ IPMI:%s...", ip); > fflush(stdout); > ret = ipmi_off(i); >+ } else if (!strcasecmp(op, "status")) { >+ printf("Getting status of IPMI:%s...",ip); >+ fflush(stdout); >+ ret = ipmi_op(i, ST_STATUS, power_status); >+ switch(ret) { >+ case STATE_ON: >+ printf("Chassis power = On\n"); >+ ret = 0; >+ break; >+ case STATE_OFF: >+ printf("Chassis power = Off\n"); >+ ret = 0; >+ break; >+ default: >+ printf("Chassis power = Unknown\n"); >+ ret = 1; >+ break; >+ } > } > >+ > out: > ipmi_destroy(i); > free(i);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 245221
:
157562
| 157944