Blame SOURCES/bz1140921-3-fence_zvm.patch

e4ffb1
commit c5ed2256e572bd06e8bf4ca00d6c891424ae4b00
e4ffb1
Author: Marek 'marx' Grac <mgrac@redhat.com>
e4ffb1
Date:   Thu Oct 23 16:33:26 2014 +0200
e4ffb1
e4ffb1
    fence_zvm: Add support for 'monitor'
e4ffb1
    
e4ffb1
    Author: Neale Ferguson
e4ffb1
e4ffb1
diff --git a/fence/agents/zvm/fence_zvm.c b/fence/agents/zvm/fence_zvm.c
e4ffb1
index 524e21e..2f82e25 100644
e4ffb1
--- a/fence/agents/zvm/fence_zvm.c
e4ffb1
+++ b/fence/agents/zvm/fence_zvm.c
e4ffb1
@@ -51,6 +51,15 @@
e4ffb1
 #define DEFAULT_TIMEOUT 300
e4ffb1
 #define DEFAULT_DELAY   0
e4ffb1
 
e4ffb1
+#define ACT_OFFON 	0
e4ffb1
+#define ACT_OFF		1
e4ffb1
+#define ACT_ON		2
e4ffb1
+#define ACT_METADATA	3
e4ffb1
+#define ACT_STATUS	4
e4ffb1
+#define ACT_MONITOR	5
e4ffb1
+#define ACT_LIST	6
e4ffb1
+#define ACT_HELP	7
e4ffb1
+
e4ffb1
 static int zvm_smapi_reportError(void *, void *);
e4ffb1
 
e4ffb1
 static struct option longopts[] = {
e4ffb1
@@ -64,7 +73,7 @@ static struct option longopts[] = {
e4ffb1
 	{NULL,		0,			NULL, 0}
e4ffb1
 };
e4ffb1
 
e4ffb1
-static char *optString = "a:ho:n:T:";
e4ffb1
+static const char *optString = "a:ho:n:T:";
e4ffb1
 
e4ffb1
 static int zvm_metadata(void);
e4ffb1
 static int usage(void);
e4ffb1
@@ -323,8 +332,7 @@ zvm_smapi_imageActivate(zvm_driver_t *zvm)
e4ffb1
 					rc = 0;
e4ffb1
 				} else {
e4ffb1
 					if ((outPlist->hdr.rc == RCERR_IMAGEOP) &
e4ffb1
-					    ((outPlist->hdr.reason == RS_NOT_ACTIVE) |
e4ffb1
-					     (outPlist->hdr.reason == RS_BEING_DEACT))) {
e4ffb1
+					     (outPlist->hdr.reason == RS_ALREADY_ACTIVE)) {
e4ffb1
 						syslog(LOG_INFO, "Activation of %s successful",
e4ffb1
 						       zvm->target);
e4ffb1
 						rc = 0;
e4ffb1
@@ -649,8 +657,11 @@ zvm_metadata()
e4ffb1
 
e4ffb1
 	fprintf (stdout, "<actions>\n");
e4ffb1
 	fprintf (stdout, "\t<action name=\"off\" />\n");
e4ffb1
-	fprintf (stdout, "\t<action name=\"on\" />\n");
e4ffb1
+	fprintf (stdout, "\t<action name=\"on\" automatic=\"0\" />\n");
e4ffb1
+	fprintf (stdout, "\t<action name=\"list\" />\n");
e4ffb1
 	fprintf (stdout, "\t<action name=\"metadata\" />\n");
e4ffb1
+	fprintf (stdout, "\t<action name=\"monitor\" />\n");
e4ffb1
+	fprintf (stdout, "\t<action name=\"reboot\" />\n");
e4ffb1
 	fprintf (stdout, "\t<action name=\"status\" />\n");
e4ffb1
 	fprintf (stdout, "</actions>\n");
e4ffb1
 
e4ffb1
@@ -675,7 +686,7 @@ get_options_stdin (zvm_driver_t *zvm)
e4ffb1
 	int32_t lSrvName,
e4ffb1
 		lSrvNode,
e4ffb1
 		lTarget;
e4ffb1
-	int	fence = 0;
e4ffb1
+	int	fence = ACT_OFFON;
e4ffb1
 
e4ffb1
 	while (fgets (buf, sizeof (buf), stdin) != 0) {
e4ffb1
 		if (trim(buf) == 0) {
e4ffb1
@@ -698,16 +709,22 @@ get_options_stdin (zvm_driver_t *zvm)
e4ffb1
 			continue;
e4ffb1
 
e4ffb1
 		if (!strcasecmp (opt, "action")) {
e4ffb1
-			if (strcasecmp(arg, "off") == 0) {
e4ffb1
-				fence = 1;
e4ffb1
+			if (strcasecmp(arg, "reboot") == 0) {
e4ffb1
+				fence = ACT_OFFON;
e4ffb1
+			} else if (strcasecmp(arg, "off") == 0) {
e4ffb1
+				fence = ACT_OFF;
e4ffb1
 			} else if (strcasecmp(arg, "on") == 0) {
e4ffb1
-				fence = 2;
e4ffb1
+				fence = ACT_ON;
e4ffb1
 			} else if (strcasecmp(arg, "metadata") == 0) {
e4ffb1
-				fence = 3;
e4ffb1
+				fence = ACT_METADATA;
e4ffb1
 			} else if (strcasecmp(arg, "status") == 0) {
e4ffb1
-				fence = 4;
e4ffb1
+				fence = ACT_STATUS;
e4ffb1
+			} else if (strcasecmp(arg, "monitor") == 0) {
e4ffb1
+				fence = ACT_MONITOR;
e4ffb1
+			} else if (strcasecmp(arg, "list") == 0) {
e4ffb1
+				fence = ACT_LIST;
e4ffb1
 			} else {
e4ffb1
-				fence = 5;
e4ffb1
+				fence = ACT_HELP;
e4ffb1
 			}
e4ffb1
 		} else if (!strcasecmp (opt, "ipaddr")) {
e4ffb1
 			lSrvName = MIN(strlen(arg), sizeof(zvm->smapiSrv));
e4ffb1
@@ -738,7 +755,7 @@ get_options_stdin (zvm_driver_t *zvm)
e4ffb1
 				zvm->delay = DEFAULT_DELAY;
e4ffb1
 			}
e4ffb1
 		} else if (!strcasecmp (opt, "help")) {
e4ffb1
-			fence = 5;
e4ffb1
+			fence = ACT_HELP;
e4ffb1
 		}
e4ffb1
 	}
e4ffb1
 	return(fence);
e4ffb1
@@ -755,7 +772,7 @@ static int
e4ffb1
 get_options(int argc, char **argv, zvm_driver_t *zvm)
e4ffb1
 {
e4ffb1
 	int	c,
e4ffb1
-		fence = 0;
e4ffb1
+		fence = ACT_OFFON;
e4ffb1
 	int32_t	lSrvName,
e4ffb1
 		lSrvNode,
e4ffb1
 		lTarget;
e4ffb1
@@ -768,16 +785,22 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
e4ffb1
 			memcpy(zvm->target, optarg, lTarget);
e4ffb1
 			break;
e4ffb1
 		case 'o' :
e4ffb1
-			if (strcasecmp(optarg, "off") == 0) {
e4ffb1
-				fence = 1;
e4ffb1
+			if (strcasecmp(optarg, "reboot") == 0) {
e4ffb1
+				fence = ACT_OFFON;
e4ffb1
+			} else if (strcasecmp(optarg, "off") == 0) {
e4ffb1
+				fence = ACT_OFF;
e4ffb1
 			} else if (strcasecmp(optarg, "on") == 0) {
e4ffb1
-				fence = 2;
e4ffb1
+				fence = ACT_ON;
e4ffb1
 			} else if (strcasecmp(optarg, "metadata") == 0) {
e4ffb1
-				fence = 3;
e4ffb1
+				fence = ACT_METADATA;
e4ffb1
 			} else if (strcasecmp(optarg, "status") == 0) {
e4ffb1
-				fence = 4;
e4ffb1
+				fence = ACT_STATUS;
e4ffb1
+			} else if (strcasecmp(optarg, "monitor") == 0) {
e4ffb1
+				fence = ACT_MONITOR;
e4ffb1
+			} else if (strcasecmp(optarg, "list") == 0) {
e4ffb1
+				fence = ACT_LIST;
e4ffb1
 			} else {
e4ffb1
-				fence = 5;
e4ffb1
+				fence = ACT_HELP;
e4ffb1
 			}
e4ffb1
 			break;
e4ffb1
 		case 'a' :
e4ffb1
@@ -807,7 +830,7 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
e4ffb1
 			memcpy(zvm->node, optarg, lSrvNode);
e4ffb1
 			break;
e4ffb1
 		default :
e4ffb1
-			fence = 5;
e4ffb1
+			fence = ACT_HELP;
e4ffb1
 		}
e4ffb1
 	}
e4ffb1
 	return(fence);
e4ffb1
@@ -822,7 +845,8 @@ usage()
e4ffb1
 {
e4ffb1
 	fprintf(stderr,"Usage: fence_zvm [options]\n\n"
e4ffb1
 		"\tWhere [options] =\n"
e4ffb1
-		"\t-o --action [action] - \"off\", \"on\", \"metadata\", \"status\"\n"
e4ffb1
+		"\t-o --action [action] - \"off\", \"on\", \"list\", \"metadata\", "
e4ffb1
+					 "\"monitor\", \"reboot\", \"status\"\n"
e4ffb1
 		"\t--delay [seconds]    - Time to delay fencing action in seconds\n"
e4ffb1
 		"\t-n --plug [target]   - Name of virtual machine to fence\n"
e4ffb1
 		"\t-a --ip [server]     - Name of SMAPI IUCV Request server\n"
e4ffb1
@@ -874,26 +898,33 @@ main(int argc, char **argv)
e4ffb1
 		fence = get_options_stdin(&zvm);
e4ffb1
 
e4ffb1
 	switch(fence) {
e4ffb1
-		case 0 :	// OFFON
e4ffb1
+		case ACT_OFFON :	// OFFON
e4ffb1
 			if ((rc = check_parm(&zvm)) == 0) 
e4ffb1
 				rc = zvm_smapi_imageRecycle(&zvm);
e4ffb1
 			break;
e4ffb1
-		case 1 :	// OFF
e4ffb1
+		case ACT_OFF :		// OFF
e4ffb1
 			if ((rc = check_parm(&zvm)) == 0)
e4ffb1
 				rc = zvm_smapi_imageDeactivate(&zvm);
e4ffb1
 			break;
e4ffb1
-		case 2 :	// ON
e4ffb1
+		case ACT_ON :		// ON
e4ffb1
 			if ((rc = check_parm(&zvm)) == 0)
e4ffb1
 				rc = zvm_smapi_imageActivate(&zvm);
e4ffb1
 			break;
e4ffb1
-		case 3 :	// METADATA
e4ffb1
+		case ACT_METADATA :	// METADATA
e4ffb1
 			rc = zvm_metadata();
e4ffb1
 			break;
e4ffb1
-		case 4 :	// STATUS
e4ffb1
+		case ACT_STATUS :	// STATUS
e4ffb1
 			if ((rc = check_parm(&zvm)) == 0)
e4ffb1
 				rc = zvm_smapi_imageQuery(&zvm);
e4ffb1
 			break;
e4ffb1
-		case 5 :
e4ffb1
+		case ACT_MONITOR :	// MONITOR
e4ffb1
+			rc = 0;
e4ffb1
+			break;
e4ffb1
+		case ACT_LIST :		// LIST
e4ffb1
+			printf("N/A");
e4ffb1
+			rc = 0;
e4ffb1
+			break;
e4ffb1
+		case ACT_HELP :
e4ffb1
 			rc = usage();
e4ffb1
 	}
e4ffb1
 	closelog();
e4ffb1
diff --git a/fence/agents/zvm/fence_zvmip.c b/fence/agents/zvm/fence_zvmip.c
e4ffb1
index bd7c536..b16de48 100644
e4ffb1
--- a/fence/agents/zvm/fence_zvmip.c
e4ffb1
+++ b/fence/agents/zvm/fence_zvmip.c
e4ffb1
@@ -50,6 +50,15 @@
e4ffb1
 #define DEFAULT_TIMEOUT 300
e4ffb1
 #define DEFAULT_DELAY	0
e4ffb1
 
e4ffb1
+#define ACT_OFFON 	0
e4ffb1
+#define ACT_OFF		1
e4ffb1
+#define ACT_ON		2
e4ffb1
+#define ACT_METADATA	3
e4ffb1
+#define ACT_STATUS	4
e4ffb1
+#define ACT_MONITOR	5
e4ffb1
+#define ACT_LIST	6
e4ffb1
+#define ACT_HELP	7
e4ffb1
+
e4ffb1
 static int zvm_smapi_reportError(void *, void *);
e4ffb1
 
e4ffb1
 static struct option longopts[] = {
e4ffb1
@@ -64,7 +73,7 @@ static struct option longopts[] = {
e4ffb1
 	{NULL,		0,			NULL, 0}
e4ffb1
 };
e4ffb1
 
e4ffb1
-static char *optString = "a:o:hn:p:t:u:";
e4ffb1
+static const char *optString = "a:o:hn:p:t:u:";
e4ffb1
 
e4ffb1
 static int zvm_metadata(void);
e4ffb1
 static int usage(void);
e4ffb1
@@ -376,8 +385,7 @@ zvm_smapi_imageActivate(zvm_driver_t *zvm)
e4ffb1
 					rc = 0;
e4ffb1
 				} else {
e4ffb1
 					if ((outPlist->hdr.rc == RCERR_IMAGEOP) &
e4ffb1
-					    ((outPlist->hdr.reason == RS_NOT_ACTIVE) |
e4ffb1
-					     (outPlist->hdr.reason == RS_BEING_DEACT))) {
e4ffb1
+					     (outPlist->hdr.reason == RS_ALREADY_ACTIVE)) {
e4ffb1
 						syslog(LOG_INFO, "Activation of %s successful",
e4ffb1
 						       zvm->target);
e4ffb1
 						rc = 0;
e4ffb1
@@ -653,7 +661,7 @@ get_options_stdin (zvm_driver_t *zvm)
e4ffb1
 		*arg;
e4ffb1
 	int32_t lSrvName,
e4ffb1
 		lTarget;
e4ffb1
-	int	fence = 0;
e4ffb1
+	int	fence = ACT_OFFON;
e4ffb1
 
e4ffb1
 	while (fgets (buf, sizeof (buf), stdin) != 0) {
e4ffb1
 		if (trim(buf) == 0) {
e4ffb1
@@ -676,16 +684,22 @@ get_options_stdin (zvm_driver_t *zvm)
e4ffb1
 			continue;
e4ffb1
 
e4ffb1
 		if (!strcasecmp (opt, "action")) {
e4ffb1
-			if (strcasecmp(arg, "off") == 0) {
e4ffb1
-				fence = 1;
e4ffb1
+			if (strcasecmp(arg, "reboot") == 0) {
e4ffb1
+				fence = ACT_OFFON;
e4ffb1
+			} else if (strcasecmp(arg, "off") == 0) {
e4ffb1
+				fence = ACT_OFF;
e4ffb1
 			} else if (strcasecmp(arg, "on") == 0) {
e4ffb1
-				fence = 2;
e4ffb1
+				fence = ACT_ON;
e4ffb1
 			} else if (strcasecmp(arg, "metadata") == 0) {
e4ffb1
-				fence = 3;
e4ffb1
+				fence = ACT_METADATA;
e4ffb1
 			} else if (strcasecmp(arg, "status") == 0) {
e4ffb1
-				fence = 4;
e4ffb1
+				fence = ACT_STATUS;
e4ffb1
+			} else if (strcasecmp(arg, "monitor") == 0) {
e4ffb1
+				fence = ACT_MONITOR;
e4ffb1
+			} else if (strcasecmp(arg, "list") == 0) {
e4ffb1
+				fence = ACT_LIST;
e4ffb1
 			} else {
e4ffb1
-				fence = 5;
e4ffb1
+				fence = ACT_HELP;
e4ffb1
 			}
e4ffb1
 		} else if (!strcasecmp (opt, "ipaddr")) {
e4ffb1
 			lSrvName = MIN(strlen(arg), sizeof(zvm->smapiSrv)-1);
e4ffb1
@@ -712,7 +726,7 @@ get_options_stdin (zvm_driver_t *zvm)
e4ffb1
 				zvm->timeOut = DEFAULT_TIMEOUT;
e4ffb1
 			}
e4ffb1
 		} else if (!strcasecmp (opt, "help")) {
e4ffb1
-			fence = 5;
e4ffb1
+			fence = ACT_HELP;
e4ffb1
 		}
e4ffb1
 	}
e4ffb1
 	return(fence);
e4ffb1
@@ -729,7 +743,7 @@ static int
e4ffb1
 get_options(int argc, char **argv, zvm_driver_t *zvm)
e4ffb1
 {
e4ffb1
 	int	c,
e4ffb1
-		fence = 0;
e4ffb1
+		fence = ACT_OFFON;
e4ffb1
 	int32_t	lSrvName,
e4ffb1
 		lTarget;
e4ffb1
 	char	*endPtr;
e4ffb1
@@ -745,16 +759,22 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
e4ffb1
 			memcpy(zvm->target, optarg, lTarget);
e4ffb1
 			break;
e4ffb1
 		case 'o' :
e4ffb1
-			if (strcasecmp(optarg, "off") == 0) {
e4ffb1
-				fence = 1;
e4ffb1
+			if (strcasecmp(optarg, "reboot") == 0) {
e4ffb1
+				fence = ACT_OFFON;
e4ffb1
+			} else if (strcasecmp(optarg, "off") == 0) {
e4ffb1
+				fence = ACT_OFF;
e4ffb1
 			} else if (strcasecmp(optarg, "on") == 0) {
e4ffb1
-				fence = 2;
e4ffb1
+				fence = ACT_ON;
e4ffb1
 			} else if (strcasecmp(optarg, "metadata") == 0) {
e4ffb1
-				fence = 3;
e4ffb1
+				fence = ACT_METADATA;
e4ffb1
 			} else if (strcasecmp(optarg, "status") == 0) {
e4ffb1
-				fence = 4;
e4ffb1
+				fence = ACT_STATUS;
e4ffb1
+			} else if (strcasecmp(optarg, "monitor") == 0) {
e4ffb1
+				fence = ACT_MONITOR;
e4ffb1
+			} else if (strcasecmp(optarg, "list") == 0) {
e4ffb1
+				fence = ACT_LIST;
e4ffb1
 			} else {
e4ffb1
-				fence = 5;
e4ffb1
+				fence = ACT_HELP;
e4ffb1
 			}
e4ffb1
 			break;
e4ffb1
 		case 'p' :
e4ffb1
@@ -784,7 +804,7 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
e4ffb1
 			}
e4ffb1
 			break;
e4ffb1
 		default :
e4ffb1
-			fence = 5;
e4ffb1
+			fence = ACT_HELP;
e4ffb1
 		}
e4ffb1
 	}
e4ffb1
 	return(fence);
e4ffb1
@@ -861,9 +881,12 @@ zvm_metadata()
e4ffb1
 
e4ffb1
 	fprintf (stdout, "<actions>\n");
e4ffb1
 	fprintf (stdout, "\t<action name=\"off\" />\n");
e4ffb1
-	fprintf (stdout, "\t<action name=\"on\" />\n");
e4ffb1
+	fprintf (stdout, "\t<action name=\"on\" automatic=\"0\" />\n");
e4ffb1
+	fprintf (stdout, "\t<action name=\"list\" />\n");
e4ffb1
 	fprintf (stdout, "\t<action name=\"metadata\" />\n");
e4ffb1
+	fprintf (stdout, "\t<action name=\"monitor\" />\n");
e4ffb1
 	fprintf (stdout, "\t<action name=\"status\" />\n");
e4ffb1
+	fprintf (stdout, "\t<action name=\"reboot\" />\n");
e4ffb1
 	fprintf (stdout, "</actions>\n");
e4ffb1
 
e4ffb1
 	fprintf (stdout, "</resource-agent>\n");
e4ffb1
@@ -881,7 +904,8 @@ usage()
e4ffb1
 {
e4ffb1
 	fprintf(stderr,"Usage: fence_zvmip [options]\n\n"
e4ffb1
 		"\tWhere [options] =\n"
e4ffb1
-		"\t-o --action [action] - \"off\", \"on\", \"metadata\", \"status\"\n"
e4ffb1
+		"\t-o --action [action] - \"off\", \"on\", \"list\", \"metadata\", "
e4ffb1
+					 "\"monitor\", \"reboot\", \"status\"\n"
e4ffb1
 		"\t--delay [seconds]    - Time to delay fencing action in seconds\n"
e4ffb1
 		"\t-n --plug [target]   - Name of virtual machine to fence\n"
e4ffb1
 		"\t-a --ip [server]     - IP Name/Address of SMAPI Server\n"
e4ffb1
@@ -944,26 +968,32 @@ main(int argc, char **argv)
e4ffb1
 		fence = get_options_stdin(&zvm);
e4ffb1
 
e4ffb1
 	switch(fence) {
e4ffb1
-		case 0 :	// OFFON
e4ffb1
+		case ACT_OFFON :	// OFFON
e4ffb1
 			if ((rc = check_parm(&zvm)) == 0)
e4ffb1
 				rc = zvm_smapi_imageRecycle(&zvm);
e4ffb1
 			break;
e4ffb1
-		case 1 :	// OFF
e4ffb1
+		case ACT_OFF :		// OFF
e4ffb1
 			if ((rc = check_parm(&zvm)) == 0)
e4ffb1
 				rc = zvm_smapi_imageDeactivate(&zvm);
e4ffb1
 			break;
e4ffb1
-		case 2 :	// ON
e4ffb1
+		case ACT_ON :		// ON
e4ffb1
 			if ((rc = check_parm(&zvm)) == 0)
e4ffb1
 				rc = zvm_smapi_imageActivate(&zvm);
e4ffb1
 			break;
e4ffb1
-		case 3 :	// METADATA
e4ffb1
+		case ACT_METADATA :	// METADATA
e4ffb1
 			rc = zvm_metadata();
e4ffb1
 			break;
e4ffb1
-		case 4 :	// STATUS
e4ffb1
+		case ACT_STATUS :	// STATUS
e4ffb1
 			if ((rc = check_parm(&zvm)) == 0)
e4ffb1
 				rc = zvm_smapi_imageQuery(&zvm);
e4ffb1
 			break;
e4ffb1
-		case 5 :
e4ffb1
+		case ACT_MONITOR :	// MONITOR
e4ffb1
+			rc = 0;
e4ffb1
+			break;
e4ffb1
+		case ACT_LIST :
e4ffb1
+			printf("N/A");
e4ffb1
+			break;
e4ffb1
+		case ACT_HELP :
e4ffb1
 			rc = usage();
e4ffb1
 	}
e4ffb1
 	closelog();
e4ffb1
diff --git a/tests/data/metadata/fence_zvmip.xml b/tests/data/metadata/fence_zvmip.xml
e4ffb1
index 1e098d1..7791303 100644
e4ffb1
--- a/tests/data/metadata/fence_zvmip.xml
e4ffb1
+++ b/tests/data/metadata/fence_zvmip.xml
e4ffb1
@@ -41,8 +41,11 @@
e4ffb1
 </parameters>
e4ffb1
 <actions>
e4ffb1
 	<action name="off" />
e4ffb1
-	<action name="on" />
e4ffb1
+	<action name="on" automatic="0" />
e4ffb1
+	<action name="list" />
e4ffb1
 	<action name="metadata" />
e4ffb1
+	<action name="monitor" />
e4ffb1
 	<action name="status" />
e4ffb1
+	<action name="reboot" />
e4ffb1
 </actions>
e4ffb1
 </resource-agent>