From 286e0c61e4b88ad078bb151d6787278ea4d276e2 Mon Sep 17 00:00:00 2001 From: Ryan McCabe Date: Wed, 3 May 2017 23:22:34 -0400 Subject: [PATCH] fence_xvm/fence_virt: Add support for the validate-all status op Add support for the validate-all status operation. In this mode, the fence agent will validate the arguments given on either the command line or standard input. If validation succeeds, it will exit with code 0, otherwise it will exit with code 1. Resolves: rhbz#1447700 Signed-off-by: Ryan McCabe --- client/main.c | 10 +++++++--- client/options.c | 7 +++++-- include/xvm.h | 17 +++++++++-------- man/fence_virt.8 | 8 ++++++-- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/client/main.c b/client/main.c index ea4f937..6401bc7 100644 --- a/client/main.c +++ b/client/main.c @@ -114,13 +114,17 @@ main(int argc, char **argv) } if (args.flags & F_ERR) { - args_usage(argv[0], my_options, (argc == 1)); + if (args.op != FENCE_VALIDATEALL) + args_usage(argv[0], my_options, (argc == 1)); exit(1); } + if (args.op == FENCE_VALIDATEALL) + exit(0); + if (args.op == FENCE_METADATA) { args_metadata(argv[0], my_options); - return 0; + exit(0); } if (args.delay > 0 && @@ -186,5 +190,5 @@ main(int argc, char **argv) out: closelog(); - return ret; + exit(ret); } diff --git a/client/options.c b/client/options.c index 9813ba2..a1157b4 100644 --- a/client/options.c +++ b/client/options.c @@ -255,6 +255,8 @@ assign_op(fence_virt_args_t *args, struct arg_info *arg, char *value) args->op = FENCE_HOSTLIST; } else if (!strcasecmp(value, "metadata")) { args->op = FENCE_METADATA; + } else if (!strcasecmp(value, "validate-all")) { + args->op = FENCE_VALIDATEALL; } else { printf("Unsupported operation: %s\n", value); args->flags |= F_ERR; @@ -490,12 +492,12 @@ static struct arg_info _arg_info[] = { { '\xff', NULL, "option", /* Deprecated */ 0, "string", "reboot", - "Fencing option (null, off, on, [reboot], status, list, monitor, metadata)", + "Fencing option (null, off, on, [reboot], status, list, list-status, monitor, validate-all, metadata)", assign_op }, { 'o', "-o ", "action", 0, "string", "reboot", - "Fencing action (null, off, on, [reboot], status, list, monitor, metadata)", + "Fencing action (null, off, on, [reboot], status, list, list-status, monitor, validate-all, metadata)", assign_op }, { 'H', "-H ", "port", @@ -801,6 +803,7 @@ args_metadata(char *progname, const char *optstr) printf("\t\n"); printf("\t\n"); printf("\t\n"); + printf("\t\n"); printf("\n"); printf("\n"); } diff --git a/include/xvm.h b/include/xvm.h index b02c414..bcd7db2 100644 --- a/include/xvm.h +++ b/include/xvm.h @@ -52,14 +52,15 @@ typedef enum { #define DEFAULT_AUTH AUTH_SHA256 typedef enum { - FENCE_NULL = 0x0, - FENCE_OFF = 0x1, /* Turn the VM off */ - FENCE_REBOOT = 0x2, /* Hit the reset button */ - FENCE_ON = 0x3, /* Turn the VM on */ - FENCE_STATUS = 0x4, /* virtual machine status (off/on) */ - FENCE_DEVSTATUS = 0x5, /* Status of the fencing device */ - FENCE_HOSTLIST = 0x6, /* List VMs controllable */ - FENCE_METADATA = 0x7 + FENCE_NULL = 0x0, + FENCE_OFF = 0x1, /* Turn the VM off */ + FENCE_REBOOT = 0x2, /* Hit the reset button */ + FENCE_ON = 0x3, /* Turn the VM on */ + FENCE_STATUS = 0x4, /* virtual machine status (off/on) */ + FENCE_DEVSTATUS = 0x5, /* Status of the fencing device */ + FENCE_HOSTLIST = 0x6, /* List VMs controllable */ + FENCE_METADATA = 0x7, /* Print fence agent metadata */ + FENCE_VALIDATEALL = 0x8 /* Validate command-line or stdin arguments and exit */ } fence_cmd_t; #define DEFAULT_TTL 4 diff --git a/man/fence_virt.8 b/man/fence_virt.8 index 1aded48..2ef6cc2 100644 --- a/man/fence_virt.8 +++ b/man/fence_virt.8 @@ -37,7 +37,7 @@ Virtual machine (domain UUID or name) to fence .TP .B -o . -Fencing action (null, off, on, reboot, status, monitor, list, list-status, or metadata) (Default Value: reboot). See the FENCING ACTIONS section. +Fencing action (null, off, on, reboot, status, monitor, list, list-status, validate-all, or metadata) (Default Value: reboot). See the FENCING ACTIONS section. .TP .B -t @@ -145,7 +145,7 @@ Virtual machine (domain UUID or name) to fence .TP .B action . -Fencing action (null, off, on, reboot, status, monitor, list, or metadata) (Default Value: reboot). See the FENCING ACTIONS section. +Fencing action (null, off, on, reboot, status, monitor, list, list-status, validate-all, or metadata) (Default Value: reboot). See the FENCING ACTIONS section. .TP .B timeout @@ -254,6 +254,10 @@ Check the health of fence_virtd's backend plugin. List virtual machines which may be fenced by fence_virtd (not supported on all backends). +.TP +\fBvalidate-all\fP +Validate arguments given on either the command line or standard input. If validation fails, the fence agent will exit with code 1, otherwise it will exit with code 0. + .TP \fBmetadata \fP Print XML metadata to standard output.