Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
fence_xvm/fence_virt: Add support for the validate-all status op
Browse files Browse the repository at this point in the history
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 <rmccabe@redhat.com>
  • Loading branch information
ryan-mccabe committed May 4, 2017
1 parent 53cb4ec commit 286e0c6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
10 changes: 7 additions & 3 deletions client/main.c
Expand Up @@ -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 &&
Expand Down Expand Up @@ -186,5 +190,5 @@ main(int argc, char **argv)

out:
closelog();
return ret;
exit(ret);
}
7 changes: 5 additions & 2 deletions client/options.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <operation>", "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 <domain>", "port",
Expand Down Expand Up @@ -801,6 +803,7 @@ args_metadata(char *progname, const char *optstr)
printf("\t<action name=\"monitor\" />\n");
printf("\t<action name=\"list\" />\n");
printf("\t<action name=\"list-status\" />\n");
printf("\t<action name=\"validate-all\" />\n");
printf("</actions>\n");
printf("</resource-agent>\n");
}
Expand Down
17 changes: 9 additions & 8 deletions include/xvm.h
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions man/fence_virt.8
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 286e0c6

Please sign in to comment.