|
|
035a21 |
--- a/fence/agents/lib/fencing.py.py.orig 2017-10-16 13:51:44.994248524 +0200
|
|
|
035a21 |
+++ b/fence/agents/lib/fencing.py.py 2017-10-16 14:09:05.576468918 +0200
|
|
|
035a21 |
@@ -938,7 +938,7 @@
|
|
|
035a21 |
|
|
|
035a21 |
return status
|
|
|
035a21 |
|
|
|
035a21 |
-def set_multi_power_fn(tn, options, set_power_fn, get_power_fn, retry_attempts = 1):
|
|
|
035a21 |
+def async_set_multi_power_fn(tn, options, set_power_fn, get_power_fn, retry_attempts):
|
|
|
035a21 |
plugs = options["--plugs"] if options.has_key("--plugs") else [""]
|
|
|
035a21 |
|
|
|
035a21 |
for _ in range(retry_attempts):
|
|
|
035a21 |
@@ -961,6 +961,39 @@
|
|
|
035a21 |
return True
|
|
|
035a21 |
return False
|
|
|
035a21 |
|
|
|
035a21 |
+def sync_set_multi_power_fn(tn, options, sync_set_power_fn, retry_attempts):
|
|
|
035a21 |
+ success = True
|
|
|
035a21 |
+ plugs = options["--plugs"] if options.has_key("--plugs") else [""]
|
|
|
035a21 |
+
|
|
|
035a21 |
+ for plug in plugs:
|
|
|
035a21 |
+ try:
|
|
|
035a21 |
+ options["--uuid"] = str(uuid.UUID(plug))
|
|
|
035a21 |
+ except ValueError:
|
|
|
035a21 |
+ pass
|
|
|
035a21 |
+ except KeyError:
|
|
|
035a21 |
+ pass
|
|
|
035a21 |
+
|
|
|
035a21 |
+ options["--plug"] = plug
|
|
|
035a21 |
+ for retry in range(retry_attempts):
|
|
|
035a21 |
+ if sync_set_power_fn(tn, options):
|
|
|
035a21 |
+ break
|
|
|
035a21 |
+ if retry == retry_attempts-1:
|
|
|
035a21 |
+ success = False
|
|
|
035a21 |
+ time.sleep(int(options["--power-wait"]))
|
|
|
035a21 |
+
|
|
|
035a21 |
+ return success
|
|
|
035a21 |
+
|
|
|
035a21 |
+def set_multi_power_fn(tn, options, set_power_fn, get_power_fn, sync_set_power_fn, retry_attempts=1):
|
|
|
035a21 |
+
|
|
|
035a21 |
+ if set_power_fn != None:
|
|
|
035a21 |
+ if get_power_fn != None:
|
|
|
035a21 |
+ return async_set_multi_power_fn(tn, options, set_power_fn, get_power_fn, retry_attempts)
|
|
|
035a21 |
+ elif sync_set_power_fn != None:
|
|
|
035a21 |
+ return sync_set_multi_power_fn(tn, options, sync_set_power_fn, retry_attempts)
|
|
|
035a21 |
+
|
|
|
035a21 |
+ return False
|
|
|
035a21 |
+
|
|
|
035a21 |
+
|
|
|
035a21 |
def show_docs(options, docs=None):
|
|
|
035a21 |
device_opt = options["device_opt"]
|
|
|
035a21 |
|
|
|
035a21 |
@@ -986,7 +1019,7 @@
|
|
|
035a21 |
print __main__.REDHAT_COPYRIGHT
|
|
|
035a21 |
sys.exit(0)
|
|
|
035a21 |
|
|
|
035a21 |
-def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list=None, reboot_cycle_fn=None):
|
|
|
035a21 |
+def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list=None, reboot_cycle_fn=None, sync_set_power_fn=None):
|
|
|
035a21 |
result = 0
|
|
|
035a21 |
|
|
|
035a21 |
try:
|
|
|
035a21 |
@@ -1042,12 +1075,12 @@
|
|
|
035a21 |
return 0
|
|
|
035a21 |
|
|
|
035a21 |
if options["--action"] == "on":
|
|
|
035a21 |
- if set_multi_power_fn(tn, options, set_power_fn, get_power_fn, 1 + int(options["--retry-on"])):
|
|
|
035a21 |
+ if set_multi_power_fn(tn, options, set_power_fn, get_power_fn, sync_set_power_fn, 1 + int(options["--retry-on"])):
|
|
|
035a21 |
print "Success: Powered ON"
|
|
|
035a21 |
else:
|
|
|
035a21 |
fail(EC_WAITING_ON)
|
|
|
035a21 |
elif options["--action"] == "off":
|
|
|
035a21 |
- if set_multi_power_fn(tn, options, set_power_fn, get_power_fn):
|
|
|
035a21 |
+ if set_multi_power_fn(tn, options, set_power_fn, get_power_fn, sync_set_power_fn):
|
|
|
035a21 |
print "Success: Powered OFF"
|
|
|
035a21 |
else:
|
|
|
035a21 |
fail(EC_WAITING_OFF)
|
|
|
035a21 |
@@ -1065,13 +1098,13 @@
|
|
|
035a21 |
else:
|
|
|
035a21 |
if status != "off":
|
|
|
035a21 |
options["--action"] = "off"
|
|
|
035a21 |
- if not set_multi_power_fn(tn, options, set_power_fn, get_power_fn):
|
|
|
035a21 |
+ if not set_multi_power_fn(tn, options, set_power_fn, get_power_fn, sync_set_power_fn):
|
|
|
035a21 |
fail(EC_WAITING_OFF)
|
|
|
035a21 |
|
|
|
035a21 |
options["--action"] = "on"
|
|
|
035a21 |
|
|
|
035a21 |
try:
|
|
|
035a21 |
- power_on = set_multi_power_fn(tn, options, set_power_fn, get_power_fn, int(options["--retry-on"]))
|
|
|
035a21 |
+ power_on = set_multi_power_fn(tn, options, set_power_fn, get_power_fn, sync_set_power_fn, int(options["--retry-on"]))
|
|
|
035a21 |
except Exception, ex:
|
|
|
035a21 |
# an error occured during power ON phase in reboot
|
|
|
035a21 |
# fence action was completed succesfully even in that case
|