Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=fdd1e82d6... Commit: fdd1e82d67d19cf7e3ca685c120f8f36fe9ed6d6 Parent: 84f98fa327e0167f617a9f57afb1473e76422ed0 Author: Ondrej Mular omular@redhat.com AuthorDate: Fri Jan 10 05:44:06 2014 -0500 Committer: Marek 'marx' Grac mgrac@redhat.com CommitterDate: Fri Jan 10 13:52:42 2014 +0100
fencing: method cycle can be used with maximum 1 plug
Checks input for invalid usage of cycle (method cycle and plug).
Signed-off-by: Marek 'marx' Grac mgrac@redhat.com --- fence/agents/lib/fencing.py.py | 27 ++++++--------------------- 1 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index 5410176..9cc7407 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -348,7 +348,7 @@ all_opt = { "longopt" : "method", "help" : "-m, --method=[method] Method to fence (onoff|cycle) (Default: onoff)", "required" : "0", - "shortdesc" : "Method to fence (onoff|cycle) (Default: onoff)", + "shortdesc" : "Method to fence (onoff|cycle)", "default" : "onoff", "choices" : [ "onoff", "cycle" ], "order" : 1} @@ -732,6 +732,9 @@ def check_input(device_opt, opt): else: options["--ipport"] = 23
+ if options.has_key("--plug") and len(options["--plug"].split(",")) > 1 and options.has_key("--method") and options["--method"] == "cycle": + fail_usage("Failed: Cannot use --method cycle for more than 1 plug") + for opt in device_opt: if all_opt[opt].has_key("choices"): long = "--" + all_opt[opt]["longopt"] @@ -789,24 +792,6 @@ def set_multi_power_fn(tn, options, set_power_fn): else: set_power_fn(tn, options)
-def multi_reboot_cycle_fn(tn, options, reboot_cycle_fn): - success = False; - if options.has_key("--plugs"): - for plug in options["--plugs"]: - try: - options["--uuid"] = str(uuid.UUID(plug)) - except ValueError: - pass - except KeyError: - pass - options["--plug"] = plug - plug_status = reboot_cycle_fn(tn, options) - if plug_status: - success = plug_status - else: - success = reboot_cycle_fn(tn, options) - return success - def show_docs(options, docs = None): device_opt = options["device_opt"]
@@ -890,9 +875,9 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None fail(EC_WAITING_OFF) elif options["--action"] == "reboot": power_on = False - if options.has_key("--method") and options["--method"].lower() == "cycle": + if options.has_key("--method") and options["--method"].lower() == "cycle" and reboot_cycle_fn is not None: for _ in range(1, 1 + int(options["--retry-on"])): - if multi_reboot_cycle_fn(tn, options, reboot_cycle_fn): + if reboot_cycle_fn(tn, options): power_on = True break
cluster-commits@lists.fedorahosted.org