--- /dev/null
+[
+{"OP_ID": "OP_TEST_DELAY", "debug_level": 0, "dry_run": false, "duration": 0.0, "on_master": true, "on_nodes": [], "repeat": 5}
+]
_OP_REQP = ["duration", "on_master", "on_nodes"]
REQ_BGL = False
+ def CheckArguments(self):
+ # TODO: convert to the type system
+ self.op.repeat = getattr(self.op, "repeat", 0)
+ if self.op.repeat < 0:
+ raise errors.OpPrereqError("Repetition count cannot be negative")
+
def ExpandNames(self):
"""Expand names and set required locks.
"""
- def Exec(self, feedback_fn):
+ def _TestDelay(self):
"""Do the actual sleep.
"""
for node, node_result in result.items():
node_result.Raise("Failure during rpc call to node %s" % node)
+ def Exec(self, feedback_fn):
+ """Execute the test delay opcode, with the wanted repetitions.
+
+ """
+ if self.op.repeat == 0:
+ self._TestDelay()
+ else:
+ top_value = self.op.repeat - 1
+ for i in range(self.op.repeat):
+ self.LogInfo("Test delay iteration %d/%d" % (i, top_value))
+ self._TestDelay()
+
class IAllocator(object):
"""IAllocator framework.
"""
OP_ID = "OP_TEST_DELAY"
OP_DSC_FIELD = "duration"
- __slots__ = ["duration", "on_master", "on_nodes"]
+ __slots__ = ["duration", "on_master", "on_nodes", "repeat"]
class OpTestAllocator(OpCode):
delay = float(args[0])
op = opcodes.OpTestDelay(duration=delay,
on_master=opts.on_master,
- on_nodes=opts.on_nodes)
+ on_nodes=opts.on_nodes,
+ repeat=opts.repeat)
SubmitOpCode(op, opts=opts)
return 0
action="store_false", help="Do not sleep in the master code"),
cli_option("-n", dest="on_nodes", default=[],
action="append", help="Select nodes to sleep on"),
+ cli_option("-r", "--repeat", type="int", default="0", dest="repeat",
+ help="Number of times to repeat the sleep"),
],
"[opts...] <duration>", "Executes a TestDelay OpCode"),
'submit-job': (