Hello,
It's me again, please find attached a patch that includes an
implementation of the FRU control command. It also includes the previous
patch sent to the list (activation policy set). The command can be used
as follow:
# ipmitool -H shelfman picmg control
<FRU> {cr|wr|gr|idi}
cr: Cold Reset
wr: Warm Reset
gr: Graceful Reboot
idi: Issue Diagnostic Interrupt
# ipmitool -H shelfman picmg control 12 boo
boo: unknown control option
# ipmitool -H shelfman picmg control 12 cr
Maybe a frureset shortcut could be useful too.
Regards,
--
BenoƮt Guillon [EMAIL PROTECTED]
TCT/3S tel. : 33 (0)4 98 16 33 90
THALES COMPUTERS
--- ipmitool-1.8.8/lib/ipmi_picmg.c 2006-03-19 22:15:05.000000000 +0100
+++ ../ipmitool-1.8.8/lib/ipmi_picmg.c 2007-02-08 19:19:40.000000000 +0100
@@ -4,6 +4,7 @@
*/
+#include <string.h>
#include <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_picmg.h>
#include <ipmitool/ipmi_fru.h> /* for access to link descriptor defines */
@@ -18,6 +19,7 @@
printf(" deactivate - deactivate a FRU\n");
printf(" policy get - get the FRU activation policy\n");
printf(" policy set - set the FRU activation policy\n");
+ printf(" control - FRU control (reset, reboot)\n");
printf(" portstate get - get port state \n");
printf(" portstate set - set port state \n");
printf(" led prop - get led properties\n");
@@ -192,11 +194,143 @@
}
printf("Activation Policy for FRU %x: ", atoi(argv[0]) );
- printf(" %s\n",(((*(rsp->data+3))&0x01) == 0x01)?"is locked":"is not locked");
+ printf("%s, ", (rsp->data[1] & 0x01) ? "is locked" : "is not locked");
+ printf("%s\n", (rsp->data[1] & 0x02) ? "deactivation locked"
+ : "deactivation not locked");
+ return 0;
+}
+
+static void
+policy_set_bit(unsigned char *mask, unsigned char *set, int bit, int lock)
+{
+ *mask = *mask | bit;
+ if (lock) {
+ *set = *set | bit;
+ } else {
+ *set = *set & ~bit;
+ }
+}
+
+int
+ipmi_picmg_fru_activation_policy_set(struct ipmi_intf * intf,
+ int argc, char ** argv)
+{
+ struct ipmi_rs * rsp;
+ struct ipmi_rq req;
+ int i;
+ int bit;
+ int lock;
+ char *sep;
+#define ACT_LOCKED_BIT 0x1
+#define DEACT_LOCKED_BIT 0x2
+
+ unsigned char msg_data[4];
+
+ memset(&req, 0, sizeof(req));
+ req.msg.netfn = IPMI_NETFN_PICMG;
+ req.msg.cmd = PICMG_SET_FRU_POLICY_CMD;
+ req.msg.data = msg_data;
+ req.msg.data_len = 4;
+
+ msg_data[0] = 0; /* PICMG identifier */
+ msg_data[1] = (unsigned char) atoi(argv[0]); /* FRU ID */
+ msg_data[2] = 0; /* Policy Mask Bits */
+ msg_data[3] = 0; /* Policy Set Bits */
+
+ for (i = 1; i < argc; i++) {
+ printf("%s\n", argv[i]);
+ sep = strchr(argv[i], ':');
+ if (! sep) {
+ printf("[act:lock|act:unlock] [deact:lock|deact:unlock]\n");
+ return -1;
+ }
+ *sep = 0;
+ if (strcmp(argv[i], "act") == 0) {
+ bit = ACT_LOCKED_BIT;
+ } else if (strcmp(argv[i], "deact") == 0) {
+ bit = DEACT_LOCKED_BIT;
+ } else {
+ printf("act|deact\n");
+ return -1;
+ }
+ if (strcmp(sep+1, "lock") == 0) {
+ lock = 1;
+ } else if (strcmp(sep+1, "unlock") == 0) {
+ lock = 0;
+ } else {
+ printf("lock|unlock\n");
+ return -1;
+ }
+ policy_set_bit(&msg_data[2], &msg_data[3], bit, lock);
+ }
+
+ if (msg_data[2] == 0)
+ return 0;
+
+ rsp = intf->sendrecv(intf, &req);
+
+ if (!rsp) {
+ printf("no response\n");
+ return -1;
+ }
+ if (rsp->ccode) {
+ printf("returned CC code 0x%02x\n", rsp->ccode);
+ return -1;
+ }
return 0;
}
+
+int
+ipmi_picmg_fru_control(struct ipmi_intf * intf, int argc, char ** argv)
+{
+ struct ipmi_rs * rsp;
+ struct ipmi_rq req;
+
+ unsigned char msg_data[4];
+
+ memset(&req, 0, sizeof(req));
+ req.msg.netfn = IPMI_NETFN_PICMG;
+ req.msg.cmd = PICMG_FRU_CONTROL_CMD;
+ req.msg.data = msg_data;
+ req.msg.data_len = 3;
+
+ msg_data[0] = 0; /* PICMG identifier */
+ msg_data[1] = (unsigned char) atoi(argv[0]); /* FRU ID */
+
+ if (strcmp(argv[1], "cr") == 0) {
+ msg_data[2] = 0;
+ } else if (strcmp(argv[1], "wr") == 0) {
+ msg_data[2] = 1;
+ } else if (strcmp(argv[1], "gr") == 0) {
+ msg_data[2] = 2;
+ } else if (strcmp(argv[1], "idi") == 0) {
+ msg_data[2] = 3;
+ } else {
+ printf("%s: unknown control option\n", argv[1]);
+ return -1;
+ }
+
+ rsp = intf->sendrecv(intf, &req);
+
+ if (!rsp) {
+ printf("no response\n");
+ return -1;
+ }
+
+ if (rsp->ccode) {
+ printf("returned CC code 0x%02x\n", rsp->ccode);
+ return -1;
+ }
+ if (rsp->data[0] != 0x00) {
+ printf("Error: not the PICMG identifier (%x)\n", rsp->data[0]);
+ return -1;
+ }
+ return 0;
+}
+
+
int
ipmi_picmg_portstate_get(struct ipmi_intf * intf, int argc, char ** argv)
{
@@ -608,11 +742,10 @@
else if (!strncmp(argv[0], "policy", 6)) {
if (argc > 2) {
if (!strncmp(argv[1], "get", 3)) {
- rc = ipmi_picmg_fru_activation_policy_get(intf, argc-1, &(argv[2]));
+ rc = ipmi_picmg_fru_activation_policy_get(intf, argc-2, &(argv[2]));
}
else if (!strncmp(argv[1], "set", 6)) {
- printf("tbd\n");
- return -1;
+ rc = ipmi_picmg_fru_activation_policy_set(intf, argc-2, &(argv[2]));
}
else {
printf("specify fru\n");
@@ -624,6 +757,20 @@
}
}
+ /* control command */
+ else if (!strncmp(argv[0], "control", 6)) {
+ if (argc > 2) {
+ rc = ipmi_picmg_fru_control(intf, argc-1, &(argv[1]));
+ } else {
+ printf("<FRU> {cr|wr|gr|idi}\n");
+ printf("cr: Cold Reset\n");
+ printf("wr: Warm Reset\n");
+ printf("gr: Graceful Reboot\n");
+ printf("idi: Issue Diagnostic Interrupt\n");
+ return -1;
+ }
+ }
+
/* portstate command */
else if (!strncmp(argv[0], "portstate", 9)) {
if (argc > 2) {
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Ipmitool-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel