Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=8ebfc023495b10... Commit: 8ebfc023495b1010e6802ab1be6fb11790f35494 Parent: adf106455d72219956030c7f821b0dd06381a9cb Author: Ryan McCabe rmccabe@redhat.com AuthorDate: Mon Apr 15 10:13:56 2013 -0400 Committer: Ryan McCabe rmccabe@redhat.com CommitterDate: Mon Apr 15 10:13:56 2013 -0400
fence_xvm: Add a delay (-w) option
Add a delay option to fence_xvm that causes it to sleep some specified number of seconds before performing fencing operations.
Resolves: rhbz#854183
Signed-off-by: Ryan McCabe rmccabe@redhat.com --- fence/agents/xvm/fence_xvm.c | 5 ++++- fence/agents/xvm/options.c | 21 ++++++++++++++++++++- fence/agents/xvm/options.h | 1 + fence/man/fence_xvm.8 | 7 +++++++ 4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/fence/agents/xvm/fence_xvm.c b/fence/agents/xvm/fence_xvm.c index eb006fd..0cb78e5 100644 --- a/fence/agents/xvm/fence_xvm.c +++ b/fence/agents/xvm/fence_xvm.c @@ -317,7 +317,7 @@ int main(int argc, char **argv) { fence_xvm_args_t args; - char *my_options = "di:a:p:r:C:c:k:H:uo:t:?hV"; + char *my_options = "di:a:p:r:C:c:k:H:uo:t:?hVw:";
args_init(&args); if (argc == 1) { @@ -372,5 +372,8 @@ main(int argc, char **argv) return 1; }
+ if (args.delay > 0) + sleep(args.delay); + return fence_xen_domain(&args); } diff --git a/fence/agents/xvm/options.c b/fence/agents/xvm/options.c index c77dee0..107b29a 100644 --- a/fence/agents/xvm/options.c +++ b/fence/agents/xvm/options.c @@ -251,6 +251,20 @@ assign_help(fence_xvm_args_t *args, struct arg_info *arg, char *value)
static inline void +assign_delay(fence_xvm_args_t *args, struct arg_info *arg, char *value) +{ + if (!value) + return; + + args->delay = atoi(value); + if (args->timeout <= 0) { + printf("Invalid delay: '%s'\n", value); + args->flags |= F_ERR; + } +} + + +static inline void assign_version(fence_xvm_args_t *args, struct arg_info *arg, char *value) { args->flags |= F_VERSION; @@ -369,7 +383,11 @@ static struct arg_info _arg_info[] = { { 'U', "-U", "uri", "URI for Hypervisor (default: auto detect)", assign_uri }, - + + { 'w', "-w <delay>", "delay", + "Fencing delay (in seconds; default=0)", + assign_delay }, + { 'V', "-V", NULL, "Display version and exit", assign_version }, @@ -433,6 +451,7 @@ args_init(fence_xvm_args_t *args) args->retr_time = 20; args->flags = 0; args->debug = 0; + args->delay = 0; }
diff --git a/fence/agents/xvm/options.h b/fence/agents/xvm/options.h index 7687acc..9115b09 100644 --- a/fence/agents/xvm/options.h +++ b/fence/agents/xvm/options.h @@ -44,6 +44,7 @@ typedef struct { unsigned int ifindex; int family; int timeout; + int delay; int retr_time; arg_flags_t flags; int debug; diff --git a/fence/man/fence_xvm.8 b/fence/man/fence_xvm.8 index 55c7915..209761e 100644 --- a/fence/man/fence_xvm.8 +++ b/fence/man/fence_xvm.8 @@ -87,6 +87,10 @@ failure!). This specifies the amount of time, in seconds, to wait before a response to the multicast request before giving up (default=30). .TP +\fB-w\fP \fIdelay\fP +. +Fencing delay (in seconds). The fence agent will wait the specified number of seconds before attempting a fencing operation. (Default Value: 0) +.TP \fB-?\fP Print out a help message describing available options, then exit. .TP @@ -137,6 +141,9 @@ Same as the -o option. \fItimeout = < param >\fR Same as the -t option. .TP +\fIdelay = < param >\fR +Same as the -w option. +.TP \fIdomain = < param >\fR Same as the -H option.