From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7384 invoked by alias); 13 Jul 2009 14:53:28 -0000 Received: (qmail 7378 invoked by alias); 13 Jul 2009 14:53:28 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_210,SPF_HELO_PASS X-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_210,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - fencing: Metadata suitable for automatic man pages generation To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: 014fead2ca7adce6b3832a0585498f4abcc3250e X-Git-Newrev: 634c700d5781476ed777266950bd84e4952fa4a9 From: =?utf-8?q?Marek_Gr=C3=A1c?= Message-Id: <20090713145304.D4C151201FF@lists.fedorahosted.org> Date: Mon, 13 Jul 2009 14:53:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00044.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=634c700d5781476ed777266950bd84e4952fa4a9 Commit: 634c700d5781476ed777266950bd84e4952fa4a9 Parent: 014fead2ca7adce6b3832a0585498f4abcc3250e Author: Marek 'marx' Grac AuthorDate: Mon Jul 13 16:48:05 2009 +0200 Committer: Marek 'marx' Grac CommitterDate: Mon Jul 13 16:48:05 2009 +0200 fencing: Metadata suitable for automatic man pages generation Information about individual options are extended so they are more suitable for creating better metadata. We can use them to produce fresh manual pages. Metadata have to be formatted using XSLT processor (e.h. xsltproc) using template ra2man.xsl in lib/ Example: fence_lpar -o metadata | xsltproc ra2man.xsl - | nroff -mandoc > z man ./z @note: If the default value is array then only string 'list of values' is rendered. As currently it is not possible to enter arrays from getopt/stdin. --- fence/agents/lib/fencing.py.py | 62 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 57 insertions(+), 5 deletions(-) diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index 3829ccc..eaff7a0 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -37,11 +37,15 @@ all_opt = { "getopt" : "h", "longopt" : "help", "help" : "-h, --help Display this help and exit", + "required" : "0", + "shortdesc" : "Display help and exit", "order" : 54 }, "version" : { "getopt" : "V", "longopt" : "version", "help" : "-V, --version Output version information and exit", + "required" : "0", + "shortdesc" : "Display version information and exit", "order" : 53 }, "quiet" : { "getopt" : "q", @@ -58,6 +62,8 @@ all_opt = { "getopt" : "D:", "longopt" : "debug-file", "help" : "-D, --debug-file= Debugging to output file", + "required" : "0", + "shortdesc" : "Write debug information to given file", "order" : 52 }, "agent" : { "getopt" : "", @@ -125,34 +131,44 @@ all_opt = { "getopt" : "m:", "longopt" : "module-name", "help" : "-m, --module-name= DRAC/MC module name", + "required" : "0", + "shortdesc" : "DRAC/MC module name", "order" : 1 }, "drac_version" : { "getopt" : "d:", "longopt" : "drac-version", "help" : "-d, --drac-version= Force DRAC version to use", + "required" : "0", + "shortdesc" : "Force DRAC version to use", "order" : 1 }, "hmc_version" : { "getopt" : "H:", "longopt" : "hmc-version", "help" : "-H, --hmc-version= Force HMC version to use: 3, 4 (default)", + "required" : "0", + "shortdesc" : "Force HMC version to use (3 or 4)", "default" : "4", "order" : 1 }, "ribcl" : { "getopt" : "r:", "longopt" : "ribcl-version", "help" : "-r, --ribcl-version= Force ribcl version to use", + "required" : "0", + "shortdesc" : "Force ribcl version to use", "order" : 1 }, "cmd_prompt" : { "getopt" : "c:", "longopt" : "command-prompt", "help" : "-c, --command-prompt= Force command prompt", + "shortdesc" : "Force command prompt", + "required" : "0", "order" : 1 }, "secure" : { "getopt" : "x", "longopt" : "ssh", "help" : "-x, --ssh Use ssh connection", - "required" : "0", "shortdesc" : "SSH connection", + "required" : "0", "order" : 1 }, "ssl" : { "getopt" : "z", @@ -290,6 +306,8 @@ all_opt = { "longopt" : "separator", "help" : "-C, --separator= Separator for CSV created by 'list' operation", "default" : ",", + "required" : "0", + "shortdesc" : "Separator for CSV created by operation list", "order" : 100 } } @@ -346,14 +364,15 @@ def usage(avail_opt): if len(value["help"]) != 0: print " " + value["help"] -def metadata(avail_opt): +def metadata(avail_opt, options, docs): global all_opt sorted_list = [ (key, all_opt[key]) for key in avail_opt ] sorted_list.sort(lambda x, y: cmp(x[1]["order"], y[1]["order"])) print "" - print "" + print "" + print "" + docs["longdesc"] + "" print "" for option, value in sorted_list: if all_opt[option].has_key("shortdesc"): @@ -362,14 +381,42 @@ def metadata(avail_opt): default = "" if all_opt[option].has_key("default"): default = "default=\""+all_opt[option]["default"]+"\"" + elif options.has_key("-" + all_opt[option]["getopt"][:-1]): + if options["-" + all_opt[option]["getopt"][:-1]]: + try: + default = "default=\"" + options["-" + all_opt[option]["getopt"][:-1]] + "\"" + except TypeError: + ## @todo/@note: Currently there is no clean way how to handle lists + ## we can create a string from it but we can't set it on command line + default = "default=\"list of values\"" + elif options.has_key("-" + all_opt[option]["getopt"]): + default = "default=\"true\" " + + mixed = all_opt[option]["help"] + ## split it between option and help text + res = re.compile("^(.*--\S+)\s+", re.IGNORECASE | re.S).search(mixed) + if (None != res): + mixed = res.group(1) + mixed = mixed.replace("<", "<").replace(">", ">") + print "\t\t" if all_opt[option]["getopt"].count(":") > 0: print "\t\t" else: print "\t\t" + print "\t\t" + all_opt[option]["shortdesc"] + "" print "\t" print "" + print "" + print "\t" + print "\t" + print "\t" + print "\t" + print "\t" + print "\t" + print "\t" + print "" print "" def process_input(avail_opt): @@ -561,8 +608,13 @@ def wait_power_status(tn, options, get_power_fn): return 1 return 0 -def show_docs(options): +def show_docs(options, docs = None): device_opt = options["device_opt"] + + if docs == None: + docs = { } + docs["shortdesc"] = "Fence agent" + docs["longdesc"] = "" ## Process special options (and exit) ##### @@ -571,7 +623,7 @@ def show_docs(options): sys.exit(0) if options.has_key("-o") and options["-o"].lower() == "metadata": - metadata(device_opt) + metadata(device_opt, options, docs) sys.exit(0) if options.has_key("-V"):