All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/3] fencing: method cycle can be used with maximum 1 plug
       [not found] <1094783092.10919984.1389349066672.JavaMail.root@redhat.com>
@ 2014-01-10 10:44 ` Ondrej Mular
  0 siblings, 0 replies; only message in thread
From: Ondrej Mular @ 2014-01-10 10:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Checks input for invalid usage of cycle (method cycle and plug).

---
 fence/agents/lib/fencing.py.py | 27 ++++++---------------------
 1 file 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
 
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-10 10:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1094783092.10919984.1389349066672.JavaMail.root@redhat.com>
2014-01-10 10:44 ` [Cluster-devel] [PATCH 1/3] fencing: method cycle can be used with maximum 1 plug Ondrej Mular

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.