From: Ondrej Mular <omular@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/4] fencing: new option --method
Date: Mon, 30 Dec 2013 11:24:41 -0500 (EST) [thread overview]
Message-ID: <220744167.7770282.1388420681942.JavaMail.root@redhat.com> (raw)
In-Reply-To: <1362796067.7767660.1388419178072.JavaMail.root@redhat.com>
Add new option method --method for cycle reboot
Checks input for invalid usage of cycle (method cycle and plug)
---
fence/agents/lib/fencing.py.py | 62 ++++++++++++++++++++++++++++--------------
1 file changed, 42 insertions(+), 20 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 2b914f2..ab14cb7 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -342,7 +342,16 @@ all_opt = {
"help" : "--use-sudo Use sudo (without password) when calling 3rd party software",
"required" : "0",
"shortdesc" : "Use sudo (without password) when calling 3rd party sotfware.",
- "order" : 205}
+ "order" : 205},
+ "method" : {
+ "getopt" : "m:",
+ "longopt" : "method",
+ "help" : "-m, --method=[method] Method to fence (offon|cycle) (Default: offon)",
+ "required" : "0",
+ "shortdesc" : "Method to fence (offon|cycle) (Default: offon)",
+ "default" : "offon",
+ "choices" : [ "offon", "cycle" ],
+ "order" : 1}
}
# options which are added automatically if 'key' is encountered ("default" is always added)
@@ -723,6 +732,9 @@ def check_input(device_opt, opt):
else:
options["--ipport"] = 23
+ if options.has_key("--plug") and options.has_key("--method") and options["--method"] == "cycle":
+ fail_usage("Failed: Cannot use --method cycle and --plug together")
+
for opt in device_opt:
if all_opt[opt].has_key("choices"):
long = "--" + all_opt[opt]["longopt"]
@@ -804,7 +816,7 @@ def show_docs(options, docs = None):
print __main__.REDHAT_COPYRIGHT
sys.exit(0)
-def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None):
+def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None, reboot_cycle_fn = None):
result = 0
try:
@@ -863,28 +875,38 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
else:
fail(EC_WAITING_OFF)
elif options["--action"] == "reboot":
- if status != "off":
- options["--action"] = "off"
- set_multi_power_fn(tn, options, set_power_fn)
- time.sleep(int(options["--power-wait"]))
- if wait_power_status(tn, options, get_power_fn) == 0:
- fail(EC_WAITING_OFF)
- options["--action"] = "on"
-
power_on = False
- try:
+ 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"])):
- set_multi_power_fn(tn, options, set_power_fn)
- time.sleep(int(options["--power-wait"]))
- if wait_power_status(tn, options, get_power_fn) == 1:
+ if reboot_cycle_fn(tn, options):
power_on = True
break
- except Exception, ex:
- # an error occured during power ON phase in reboot
- # fence action was completed succesfully even in that case
- sys.stderr.write(str(ex))
- syslog.syslog(syslog.LOG_NOTICE, str(ex))
- pass
+
+ if not power_on:
+ fail(EC_TIMED_OUT)
+
+ else:
+ if status != "off":
+ options["--action"] = "off"
+ set_multi_power_fn(tn, options, set_power_fn)
+ time.sleep(int(options["--power-wait"]))
+ if wait_power_status(tn, options, get_power_fn) == 0:
+ fail(EC_WAITING_OFF)
+ options["--action"] = "on"
+
+ try:
+ for _ in range(1, 1 + int(options["--retry-on"])):
+ set_multi_power_fn(tn, options, set_power_fn)
+ time.sleep(int(options["--power-wait"]))
+ if wait_power_status(tn, options, get_power_fn) == 1:
+ power_on = True
+ break
+ except Exception, ex:
+ # an error occured during power ON phase in reboot
+ # fence action was completed succesfully even in that case
+ sys.stderr.write(str(ex))
+ syslog.syslog(syslog.LOG_NOTICE, str(ex))
+ pass
if power_on == False:
# this should not fail as node was fenced succesfully
--
1.8.3.1
parent reply other threads:[~2013-12-30 16:24 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1362796067.7767660.1388419178072.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=220744167.7770282.1388420681942.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.