All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ondrej Mular <omular@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/3] fencing: method cycle can be used with maximum 1 plug
Date: Fri, 10 Jan 2014 05:44:06 -0500 (EST)	[thread overview]
Message-ID: <536023710.10929978.1389350646651.JavaMail.root@redhat.com> (raw)
In-Reply-To: <1094783092.10919984.1389349066672.JavaMail.root@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



           reply	other threads:[~2014-01-10 10:44 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1094783092.10919984.1389349066672.JavaMail.root@redhat.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=536023710.10929978.1389350646651.JavaMail.root@redhat.com \
    --to=omular@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.