From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek 'marx' Grac Date: Thu, 25 Oct 2012 10:27:36 +0200 Subject: [Cluster-devel] [PATCH 3/3] fence-agents: Use default values for device options instead of per-agent solutions Message-ID: <1351153656-25272-1-git-send-email-mgrac@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Majority of these changes concern: * (-x / ssh) to be turn on by default * command prompt default which differs across fence agents --- fence/agents/alom/fence_alom.py | 10 +++------- fence/agents/apc/fence_apc.py | 9 ++------- fence/agents/drac5/fence_drac5.py | 8 ++------ fence/agents/eaton_snmp/fence_eaton_snmp.py | 8 ++------ fence/agents/ibmblade/fence_ibmblade.py | 6 +----- fence/agents/ifmib/fence_ifmib.py | 5 +---- fence/agents/ilo/fence_ilo.py | 7 ++----- fence/agents/ipdu/fence_ipdu.py | 14 +++++--------- fence/agents/ldom/fence_ldom.py | 13 +++---------- fence/agents/lpar/fence_lpar.py | 7 +------ fence/agents/rsa/fence_rsa.py | 8 ++------ fence/agents/rsb/fence_rsb.py | 2 -- fence/agents/sanbox2/fence_sanbox2.py | 8 ++------ fence/agents/virsh/fence_virsh.py | 9 +++------ fence/agents/vmware/fence_vmware.py | 10 ++-------- fence/agents/wti/fence_wti.py | 8 ++------ fence/agents/xenapi/fence_xenapi.py | 4 +--- 17 files changed, 34 insertions(+), 102 deletions(-) diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py index 6d62d73..c5fec7c 100644 --- a/fence/agents/alom/fence_alom.py +++ b/fence/agents/alom/fence_alom.py @@ -47,15 +47,11 @@ def main(): "identity_file", "test", "inet4_only", "inet6_only", "ipport" ] atexit.register(atexit_handler) - - pinput = process_input(device_opt) - pinput["-x"] = 1 - options = check_input(device_opt, pinput) - # Default command is sc> - if (not options.has_key("-c")): - options["-c"] = "sc\>\ " + all_opt["secure"]["default"] = "1" + all_opt["cmd_prompt"]["default"] = [ "sc\>\ " ] + options = check_input(device_opt, process_input(device_opt)) options["telnet_over_ssh"] = 1 docs = { } diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py index 46f8b84..6ba8628 100644 --- a/fence/agents/apc/fence_apc.py +++ b/fence/agents/apc/fence_apc.py @@ -188,16 +188,11 @@ def main(): atexit.register(atexit_handler) - options = check_input(device_opt, process_input(device_opt)) + all_opt["cmd_prompt"]["default"] = [ "\n>" ] - ## - ## Fence agent specific defaults - ##### + options = check_input(device_opt, process_input(device_opt)) options["ssh_options"] = "-1 -c blowfish" - if 0 == options.has_key("-c"): - options["-c"] = "\n>" - docs = { } docs["shortdesc"] = "Fence agent for APC over telnet/ssh" docs["longdesc"] = "fence_apc is an I/O Fencing agent \ diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py index 755f2b4..b261e50 100644 --- a/fence/agents/drac5/fence_drac5.py +++ b/fence/agents/drac5/fence_drac5.py @@ -91,13 +91,9 @@ def main(): atexit.register(atexit_handler) - options = check_input(device_opt, process_input(device_opt)) + all_opt["cmd_prompt"]["default"] = [ "\$" ] - ## - ## Fence agent specific defaults - ##### - if 0 == options.has_key("-c"): - options["-c"] = "\$" + options = check_input(device_opt, process_input(device_opt)) docs = { } docs["shortdesc"] = "Fence agent for Dell DRAC CMC/5" diff --git a/fence/agents/eaton_snmp/fence_eaton_snmp.py b/fence/agents/eaton_snmp/fence_eaton_snmp.py index 2c0b54e..e4c3ea3 100644 --- a/fence/agents/eaton_snmp/fence_eaton_snmp.py +++ b/fence/agents/eaton_snmp/fence_eaton_snmp.py @@ -197,11 +197,6 @@ def get_outlets_status(conn, options): return result -# Define new options -def eaton_snmp_define_defaults(): - all_opt["snmp_version"]["default"]="1" - all_opt["community"]["default"]="private" - # Main agent method def main(): device_opt = [ "ipaddr", "login", "passwd", "passwd_script", @@ -213,10 +208,11 @@ def main(): atexit.register(atexit_handler) snmp_define_defaults () - eaton_snmp_define_defaults() all_opt["switch"]["default"] = 1 all_opt["power_wait"]["default"] = 2 + all_opt["snmp_version"]["default"] = "1" + all_opt["community"]["default"] = "private" options=check_input(device_opt,process_input(device_opt)) # Plug indexing start from zero on ePDU Managed, so we substract '1' from diff --git a/fence/agents/ibmblade/fence_ibmblade.py b/fence/agents/ibmblade/fence_ibmblade.py index 96d2a76..ec992f4 100644 --- a/fence/agents/ibmblade/fence_ibmblade.py +++ b/fence/agents/ibmblade/fence_ibmblade.py @@ -48,10 +48,6 @@ def get_outlets_status(conn, options): return result -# Define new options -def ibmblade_define_defaults(): - all_opt["snmp_version"]["default"]="1" - # Main agent method def main(): global port_oid @@ -65,7 +61,7 @@ def main(): atexit.register(atexit_handler) snmp_define_defaults () - ibmblade_define_defaults() + all_opt["snmp_version"]["default"]="1" options=check_input(device_opt,process_input(device_opt)) diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py index bbbec22..a43bf38 100644 --- a/fence/agents/ifmib/fence_ifmib.py +++ b/fence/agents/ifmib/fence_ifmib.py @@ -93,10 +93,6 @@ def get_outlets_status(conn, options): return result -# Define new options -def ifmib_define_defaults(): - all_opt["snmp_version"]["default"]="2c" - # Main agent method def main(): global port_oid @@ -110,6 +106,7 @@ def main(): atexit.register(atexit_handler) snmp_define_defaults () + all_opt["snmp_version"]["default"]="2c" options=process_input(device_opt) diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py index 4c8f7ca..fca72a7 100644 --- a/fence/agents/ilo/fence_ilo.py +++ b/fence/agents/ilo/fence_ilo.py @@ -65,12 +65,9 @@ def main(): all_opt["login_timeout"]["default"] = "10" all_opt["retry_on"]["default"] = "3" + all_opt["ssl"]["default"] = "1" - pinput = process_input(device_opt) - pinput["-z"] = 1 - options = check_input(device_opt, pinput) - - LOGIN_TIMEOUT = 10 + options = check_input(device_opt, process_input(device_opt)) docs = { } docs["shortdesc"] = "Fence agent for HP iLO" diff --git a/fence/agents/ipdu/fence_ipdu.py b/fence/agents/ipdu/fence_ipdu.py index 2749e44..0243afd 100644 --- a/fence/agents/ipdu/fence_ipdu.py +++ b/fence/agents/ipdu/fence_ipdu.py @@ -129,13 +129,6 @@ def get_outlets_status(conn, options): return result -# Define new options -def ipdu_snmp_define_defaults(): - all_opt["snmp_version"]["default"]="3" - all_opt["community"]["default"]="private" - all_opt["switch"]["default"]="1" - device=IBMiPDU - # Main agent method def main(): device_opt = [ "ipaddr", "login", "passwd", "passwd_script", @@ -147,9 +140,12 @@ def main(): atexit.register(atexit_handler) snmp_define_defaults () - ipdu_snmp_define_defaults() + all_opt["snmp_version"]["default"] = "3" + all_opt["community"]["default"] = "private" + all_opt["switch"]["default"] = "1" + device = IBMiPDU - options=check_input(device_opt,process_input(device_opt)) + options = check_input(device_opt,process_input(device_opt)) docs = { } docs["shortdesc"] = "Fence agent for iPDU over SNMP" diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py index d106255..c9b5449 100644 --- a/fence/agents/ldom/fence_ldom.py +++ b/fence/agents/ldom/fence_ldom.py @@ -87,16 +87,9 @@ def main(): atexit.register(atexit_handler) - pinput = process_input(device_opt) - pinput["-x"] = 1 - options = check_input(device_opt, pinput) - - ## - ## Fence agent specific defaults - ##### - if (not options.has_key("-c")): - options["-c"] = "\ $" - + all_opt["secure"]["default"] = "1" + all_opt["cmd_prompt"]["default"] = [ "\ $" ] + docs = { } docs["shortdesc"] = "Fence agent for Sun LDOM" docs["longdesc"] = "fence_ldom is an I/O Fencing agent \ diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py index b9121e4..a5d4195 100644 --- a/fence/agents/lpar/fence_lpar.py +++ b/fence/agents/lpar/fence_lpar.py @@ -138,15 +138,10 @@ def main(): all_opt["login_timeout"]["default"] = "15" all_opt["secure"]["default"] = "1" + all_opt["cmd_prompt"]["default"] = [ ":~>", "]\$", "\$ " ] options = check_input(device_opt, process_input(device_opt)) - ## - ## Fence agent specific settings and default values - ##### - if 0 == options.has_key("-c"): - options["-c"] = [ ":~>", "]\$", "\$ " ] - docs = { } docs["shortdesc"] = "Fence agent for IBM LPAR" docs["longdesc"] = "" diff --git a/fence/agents/rsa/fence_rsa.py b/fence/agents/rsa/fence_rsa.py index 3ba2c80..44ad33f 100644 --- a/fence/agents/rsa/fence_rsa.py +++ b/fence/agents/rsa/fence_rsa.py @@ -50,14 +50,10 @@ def main(): atexit.register(atexit_handler) all_opt["login_timeout"]["default"] = 10 + all_opt["cmd_prompt"]["default"] = [ ">" ] + options = check_input(device_opt, process_input(device_opt)) - ## - ## Fence agent specific defaults - ##### - if 0 == options.has_key("-c"): - options["-c"] = ">" - # This device will not allow us to login even with LANG=C options["ssh_options"] = "-F /dev/null" diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py index bc3df9a..f8cd827 100755 --- a/fence/agents/rsb/fence_rsb.py +++ b/fence/agents/rsb/fence_rsb.py @@ -85,8 +85,6 @@ will block any necessary fencing actions." ## ## Operate the fencing device #### - print options["-u"] - conn = fence_login(options) result = fence_action(conn, options, set_power_status, get_power_status, None) diff --git a/fence/agents/sanbox2/fence_sanbox2.py b/fence/agents/sanbox2/fence_sanbox2.py index 8c67ac2..fdbea06 100644 --- a/fence/agents/sanbox2/fence_sanbox2.py +++ b/fence/agents/sanbox2/fence_sanbox2.py @@ -113,13 +113,9 @@ def main(): atexit.register(atexit_handler) - options = check_input(device_opt, process_input(device_opt)) + all_opt["cmd_prompt"]["default"] = [ " #> " ] - ## - ## Fence agent specific defaults - ##### - if 0 == options.has_key("-c"): - options["-c"] = [ " #> " ] + options = check_input(device_opt, process_input(device_opt)) docs = { } docs["shortdesc"] = "Fence agent for QLogic SANBox2 FC switches" diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py index 6e6a43d..f903184 100644 --- a/fence/agents/virsh/fence_virsh.py +++ b/fence/agents/virsh/fence_virsh.py @@ -77,13 +77,10 @@ def main(): atexit.register(atexit_handler) - pinput = process_input(device_opt) - pinput["-x"] = 1 - options = check_input(device_opt, pinput) + all_opt["secure"]["default"] = "1" + all_opt["cmd_prompt"]["default"] = [ "\[EXPECT\]#\ " ] - ## Defaults for fence agent - if 0 == options.has_key("-c"): - options["-c"] = "\[EXPECT\]#\ " + options = check_input(device_opt, process_input(device_opt)) options["ssh_options"]="-t '/bin/bash -c \"PS1=\[EXPECT\]#\ /bin/bash --noprofile --norc\"'" diff --git a/fence/agents/vmware/fence_vmware.py b/fence/agents/vmware/fence_vmware.py index 0b81d1d..885a876 100644 --- a/fence/agents/vmware/fence_vmware.py +++ b/fence/agents/vmware/fence_vmware.py @@ -256,10 +256,6 @@ def vmware_is_supported_vmrun_version(options): return True -# Define new options -def vmware_define_defaults(): - all_opt["vmware_type"]["default"]=VMWARE_DEFAULT_TYPE - # Check vmware type, set vmware_internal_type to one of VMWARE_TYPE_ value and # options["-e"] to path (if not specified) def vmware_check_vmware_type(options): @@ -290,13 +286,11 @@ def main(): atexit.register(atexit_handler) - vmware_define_defaults() + all_opt["secure"]["default"] = "1" + all_opt["vmware_type"]["default"] = VMWARE_DEFAULT_TYPE options = check_input(device_opt, process_input(device_opt)) - # Default is secure connection - options["-x"] = 1 - docs = { } docs["shortdesc"] = "Fence agent for VMWare" docs["longdesc"] = "fence_vmware is an I/O Fencing agent \ diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py index f013953..9aa9959 100644 --- a/fence/agents/wti/fence_wti.py +++ b/fence/agents/wti/fence_wti.py @@ -96,13 +96,9 @@ def main(): atexit.register(atexit_handler) - options = check_input(device_opt, process_input(device_opt)) + all_opt["cmd_prompt"]["default"] = [ "RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>", "VMR>" ] - ## - ## Fence agent specific defaults - ##### - if 0 == options.has_key("-c"): - options["-c"] = [ "RSM>", "MPC>", "IPS>", "TPS>", "NBB>", "NPS>", "VMR>" ] + options = check_input(device_opt, process_input(device_opt)) docs = { } docs["shortdesc"] = "Fence agent for WTI" diff --git a/fence/agents/xenapi/fence_xenapi.py b/fence/agents/xenapi/fence_xenapi.py index 0b07ed6..017908f 100644 --- a/fence/agents/xenapi/fence_xenapi.py +++ b/fence/agents/xenapi/fence_xenapi.py @@ -204,9 +204,7 @@ def main(): atexit.register(atexit_handler) - options=process_input(device_opt) - - options = check_input(device_opt, options) + options = check_input(device_opt, process_input(device_opt)) docs = { } docs["shortdesc"] = "XenAPI based fencing for the Citrix XenServer virtual machines." -- 1.7.7.6