Commit beff3779 authored by René Nussbaumer's avatar René Nussbaumer

OpOobCommand: Adding power on delay

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.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent c4ec0755
......@@ -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:
......@@ -3312,7 +3314,7 @@ class LUOobCommand(NoHooksLU):
master_node = self.master_node
ret = []
for node in self.nodes:
for idx, node in enumerate(self.nodes):
node_entry = [(constants.RS_NORMAL, node.name)]
ret.append(node_entry)
......@@ -3366,6 +3368,10 @@ class LUOobCommand(NoHooksLU):
node_entry.append((constants.RS_NORMAL, result.payload))
if (self.op.command == constants.OOB_POWER_ON and
idx < len(self.nodes) - 1):
time.sleep(self.op.power_delay)
return ret
def _CheckPayload(self, result):
......
......@@ -702,6 +702,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"
......
......@@ -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.
......
......@@ -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"),
]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment