Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 24e278e14a25367b8cb2fce8af484abd > files > 99

cman-2.0.115-96.el5_8.3.src.rpm

From f71c978b9e467b40abf4cf692a636956c827e60f Mon Sep 17 00:00:00 2001
From: Marek 'marx' Grac <mgrac@redhat.com>
Date: Thu, 13 Jan 2011 14:07:50 +0100
Subject: [PATCH 1/2] fence_ipmilan: Add "diag" option to support "ipmitool chassis power diag"

Resolves: rhbz#678061
---
 fence/agents/ipmilan/ipmilan.c |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index 2f46078..4371143 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -52,6 +52,7 @@ do { \
 #define ST_POWEROFF 2
 #define ST_GENERIC_RESET 3
 #define ST_CYCLE 4
+#define ST_DIAG 5
 
 #define DEFAULT_TIMEOUT 20
 #define DEFAULT_POWER_WAIT 2
@@ -198,7 +199,7 @@ struct xml_parameter_s xml_parameters[]={
   {"passwd_script","-S",0,"string",NULL,"Script to retrieve password (if required)"},
   {"lanplus","-P",0,"boolean",NULL,"Use Lanplus"},
   {"login","-l",0,"string",NULL,"Username/Login (if required) to control power on IPMI device"},
-  {"action","-o",0,"string","reboot","Operation to perform. Valid operations: on, off, reboot, status, list, monitor or metadata"},
+  {"action","-o",0,"string","reboot","Operation to perform. Valid operations: on, off, reboot, status, list, diag, monitor or metadata"},
   {"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)"},
@@ -337,6 +338,10 @@ build_cmd(char *command, size_t cmdlen, struct ipmi *ipmi, int op)
 		snprintf(arg, sizeof(arg),
 			 "%s chassis power cycle", cmd);
 		break;
+	case ST_DIAG:
+		snprintf(arg, sizeof(arg),
+			 "%s chassis power diag", cmd);
+		break;
 	}
 
 	strncpy(command, arg, cmdlen);
@@ -554,6 +559,16 @@ ipmi_cycle(struct ipmi *ipmi)
 	return ret;
 }
 
+static int
+ipmi_diag(struct ipmi *ipmi)
+{
+	int ret;
+	
+	ret = ipmi_op(ipmi, ST_DIAG, power_off_complete);
+	
+	return ret;
+}
+
 
 /**
   Squash all our private data
@@ -1068,7 +1083,8 @@ printf("   -S <path>      Script to retrieve password (if required)\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, status, list or monitor\n");
+printf("                  Valid operations: on, off, reboot, status,\n");
+printf("                  diag, list or monitor\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("   -f <timeout>   Wait X seconds before fencing is started\n");
@@ -1136,6 +1152,7 @@ void print_xml_metadata(char *pname) {
   printf("\t<action name=\"%s\" />\n", "off");
   printf("\t<action name=\"%s\" />\n", "reboot");
   printf("\t<action name=\"%s\" />\n", "status");
+  printf("\t<action name=\"%s\" />\n", "diag");
   printf("\t<action name=\"%s\" />\n", "list");
   printf("\t<action name=\"%s\" />\n", "monitor");
   printf("\t<action name=\"%s\" />\n", "metadata");
@@ -1308,9 +1325,9 @@ main(int argc, char **argv)
 	if (strcasecmp(op, "off") && strcasecmp(op, "on") &&
 	    strcasecmp(op, "status") && strcasecmp(op, "reboot") &&
 	    strcasecmp(op, "monitor") && strcasecmp(op, "list") &&
-	    strcasecmp(op, "metadata")) {
+	    strcasecmp(op, "metadata") && strcasecmp(op, "diag")) {
 		fail_exit("operation must be 'on', 'off', 'status', "
-			  "'reboot', 'list', 'monitor' or 'metadata'");
+			  "'reboot', 'diag', 'list', 'monitor' or 'metadata'");
 	}
 
 	if (strlen(authtype) &&
@@ -1408,6 +1425,12 @@ main(int argc, char **argv)
 	  ret=0;
 	  translated_ret = ERR_OK;
 	  print_final_status=0;
+	} else if (!strcasecmp(op, "diag")) {
+	  printf("Pulsing diagnostic interrupt to machine @ IPMI:%s...", ip);
+	  fflush(stdout);
+	  ret = ipmi_diag(i);
+	  translated_ret = (ret==0?ERR_ON_SUCCESSFUL:ERR_ON_FAIL);
+	  ret = 0;
 	}
 
 
-- 
1.7.4