fence-agents: master - fence_zvm: Add support for --delay in fence_zvm
Marek GrĂ¡c
marx at fedoraproject.org
Wed May 21 13:26:54 UTC 2014
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=260bc9c02dd7f46271dc0df438194d20656a6a5a
Commit: 260bc9c02dd7f46271dc0df438194d20656a6a5a
Parent: 09ced953ea11599d3b59ebf0c038c04f82a14d18
Author: Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate: Wed May 21 15:25:59 2014 +0200
Committer: Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Wed May 21 15:25:59 2014 +0200
fence_zvm: Add support for --delay in fence_zvm
Patch by: Neale Ferguson
---
fence/agents/zvm/fence_zvm.8 | 5 ++++-
fence/agents/zvm/fence_zvm.c | 38 ++++++++++++++++++++++++++++++++++++--
fence/agents/zvm/fence_zvm.h | 1 +
fence/agents/zvm/fence_zvmip.8 | 3 +++
fence/agents/zvm/fence_zvmip.c | 26 ++++++++++++++++++++++++++
5 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/fence/agents/zvm/fence_zvm.8 b/fence/agents/zvm/fence_zvm.8
index 2c54e75..0b34e2c 100644
--- a/fence/agents/zvm/fence_zvm.8
+++ b/fence/agents/zvm/fence_zvm.8
@@ -24,6 +24,9 @@ Vendor URL: http://www.sinenomine.net
\fB-o --action\fP
Fencing action: "off" - fence off device; "metadata" - display device metadata
.TP
+\fB--delay\fP \fIseconds\fP
+Time to delay fencing action in seconds
+.TP
\fB-n --plug\fP \fItarget\fP
Name of virtual machine to recycle.
.TP
@@ -31,7 +34,7 @@ Name of virtual machine to recycle.
Print out a help message describing available options, then exit.
.TP
\fB-a --ip\fP \fIsmapi Server\fP
-\fBName\fP of SMAPI server virtual machine. To be consistent with other fence agents thisname is a little misleading: it is the name of the virtual machine not its IP address or hostname.
+\fBName\fP of SMAPI server virtual machine. To be consistent with other fence agents this name is a little misleading: it is the name of the virtual machine not its IP address or hostname.
.TP
\fB--zvmsys\fP \fIz/VM System\fP
\fBName\fP of z/VM on which the SMAPI server virtual machine resides. Optional - defaults to system on which the node is running.
diff --git a/fence/agents/zvm/fence_zvm.c b/fence/agents/zvm/fence_zvm.c
index 6fbbb12..d2fb4a9 100644
--- a/fence/agents/zvm/fence_zvm.c
+++ b/fence/agents/zvm/fence_zvm.c
@@ -49,11 +49,13 @@
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define DEFAULT_TIMEOUT 300
+#define DEFAULT_DELAY 0
static int zvm_smapi_reportError(void *, void *);
static struct option longopts[] = {
{"action", required_argument, NULL, 'o'},
+ {"delay", required_argument, NULL, 'h'},
{"help", no_argument, NULL, 'h'},
{"ip", required_argument, NULL, 'a'},
{"plug", required_argument, NULL, 'n'},
@@ -136,6 +138,12 @@ zvm_smapi_imageRecycle(zvm_driver_t *zvm)
uint32_t reqId;
int rc;
+ /*
+ * Implement any delay
+ */
+ if (zvm->delay > 0)
+ sleep(zvm->delay);
+
lInPlist = sizeof(*inPlist) + strlen(zvm->target);
inPlist = malloc(lInPlist);
if (inPlist != NULL) {
@@ -388,6 +396,13 @@ zvm_metadata()
"Fencing action");
fprintf (stdout, "\t</parameter>\n");
+ fprintf (stdout, "\t<parameter name=\"delay\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t\t<getopt mixed=\"--delay\" />\n");
+ fprintf (stdout, "\t\t<content type=\"string\" default=\"0\" />\n");
+ fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
+ "Time to delay fencing action in seconds");
+ fprintf (stdout, "\t</parameter>\n");
+
fprintf (stdout, "\t<parameter name=\"usage\" unique=\"1\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-h, --help\" />\n");
fprintf (stdout, "\t\t<content type=\"boolean\" />\n");
@@ -466,13 +481,21 @@ get_options_stdin (zvm_driver_t *zvm)
if (*endPtr != 0) {
syslog(LOG_WARNING, "Invalid timeout value specified %s "
"defaulting to %d",
- arg, DEFAULT_TIMEOUT);
- zvm->timeOut = DEFAULT_TIMEOUT;
+ arg, DEFAULT_DELAY);
+ zvm->timeOut = DEFAULT_DELAY;
}
} else if (!strcasecmp (opt, "zvmsys")) {
lSrvNode = MIN(strlen(arg), sizeof(zvm->node));
memcpy(zvm->node, arg, lSrvNode);
continue;
+ } else if (!strcasecmp (opt, "delay")) {
+ zvm->delay = strtoul(arg, &endPtr, 10);
+ if (*endPtr != 0) {
+ syslog(LOG_WARNING, "Invalid delay value specified %s "
+ "defaulting to %d",
+ arg, DEFAULT_DELAY);
+ zvm->delay = DEFAULT_DELAY;
+ }
} else if (!strcasecmp (opt, "help")) {
fence = 2;
}
@@ -525,6 +548,15 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
zvm->timeOut = DEFAULT_TIMEOUT;
}
break;
+ case 'd' :
+ zvm->delay = strtoul(optarg, &endPtr, 10);
+ if (*endPtr != 0) {
+ syslog(LOG_WARNING, "Invalid delay value specified: %s - "
+ "defaulting to %d",
+ optarg, DEFAULT_DELAY);
+ zvm->delay = DEFAULT_DELAY;
+ }
+ break;
case 'z' :
lSrvNode = MIN(strlen(optarg), sizeof(zvm->node));
memcpy(zvm->node, optarg, lSrvNode);
@@ -546,6 +578,7 @@ usage()
fprintf(stderr,"Usage: fence_zvm [options]\n\n"
"\tWhere [options] =\n"
"\t-o --action [action] - \"off\", \"metadata\"\n"
+ "\t--delay [seconds] - Time to delay fencing action in seconds\n"
"\t-n --plug [target] - Name of virtual machine to fence\n"
"\t-a --ip [server] - Name of SMAPI IUCV Request server\n"
"\t-T --timeout [secs] - Time to wait for fence in seconds - currently ignored\n"
@@ -588,6 +621,7 @@ main(int argc, char **argv)
openlog ("fence_zvm", LOG_CONS|LOG_PID, LOG_DAEMON);
memset(&zvm, 0, sizeof(zvm));
zvm.timeOut = DEFAULT_TIMEOUT;
+ zvm.delay = DEFAULT_DELAY;
if (argc > 1)
fence = get_options(argc, argv, &zvm);
diff --git a/fence/agents/zvm/fence_zvm.h b/fence/agents/zvm/fence_zvm.h
index 0a86af3..6178fa5 100644
--- a/fence/agents/zvm/fence_zvm.h
+++ b/fence/agents/zvm/fence_zvm.h
@@ -562,6 +562,7 @@ typedef struct {
int sd;
int reason;
uint32_t timeOut;
+ uint32_t delay;
char target[9];
char authUser[9];
char authPass[9];
diff --git a/fence/agents/zvm/fence_zvmip.8 b/fence/agents/zvm/fence_zvmip.8
index 222b483..0bf91ae 100644
--- a/fence/agents/zvm/fence_zvmip.8
+++ b/fence/agents/zvm/fence_zvmip.8
@@ -24,6 +24,9 @@ Vendor URL: http://www.sinenomine.net
\fB-o --action\fP
Fencing action: "off" - fence off device; "metadata" - display device metadata
.TP
+\fB--delay\fP \fIseconds\fP
+Time to delay fencing action in seconds
+.TP
\fB-n --plug\fP \fItarget\fP
Name of target virtual machine to fence
.TP
diff --git a/fence/agents/zvm/fence_zvmip.c b/fence/agents/zvm/fence_zvmip.c
index 28c9726..f4dcd1c 100644
--- a/fence/agents/zvm/fence_zvmip.c
+++ b/fence/agents/zvm/fence_zvmip.c
@@ -48,11 +48,13 @@
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define DEFAULT_TIMEOUT 300
+#define DEFAULT_DELAY 0
static int zvm_smapi_reportError(void *, void *);
static struct option longopts[] = {
{"action", required_argument, NULL, 'o'},
+ {"delay", required_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"ipaddr", required_argument, NULL, 'a'},
{"password", required_argument, NULL, 'p'},
@@ -142,6 +144,12 @@ zvm_smapi_imageRecycle(zvm_driver_t *zvm)
uint32_t reqId;
int rc;
+ /*
+ * Implement any delay
+ */
+ if (zvm->delay > 0)
+ sleep(zvm->delay);
+
lInPlist = sizeof(*inPlist) + sizeof(*authUser) + strlen(zvm->authUser) +
sizeof(*authPass) + strlen(zvm->authPass) + sizeof(*image) +
+ strlen(zvm->target);
@@ -487,6 +495,15 @@ get_options(int argc, char **argv, zvm_driver_t *zvm)
zvm->timeOut = DEFAULT_TIMEOUT;
}
break;
+ case 'd' :
+ zvm->delay = strtoul(optarg, &endPtr, 10);
+ if (*endPtr != 0) {
+ syslog(LOG_WARNING, "Invalid delay value specified: %s - "
+ "defaulting to %d",
+ optarg, DEFAULT_DELAY);
+ zvm->delay = DEFAULT_DELAY;
+ }
+ break;
default :
fence = 2;
}
@@ -546,6 +563,13 @@ zvm_metadata()
"Fencing action");
fprintf (stdout, "\t</parameter>\n");
+ fprintf (stdout, "\t<parameter name=\"delay\" unique=\"1\" required=\"0\">\n");
+ fprintf (stdout, "\t\t<getopt mixed=\"--delay\" />\n");
+ fprintf (stdout, "\t\t<content type=\"string\" default=\"0\" />\n");
+ fprintf (stdout, "\t\t<shortdesc lang=\"en\">%s</shortdesc>\n",
+ "Time to delay fencing action in seconds");
+ fprintf (stdout, "\t</parameter>\n");
+
fprintf (stdout, "\t<parameter name=\"usage\" unique=\"1\" required=\"0\">\n");
fprintf (stdout, "\t\t<getopt mixed=\"-h, --help\" />\n");
fprintf (stdout, "\t\t<content type=\"boolean\" />\n");
@@ -576,6 +600,7 @@ usage()
fprintf(stderr,"Usage: fence_zvmip [options]\n\n"
"\tWhere [options] =\n"
"\t-o --action [action] - \"off\", \"metadata\"\n"
+ "\t--delay [seconds] - Time to delay fencing action in seconds\n"
"\t-n --plug [target] - Name of virtual machine to fence\n"
"\t-a --ip [server] - IP Name/Address of SMAPI Server\n"
"\t-u --username [user] - Name of autorized SMAPI user\n"
@@ -629,6 +654,7 @@ main(int argc, char **argv)
openlog ("fence_zvmip", LOG_CONS|LOG_PID, LOG_DAEMON);
memset(&zvm, 0, sizeof(zvm));
zvm.timeOut = DEFAULT_TIMEOUT;
+ zvm.delay = DEFAULT_DELAY;
if (argc > 1)
fence = get_options(argc, argv, &zvm);
More information about the cluster-commits
mailing list