This delays the invocation of the power on of the next node. So if you
power on a bunch of nodes it will not blow the fuse.
---
lib/cmdlib.py | 6 ++++++
lib/constants.py | 1 +
lib/ht.py | 4 ++++
lib/opcodes.py | 2 ++
4 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 29ed69a..73df30d 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -3249,6 +3249,8 @@ class LUOobCommand(NoHooksLU):
self.nodes = []
self.master_node = self.cfg.GetMasterNode()
+ assert self.op.power_delay >= 0.0
+
if self.op.node_names:
if self.op.command in self._SKIP_MASTER:
if self.master_node in self.op.node_names:
@@ -3366,6 +3368,10 @@ class LUOobCommand(NoHooksLU):
node_entry.append((constants.RS_NORMAL, result.payload))
+ if (self.op.command == constants.OOB_POWER_ON and
+ node != self.nodes[-1]):
+ time.sleep(self.op.power_delay)
+
return ret
def _CheckPayload(self, result):
diff --git a/lib/constants.py b/lib/constants.py
index 033de03..bb22fba 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -696,6 +696,7 @@ OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF,
OOB_POWER_CYCLE,
OOB_POWER_STATUS_POWERED = "powered"
OOB_TIMEOUT = 60 # 60 seconds
+OOB_POWER_DELAY = 2.0 # 2 seconds
OOB_STATUS_OK = "OK"
OOB_STATUS_WARNING = "WARNING"
diff --git a/lib/ht.py b/lib/ht.py
index ffc6b44..f2fc0b3 100644
--- a/lib/ht.py
+++ b/lib/ht.py
@@ -267,6 +267,10 @@ TPositiveInt = \
TStrictPositiveInt = \
TAnd(TInt, WithDesc("GreaterThanZero")(lambda v: v > 0))
+#: a positive float
+TPositiveFloat = \
+ TAnd(TFloat, WithDesc("EqualGreaterZero")(lambda v: v >= 0.0))
+
def TListOf(my_type):
"""Checks if a given value is a list with all elements of the same type.
diff --git a/lib/opcodes.py b/lib/opcodes.py
index dffdcf3..d2bdaa3 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -678,6 +678,8 @@ class OpOobCommand(OpCode):
"Timeout before the OOB helper will be terminated"),
("ignore_status", False, ht.TBool,
"Ignores the node offline status for power off"),
+ ("power_delay", constants.OOB_POWER_DELAY, ht.TPositiveFloat,
+ "Time in seconds to wait between powering on nodes"),
]
--
1.7.3.1