diff --git a/TODO b/TODO index 5523c6b..f595c1b 100644 --- a/TODO +++ b/TODO @@ -2,11 +2,6 @@ High Priority / Blockers for v1.0; * pacemaker backend -* metadata function - -* allow use of IPs w/ multicast listener as the "source" - VMs for management layer permissions mappings - Future Stuff: * oVirt backend diff --git a/client/main.c b/client/main.c index 5b65c39..e5f1f77 100644 --- a/client/main.c +++ b/client/main.c @@ -99,7 +99,8 @@ main(int argc, char **argv) /* Additional validation here */ if (!args.domain && (args.op != FENCE_DEVSTATUS && - args.op != FENCE_HOSTLIST)) { + args.op != FENCE_HOSTLIST && + args.op != FENCE_METADATA)) { printf("No domain specified!\n"); args.flags |= F_ERR; } @@ -109,6 +110,11 @@ main(int argc, char **argv) exit(1); } + if (args.op == FENCE_METADATA) { + args_metadata(argv[0], my_options); + return 0; + } + switch(args.mode) { case MODE_MULTICAST: ret = mcast_fence_virt(&args); diff --git a/client/options.c b/client/options.c index 528bc74..39e6912 100644 --- a/client/options.c +++ b/client/options.c @@ -203,6 +203,8 @@ assign_op(fence_virt_args_t *args, struct arg_info *arg, char *value) args->op = FENCE_DEVSTATUS; } else if (!strcasecmp(value, "hostlist")) { args->op = FENCE_HOSTLIST; + } else if (!strcasecmp(value, "metadata")) { + args->op = FENCE_METADATA; } else { printf("Unsupported operation: %s\n", value); args->flags |= F_ERR; @@ -301,108 +303,151 @@ assign_uri(fence_virt_args_t *args, struct arg_info *arg, char *value) } +static void +print_desc_xml(const char *desc) +{ + const char *d; + + for (d = desc; *d; d++) { + switch (*d) { + case '<': + printf("<"); + break; + case '>': + printf(">"); + break; + default: + printf("%c", *d); + } + } +} + /** ALL valid command line and stdin arguments for this fencing agent */ static struct arg_info _arg_info[] = { { '\xff', NULL, "agent", + 0, "string", NULL, "Not user serviceable", NULL }, { '\xff', NULL, "self", + 0, "string", NULL, "Not user serviceable", NULL }, { '\xff', NULL, "nodename", + 0, "string", NULL, "Not user serviceable", NULL }, { 'd', "-d", "debug", + 0, "boolean", NULL, "Specify (stdin) or increment (command line) debug level", assign_debug }, { 'i', "-i ", "ip_family", + 0, "string", "auto", "IP Family ([auto], ipv4, ipv6)", assign_family }, { 'a', "-a
", "multicast_address", + 0, "string", NULL, "Multicast address (default=" IPV4_MCAST_DEFAULT " / " IPV6_MCAST_DEFAULT ")", assign_address }, { 'A', "-A
", "channel_address", + 0, "string", "10.0.2.179", "VM Channel IP address (default=" DEFAULT_CHANNEL_IP ")", assign_channel_address }, { 'p', "-p ", "port", + 0, "string", "1229", "Multicast or VMChannel IP port (default=1229)", assign_port }, { 'I', "-I ", "interface", + 0, "string", NULL, "Network interface name to listen on", assign_interface }, { 'r', "-r ", "retrans", + 0, "string", "20", "Multicast retransmit time (in 1/10sec; default=20)", assign_retrans }, { 'c', "-c ", "hash", + 0, "string", "sha256", "Packet hash strength (none, sha1, [sha256], sha512)", assign_hash }, { 'C', "-C ", "auth", + 0, "string", "sha256", "Authentication (none, sha1, [sha256], sha512)", assign_auth }, { 'k', "-k ", "key_file", + 0, "string", DEFAULT_KEY_FILE, "Shared key file (default=" DEFAULT_KEY_FILE ")", assign_key }, { 'D', "-D ", "serial_device", + 0, "string", NULL, "Serial device (default=" DEFAULT_SERIAL_DEVICE ")", assign_device }, { 'P', "-P ", "serial_params", + 0, "string", DEFAULT_SERIAL_SPEED, "Serial Parameters (default=" DEFAULT_SERIAL_SPEED ")", assign_params }, { '\xff', NULL, "option", /* Deprecated */ + 0, "string", "reboot", "Fencing option (null, off, on, [reboot], status, hostlist, devstatus)", assign_op }, { 'o', "-o ", "action", + 0, "string", "reboot", "Fencing action (null, off, on, [reboot], status, hostlist, devstatus)", assign_op }, { 'H', "-H ", "domain", + 0, "string", NULL, "Virtual Machine (domain name) to fence", assign_domain }, { 'u', "-u", "use_uuid", + 0, "string", "0", "Treat as UUID instead of domain name. This is provided for compatibility with older fence_xvmd installations.", assign_uuid_lookup }, { 't', "-t ", "timeout", + 0, "string", "30", "Fencing timeout (in seconds; default=30)", assign_timeout }, { 'h', "-h", NULL, + 0, "boolean", "0", "Help", assign_help }, { '?', "-?", NULL, + 0, "boolean", "0", "Help (alternate)", assign_help }, { 'U', "-U", "uri", + 0, "boolean", "qemu:///system", "URI for Hypervisor (default: auto detect)", assign_uri }, { 'V', "-V", NULL, + 0, "boolean", "0", "Display version and exit", assign_version }, /* Terminator */ - { 0, NULL, NULL, NULL, NULL } + { 0, NULL, NULL, 0, NULL, NULL, NULL, NULL } }; @@ -588,6 +633,53 @@ args_usage(char *progname, const char *optstr, int print_stdin) } +void +args_metadata(char *progname, const char *optstr) +{ + int x; + struct arg_info *arg; + + printf("\n"); + printf("\n", basename(progname)); + printf("%s is an I/O Fencing agent which can be used with" + "virtual machines.\n", basename(progname)); + printf("\n"); + + for (x = 0; x < strlen(optstr); x++) { + arg = find_arg_by_char(optstr[x]); + if (!arg) + continue; + if (!arg->stdin_opt) + continue; + + printf("\t\n",arg->stdin_opt); + printf("\t\t\n",arg->opt); + if (arg->default_value) { + printf("\t\t\n", arg->content_type, arg->default_value); + } else { + printf("\t\t\n", arg->content_type); + } + printf("\t\t"); + print_desc_xml(arg->desc); + printf("\n"); + printf("\t\n"); + } + + printf("\n"); + printf("\n"); + printf("\t\n"); + printf("\t\n"); + printf("\t\n"); + printf("\t\n"); + printf("\t\n"); + printf("\t\n"); + printf("\t\n"); + printf("\t\n"); + printf("\n"); + printf("\n"); +} + + /** Remove leading and trailing whitespace from a line of text. diff --git a/include/options.h b/include/options.h index 5253ba9..6fe19d8 100644 --- a/include/options.h +++ b/include/options.h @@ -69,6 +69,9 @@ struct arg_info { char opt; char *opt_desc; char *stdin_opt; + int eh; + char *content_type; + char *default_value; char *desc; void (*assign)(fence_virt_args_t *, struct arg_info *, char *); }; @@ -84,5 +87,6 @@ void args_get_stdin(const char *optstr, fence_virt_args_t *args); void args_get_ccs(const char *optstr, fence_virt_args_t *args); void args_usage(char *progname, const char *optstr, int print_stdin); void args_print(fence_virt_args_t *args); +void args_metadata(char *progname, const char *optstr); #endif diff --git a/include/xvm.h b/include/xvm.h index b08d0bb..9bb47bf 100644 --- a/include/xvm.h +++ b/include/xvm.h @@ -56,7 +56,8 @@ typedef enum { 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_HOSTLIST = 0x6, /* List VMs controllable */ + FENCE_METADATA = 0x7 } fence_cmd_t; #define DEFAULT_TTL 4