From 05bfc15535f3d28af5f09a9a8fedd16ab45c24d3 Mon Sep 17 00:00:00 2001 From: Marek 'marx' Grac Date: Mon, 29 Jun 2015 19:55:00 +0200 Subject: [PATCH 6/6] fencing: Introduce option --port-as-ip (port_as_ip on stdin) Pacemaker's mapping between fence devices and appropriate ports works fine. But if fence device is used only for single device (IPMI, iLO, DRAC, ...) then configuration is more complex. With this new option, user can use --plug/-n/port to specify IP address what simplify configuration. Resolves: rhbz#1214522 --- fence/agents/lib/fencing.py.py | 30 +++++++++++++++- tests/data/metadata/fence_alom.xml | 10 ++++++ tests/data/metadata/fence_amt.xml | 10 ++++++ tests/data/metadata/fence_drac.xml | 64 ++++++++++++++++++++-------------- tests/data/metadata/fence_dummy.xml | 15 +++++--- tests/data/metadata/fence_hpblade.xml | 4 +-- tests/data/metadata/fence_idrac.xml | 10 ++++++ tests/data/metadata/fence_ilo.xml | 10 ++++++ tests/data/metadata/fence_ilo2.xml | 10 ++++++ tests/data/metadata/fence_ilo3.xml | 10 ++++++ tests/data/metadata/fence_ilo3_ssh.xml | 10 ++++++ tests/data/metadata/fence_ilo4.xml | 10 ++++++ tests/data/metadata/fence_ilo4_ssh.xml | 10 ++++++ tests/data/metadata/fence_ilo_mp.xml | 10 ++++++ tests/data/metadata/fence_ilo_ssh.xml | 10 ++++++ tests/data/metadata/fence_imm.xml | 10 ++++++ tests/data/metadata/fence_ipmilan.xml | 10 ++++++ tests/data/metadata/fence_mpath.xml | 54 ++++++++++++++++------------ tests/data/metadata/fence_rsa.xml | 10 ++++++ tests/data/metadata/fence_rsb.xml | 10 ++++++ 20 files changed, 260 insertions(+), 57 deletions(-) diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index db620e8..2ba98b8 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -399,6 +399,13 @@ all_opt = { "default" : "onoff", "choices" : ["onoff", "cycle"], "order" : 1}, + "port_as_ip": { + "getopt" : "", + "longopt" : "port-as-ip", + "help" : "--port-as-ip Make \"port/plug\" to be an alias to IP address", + "required" : "0", + "shortdesc" : "Make \"port/plug\" to be an alias to IP address", + "order" : 200}, "on_target": { "getopt" : "", "help" : "", @@ -451,6 +458,13 @@ def add_dependency_options(options): for opt in options + ["default"]: if DEPENDENCY_OPT.has_key(opt): added_opt.extend([y for y in DEPENDENCY_OPT[opt] if options.count(y) == 0]) + + if not "port" in (options + added_opt) and not "nodename" in (options + added_opt): + added_opt.append("port_as_ip") + all_opt["port"]["help"] = "-n, --plug=[ip] IP address or hostname of fencing device " \ + "(together with --port-as-ip)" + all_opt["port"]["shortdesc"] = "IP address or hostname of fencing device (together with --port-as-ip)" + return added_opt def fail_usage(message=""): @@ -580,6 +594,9 @@ def process_input(avail_opt): os.putenv("LANG", "C") os.putenv("LC_ALL", "C") + if "port_as_ip" in avail_opt: + avail_opt.append("port") + ## ## Prepare list of options for getopt ##### @@ -653,6 +670,10 @@ def process_input(avail_opt): opt["--"+all_opt[name]["longopt"].rstrip(":")] = value elif value.lower() in ["1", "yes", "on", "true"]: opt["--"+all_opt[name]["longopt"]] = "1" + + if "--port-as-ip" in opt and "--plug" in opt: + opt["--ip"] = opt["--plug"] + return opt ## @@ -755,6 +776,10 @@ def check_input(device_opt, opt): options["--action"] = "off" ## automatic detection and set of valid UUID from --plug + + if "port_as_ip" in device_opt and not "--port-as-ip" in options and "--plug" in options: + fail_usage("Parser error: option -n/--plug is not recognized") + if not options.has_key("--username") and \ device_opt.count("login") and (device_opt.count("no_login") == 0): fail_usage("Failed: You have to set login name") @@ -779,7 +804,8 @@ def check_input(device_opt, opt): fail_usage("Failed: Identity file " + options["--identity-file"] + " does not exist") if (0 == ["list", "monitor"].count(options["--action"])) and \ - not options.has_key("--plug") and device_opt.count("port") and device_opt.count("no_port") == 0: + not options.has_key("--plug") and device_opt.count("port") and \ + device_opt.count("no_port") == 0 and not device_opt.count("port_as_ip"): fail_usage("Failed: You have to enter plug number or machine identification") if options.has_key("--password-script"): @@ -874,6 +900,8 @@ def show_docs(options, docs=None): sys.exit(0) if options.get("--action", "") == "metadata": + if "port_as_ip" in device_opt: + device_opt.remove("separator") metadata(device_opt, options, docs) sys.exit(0) diff --git a/tests/data/metadata/fence_alom.xml b/tests/data/metadata/fence_alom.xml index 6bdefb7..32e6630 100644 --- a/tests/data/metadata/fence_alom.xml +++ b/tests/data/metadata/fence_alom.xml @@ -13,6 +13,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -108,6 +113,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_amt.xml b/tests/data/metadata/fence_amt.xml index b967b68..8524180 100644 --- a/tests/data/metadata/fence_amt.xml +++ b/tests/data/metadata/fence_amt.xml @@ -8,6 +8,11 @@ TCP/UDP port to use for connection with device + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -107,6 +112,11 @@ Path to amttool binary + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_drac.xml b/tests/data/metadata/fence_drac.xml index d2871c5..d480669 100644 --- a/tests/data/metadata/fence_drac.xml +++ b/tests/data/metadata/fence_drac.xml @@ -8,6 +8,11 @@ TCP/UDP port to use for connection with device + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -18,36 +23,36 @@ Forces agent to use IPv6 addresses only - - - - Login password or passphrase - IP Address or Hostname - - - - Fencing Action - Forces agent to use IPv4 addresses only - - - - Login Name - Script to retrieve password + + + + Login password or passphrase + + + + + Fencing Action + + + + + Login Name + @@ -68,30 +73,35 @@ Display help and exit + + + + Wait X seconds after issuing ON/OFF + + + + + Wait X seconds for cmd prompt after login + Test X seconds for status change after ON/OFF - - + + - Wait X seconds after issuing ON/OFF + Wait X seconds before fencing is started Wait X seconds for cmd prompt after issuing command - - - - Wait X seconds before fencing is started - - - - - Wait X seconds for cmd prompt after login + + + + Make "port/plug" to be an alias to IP address diff --git a/tests/data/metadata/fence_dummy.xml b/tests/data/metadata/fence_dummy.xml index 61c964e..9295544 100644 --- a/tests/data/metadata/fence_dummy.xml +++ b/tests/data/metadata/fence_dummy.xml @@ -3,6 +3,11 @@ fence_dummy http://www.example.com + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -43,11 +48,6 @@ Display help and exit - - - - Separator for CSV created by operation list - @@ -63,6 +63,11 @@ Test X seconds for status change after ON/OFF + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_hpblade.xml b/tests/data/metadata/fence_hpblade.xml index 4f0976b..a8a2b3a 100644 --- a/tests/data/metadata/fence_hpblade.xml +++ b/tests/data/metadata/fence_hpblade.xml @@ -1,6 +1,6 @@ -fence_hpblade is an I/O Fencing agent which can be used with HP BladeSystem. It logs into an enclosure via telnet or ssh and uses the command line interface to power on and off blades. +fence_hpblade is an I/O Fencing agent which can be used with HP BladeSystem and HP Integrity Superdome X. It logs into the onboard administrator of an enclosure via telnet or ssh and uses the command line interface to power blades or partitions on or off. http://www.hp.com @@ -100,7 +100,7 @@ - + Wait X seconds for cmd prompt after login diff --git a/tests/data/metadata/fence_idrac.xml b/tests/data/metadata/fence_idrac.xml index dcb3235..41ab729 100644 --- a/tests/data/metadata/fence_idrac.xml +++ b/tests/data/metadata/fence_idrac.xml @@ -12,6 +12,11 @@ TCP/UDP port to use for connection with device + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -134,6 +139,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ilo.xml b/tests/data/metadata/fence_ilo.xml index ae7fe9c..bcb3d15 100644 --- a/tests/data/metadata/fence_ilo.xml +++ b/tests/data/metadata/fence_ilo.xml @@ -39,6 +39,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -119,6 +124,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ilo2.xml b/tests/data/metadata/fence_ilo2.xml index 19a31a1..95bf32a 100644 --- a/tests/data/metadata/fence_ilo2.xml +++ b/tests/data/metadata/fence_ilo2.xml @@ -39,6 +39,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -119,6 +124,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ilo3.xml b/tests/data/metadata/fence_ilo3.xml index e6a48bc..e09e5e1 100644 --- a/tests/data/metadata/fence_ilo3.xml +++ b/tests/data/metadata/fence_ilo3.xml @@ -12,6 +12,11 @@ TCP/UDP port to use for connection with device + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -134,6 +139,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ilo3_ssh.xml b/tests/data/metadata/fence_ilo3_ssh.xml index b3531b2..1bf85e7 100644 --- a/tests/data/metadata/fence_ilo3_ssh.xml +++ b/tests/data/metadata/fence_ilo3_ssh.xml @@ -15,6 +15,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -118,6 +123,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ilo4.xml b/tests/data/metadata/fence_ilo4.xml index e7b0d60..9450e56 100644 --- a/tests/data/metadata/fence_ilo4.xml +++ b/tests/data/metadata/fence_ilo4.xml @@ -12,6 +12,11 @@ TCP/UDP port to use for connection with device + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -134,6 +139,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ilo4_ssh.xml b/tests/data/metadata/fence_ilo4_ssh.xml index 2266ee1..3779ce7 100644 --- a/tests/data/metadata/fence_ilo4_ssh.xml +++ b/tests/data/metadata/fence_ilo4_ssh.xml @@ -15,6 +15,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -118,6 +123,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ilo_mp.xml b/tests/data/metadata/fence_ilo_mp.xml index 93503a0..145fb36 100644 --- a/tests/data/metadata/fence_ilo_mp.xml +++ b/tests/data/metadata/fence_ilo_mp.xml @@ -13,6 +13,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -108,6 +113,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ilo_ssh.xml b/tests/data/metadata/fence_ilo_ssh.xml index a9bd1d3..6eb4ae4 100644 --- a/tests/data/metadata/fence_ilo_ssh.xml +++ b/tests/data/metadata/fence_ilo_ssh.xml @@ -15,6 +15,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -118,6 +123,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_imm.xml b/tests/data/metadata/fence_imm.xml index 8fbdddd..2e7d65c 100644 --- a/tests/data/metadata/fence_imm.xml +++ b/tests/data/metadata/fence_imm.xml @@ -12,6 +12,11 @@ TCP/UDP port to use for connection with device + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -134,6 +139,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_ipmilan.xml b/tests/data/metadata/fence_ipmilan.xml index 199490c..ae528de 100644 --- a/tests/data/metadata/fence_ipmilan.xml +++ b/tests/data/metadata/fence_ipmilan.xml @@ -12,6 +12,11 @@ TCP/UDP port to use for connection with device + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -134,6 +139,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_mpath.xml b/tests/data/metadata/fence_mpath.xml index c62dd49..ccd41ff 100644 --- a/tests/data/metadata/fence_mpath.xml +++ b/tests/data/metadata/fence_mpath.xml @@ -4,20 +4,25 @@ The fence_mpath agent works by having an unique key for each pair of node and device that has to be set also in /etc/multipath.conf. Once registered, a single node will become the reservation holder by creating a "write exclusive, registrants only" reservation on the device(s). The result is that only registered nodes may write to the device(s). When a node failure occurs, the fence_mpath agent will remove the key belonging to the failed node from the device(s). The failed node will no longer be able to write to the device(s). A manual reboot is required. https://www.sourceware.org/dm/ - - + + - List of devices to use for current operation. Devices can be comma-separated list of device-mapper multipath devices (eg. /dev/dm-3). Each device must support SCSI-3 persistent reservations. + IP address or hostname of fencing device (together with --port-as-ip) + + + + + Fencing Action Key to use for the current operation. This key should be unique to a node and have to be written in /etc/multipath.conf. For the "on" action, the key specifies the key use to register the local node. For the "off" action, this key specifies the key to be removed from the device(s). - - - - Fencing Action + + + + List of devices to use for current operation. Devices can be comma-separated list of device-mapper multipath devices (eg. /dev/dm-3). Each device must support SCSI-3 persistent reservations. @@ -39,11 +44,31 @@ The fence_mpath agent works by having an unique key for each pair of node and de Display help and exit + + + + Wait X seconds after issuing ON/OFF + + + + + Wait X seconds for cmd prompt after login + + + + + Make "port/plug" to be an alias to IP address + Wait X seconds before fencing is started + + + + Path to mpathpersist binary + @@ -59,21 +84,6 @@ The fence_mpath agent works by having an unique key for each pair of node and de Test X seconds for status change after ON/OFF - - - - Wait X seconds after issuing ON/OFF - - - - - Wait X seconds for cmd prompt after login - - - - - Path to mpathpersist binary - diff --git a/tests/data/metadata/fence_rsa.xml b/tests/data/metadata/fence_rsa.xml index 749b21d..aa9caaa 100644 --- a/tests/data/metadata/fence_rsa.xml +++ b/tests/data/metadata/fence_rsa.xml @@ -13,6 +13,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -108,6 +113,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + diff --git a/tests/data/metadata/fence_rsb.xml b/tests/data/metadata/fence_rsb.xml index 56421fc..b400d7e 100644 --- a/tests/data/metadata/fence_rsb.xml +++ b/tests/data/metadata/fence_rsb.xml @@ -13,6 +13,11 @@ IP Address or Hostname + + + + IP address or hostname of fencing device (together with --port-as-ip) + @@ -108,6 +113,11 @@ Wait X seconds for cmd prompt after issuing command + + + + Make "port/plug" to be an alias to IP address + -- 1.9.3