From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15419 invoked by alias); 26 Jun 2009 12:46:35 -0000 Received: (qmail 15413 invoked by alias); 26 Jun 2009 12:46:35 -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: fence-agents: master - fencing: Create function that prints documentation To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: fence-agents.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: b0913e9ff4b7a2be3895577ae5d54d44a6bfb067 X-Git-Newrev: 21694e64d9cd6e58a4484c3b317640e836742001 From: =?utf-8?q?Marek_Gr=C3=A1c?= Message-Id: <20090626124525.73EC11201EE@lists.fedorahosted.org> Date: Fri, 26 Jun 2009 12:46: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-q2/txt/msg00776.txt.bz2 Gitweb: http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=commitdiff;h=21694e64d9cd6e58a4484c3b317640e836742001 Commit: 21694e64d9cd6e58a4484c3b317640e836742001 Parent: b0913e9ff4b7a2be3895577ae5d54d44a6bfb067 Author: Marek 'marx' Grac AuthorDate: Fri Jun 26 14:41:05 2009 +0200 Committer: Marek 'marx' Grac CommitterDate: Fri Jun 26 14:41:05 2009 +0200 fencing: Create 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. --- 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 | 5 ++- 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(+), 16 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 9a3a1c9..d3c6f53 100644 --- a/fence/agents/lpar/fence_lpar.py +++ b/fence/agents/lpar/fence_lpar.py @@ -140,19 +140,20 @@ 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") if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")): fail_usage("Failed: You have to enter name of the partition") - if 1 == options.has_key("-H") and (options["-H"] != "3" and options["-H"] != "4"): fail_usage("Failed: You have to enter valid version number: 3 or 4") diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py index 1eb128e..09e878c 100644 --- a/fence/agents/rsa/fence_rsa.py +++ b/fence/agents/rsa/fence_rsa.py @@ -54,6 +54,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 ##