From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7286 invoked by alias); 13 Jul 2009 14:53:26 -0000 Received: (qmail 7278 invoked by alias); 13 Jul 2009 14:53:25 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_41,SPF_HELO_PASS X-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_41,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: Create a function that prints documentation 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: 05488044454ca7737f52f2d846b54b87ae08813b X-Git-Newrev: 014fead2ca7adce6b3832a0585498f4abcc3250e From: =?utf-8?q?Marek_Gr=C3=A1c?= Message-Id: <20090713145302.B82AF1201FF@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/msg00043.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=014fead2ca7adce6b3832a0585498f4abcc3250e Commit: 014fead2ca7adce6b3832a0585498f4abcc3250e Parent: 05488044454ca7737f52f2d846b54b87ae08813b Author: Marek 'marx' Grac AuthorDate: Mon Jul 13 16:44:38 2009 +0200 Committer: Marek 'marx' Grac CommitterDate: Mon Jul 13 16:44:38 2009 +0200 fencing: Create a function that prints documentation This have to be moved because we need access also to agent specific values as they will be presented as defaults in metadata. Prerequisite for man pages generation. 1st part of solution for bz#488959 --- fence/agents/alom/fence_alom.py | 4 ++- fence/agents/apc/fence_apc.py | 2 + fence/agents/apc_snmp/fence_apc_snmp.py | 2 + fence/agents/bladecenter/fence_bladecenter.py | 2 + fence/agents/cisco_mds/fence_cisco_mds.py | 2 + fence/agents/drac/fence_drac5.py | 2 + fence/agents/eps/fence_eps.py | 2 + fence/agents/ibmblade/fence_ibmblade.py | 2 + fence/agents/ifmib/fence_ifmib.py | 2 + fence/agents/ilo/fence_ilo.py | 2 + fence/agents/intelmodular/fence_intelmodular.py | 2 + fence/agents/ldom/fence_ldom.py | 2 + fence/agents/lib/fencing.py.py | 36 ++++++++++++++-------- fence/agents/lpar/fence_lpar.py | 4 ++- fence/agents/rsa/fence_rsa.py | 2 + fence/agents/virsh/fence_virsh.py | 2 + fence/agents/vmware/fence_vmware.py | 2 + fence/agents/wti/fence_wti.py | 2 + 18 files changed, 59 insertions(+), 15 deletions(-) diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py index 610ec2b..5fe72aa 100644 --- a/fence/agents/alom/fence_alom.py +++ b/fence/agents/alom/fence_alom.py @@ -53,11 +53,13 @@ def main(): # Default command is sc> if (not options.has_key("-c")): - options["-c"] = "sc\>\ " + options["-c"] = "sc\>\ " # Default to ssh options["-x"] = 1 options["telnet_over_ssh"] = 1 + + show_docs(options) # Operate the fencing device conn = fence_login(options) diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py index 13bad67..e4a3e3d 100755 --- a/fence/agents/apc/fence_apc.py +++ b/fence/agents/apc/fence_apc.py @@ -199,6 +199,8 @@ def main(): if 0 == options.has_key("-c"): options["-c"] = "\n>" + show_docs(options) + ## Support for -n [switch]:[plug] notation that was used before if (options.has_key("-n") == 1) and (-1 != options["-n"].find(":")): (switch, plug) = options["-n"].split(":", 1) diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py index 6ff1318..91331b5 100644 --- a/fence/agents/apc_snmp/fence_apc_snmp.py +++ b/fence/agents/apc_snmp/fence_apc_snmp.py @@ -187,6 +187,8 @@ def main(): if (not (options.has_key("-s"))): options["-s"]="1" + show_docs(options) + # Operate the fencing device fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status) diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py index d694966..5df4869 100644 --- a/fence/agents/bladecenter/fence_bladecenter.py +++ b/fence/agents/bladecenter/fence_bladecenter.py @@ -103,6 +103,8 @@ def main(): if 0 == options.has_key("-c"): options["-c"] = "system>" + show_docs(options) + ## ## Operate the fencing device ###### diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py index 0d57c04..67948e6 100644 --- a/fence/agents/cisco_mds/fence_cisco_mds.py +++ b/fence/agents/cisco_mds/fence_cisco_mds.py @@ -105,6 +105,8 @@ def main(): options = check_input(device_opt, options) + show_docs(options) + if (not (options["-o"] in ["list","monitor"])): port_oid=cisco_port2oid(options["-n"]) diff --git a/fence/agents/drac/fence_drac5.py b/fence/agents/drac/fence_drac5.py index af4a1ed..b669bac 100755 --- a/fence/agents/drac/fence_drac5.py +++ b/fence/agents/drac/fence_drac5.py @@ -96,6 +96,8 @@ def main(): if 0 == options.has_key("-c"): options["-c"] = "\$" + show_docs(options) + ## ## Operate the fencing device ###### diff --git a/fence/agents/eps/fence_eps.py b/fence/agents/eps/fence_eps.py index f751d29..604a481 100644 --- a/fence/agents/eps/fence_eps.py +++ b/fence/agents/eps/fence_eps.py @@ -107,6 +107,8 @@ def main(): if (not options.has_key("-c")): options["-c"]="hidden.htm" + show_docs(options) + #Run fence action. Conn is None, beacause we always need open new http connection fence_action(None, options, set_power_status, get_power_status,get_power_status) diff --git a/fence/agents/ibmblade/fence_ibmblade.py b/fence/agents/ibmblade/fence_ibmblade.py index e6d0dac..7532221 100644 --- a/fence/agents/ibmblade/fence_ibmblade.py +++ b/fence/agents/ibmblade/fence_ibmblade.py @@ -69,6 +69,8 @@ def main(): options=check_input(device_opt,process_input(device_opt)) + show_docs(options) + # Operate the fencing device fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status) diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py index 7473129..a6c452d 100644 --- a/fence/agents/ifmib/fence_ifmib.py +++ b/fence/agents/ifmib/fence_ifmib.py @@ -125,6 +125,8 @@ def main(): options = check_input(device_opt, options) + show_docs(options) + # Operate the fencing device fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status) diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py index c2fd70b..e15052d 100755 --- a/fence/agents/ilo/fence_ilo.py +++ b/fence/agents/ilo/fence_ilo.py @@ -65,6 +65,8 @@ def main(): options["-z"] = 1 LOGIN_TIMEOUT = 10 + show_docs(options) + ## ## Login and get version number #### diff --git a/fence/agents/intelmodular/fence_intelmodular.py b/fence/agents/intelmodular/fence_intelmodular.py index 6b68d0b..492bbc5 100644 --- a/fence/agents/intelmodular/fence_intelmodular.py +++ b/fence/agents/intelmodular/fence_intelmodular.py @@ -74,6 +74,8 @@ def main(): options=check_input(device_opt,process_input(device_opt)) + show_docs(options) + # Operate the fencing device fence_action(FencingSnmp(options), options, set_power_status, get_power_status, get_outlets_status) diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py index 021f036..e6bf656 100644 --- a/fence/agents/ldom/fence_ldom.py +++ b/fence/agents/ldom/fence_ldom.py @@ -98,6 +98,8 @@ def main(): options["-x"] = 1 + show_docs(options) + ## ## Operate the fencing device #### diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index feb01f8..3829ccc 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -481,20 +481,10 @@ def check_input(device_opt, opt): else: all_opt["login"]["required"] = "0" - ## Process special options (and exit) + ## In special cases (show help, metadata or version) we don't need to check anything ##### - if options.has_key("-h"): - usage(device_opt) - sys.exit(0) - - if options.has_key("-o") and options["-o"].lower() == "metadata": - metadata(device_opt) - sys.exit(0) - - if options.has_key("-V"): - print RELEASE_VERSION, BUILD_DATE - print REDHAT_COPYRIGHT - sys.exit(0) + if options.has_key("-h") or options.has_key("-V") or (options.has_key("-o") and options["-o"].lower() == "metadata"): + return options; ## Set default values ##### @@ -571,7 +561,27 @@ def wait_power_status(tn, options, get_power_fn): return 1 return 0 +def show_docs(options): + device_opt = options["device_opt"] + + ## Process special options (and exit) + ##### + if options.has_key("-h"): + usage(device_opt) + sys.exit(0) + + if options.has_key("-o") and options["-o"].lower() == "metadata": + metadata(device_opt) + sys.exit(0) + + if options.has_key("-V"): + print RELEASE_VERSION, BUILD_DATE + print REDHAT_COPYRIGHT + sys.exit(0) + def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None): + ## Process options that manipulate fencing device + ##### if (options["-o"] == "list") and (0 == options["device_opt"].count("port")) and (0 == options["device_opt"].count("partition")): print "N/A" return diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py index cb74f1d..f6e4a58 100644 --- a/fence/agents/lpar/fence_lpar.py +++ b/fence/agents/lpar/fence_lpar.py @@ -140,13 +140,15 @@ def main(): options = check_input(device_opt, process_input(device_opt)) ## - ## Fence agent specific defaults + ## Fence agent specific settings and default values ##### if 0 == options.has_key("-c"): options["-c"] = [ ":~>", "]\$", "\$ " ] if 0 == options.has_key("-x"): fail_usage("Failed: You have to use ssh connection (-x) to fence device") + + show_docs(options) if 0 == options.has_key("-s"): fail_usage("Failed: You have to enter name of managed system") diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py index dd2f579..9c33327 100644 --- a/fence/agents/rsa/fence_rsa.py +++ b/fence/agents/rsa/fence_rsa.py @@ -55,6 +55,8 @@ def main(): # This device will not allow us to login even with LANG=C options["ssh_options"] = "-F /dev/null" + + show_docs(options) ## ## Operate the fencing device diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py index 6866fb0..038e903 100644 --- a/fence/agents/virsh/fence_virsh.py +++ b/fence/agents/virsh/fence_virsh.py @@ -77,6 +77,8 @@ def main(): options["ssh_options"]="-t '/bin/bash -c \"PS1=\[EXPECT\]#\ /bin/bash --noprofile --norc\"'" + show_docs(options) + ## Operate the fencing device conn = fence_login(options) fence_action(conn, options, set_power_status, get_power_status, get_outlets_status) diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py index 42dc097..10307c1 100644 --- a/fence/agents/vmware/fence_vmware.py +++ b/fence/agents/vmware/fence_vmware.py @@ -290,6 +290,8 @@ def main(): # Default is secure connection options["-x"] = 1 + show_docs(options) + # Check vmware type and set path vmware_check_vmware_type(options) diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py index 35b4d54..13c6b52 100644 --- a/fence/agents/wti/fence_wti.py +++ b/fence/agents/wti/fence_wti.py @@ -88,6 +88,8 @@ def main(): if 0 == options.has_key("-c"): options["-c"] = [ "RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>" ] + show_docs(options) + ## ## Operate the fencing device ##