Revision 85a87e21

b/doc/examples/gnt-debug/delayR.json
1
[
2
{"OP_ID": "OP_TEST_DELAY", "debug_level": 0, "dry_run": false, "duration": 0.0, "on_master": true, "on_nodes": [], "repeat": 5}
3
]
b/lib/cmdlib.py
9484 9484
  _OP_REQP = ["duration", "on_master", "on_nodes"]
9485 9485
  REQ_BGL = False
9486 9486

  
9487
  def CheckArguments(self):
9488
    # TODO: convert to the type system
9489
    self.op.repeat = getattr(self.op, "repeat", 0)
9490
    if self.op.repeat < 0:
9491
      raise errors.OpPrereqError("Repetition count cannot be negative")
9492

  
9487 9493
  def ExpandNames(self):
9488 9494
    """Expand names and set required locks.
9489 9495

  
......
9503 9509

  
9504 9510
    """
9505 9511

  
9506
  def Exec(self, feedback_fn):
9512
  def _TestDelay(self):
9507 9513
    """Do the actual sleep.
9508 9514

  
9509 9515
    """
......
9515 9521
      for node, node_result in result.items():
9516 9522
        node_result.Raise("Failure during rpc call to node %s" % node)
9517 9523

  
9524
  def Exec(self, feedback_fn):
9525
    """Execute the test delay opcode, with the wanted repetitions.
9526

  
9527
    """
9528
    if self.op.repeat == 0:
9529
      self._TestDelay()
9530
    else:
9531
      top_value = self.op.repeat - 1
9532
      for i in range(self.op.repeat):
9533
        self.LogInfo("Test delay iteration %d/%d" % (i, top_value))
9534
        self._TestDelay()
9535

  
9518 9536

  
9519 9537
class IAllocator(object):
9520 9538
  """IAllocator framework.
b/lib/opcodes.py
766 766
  """
767 767
  OP_ID = "OP_TEST_DELAY"
768 768
  OP_DSC_FIELD = "duration"
769
  __slots__ = ["duration", "on_master", "on_nodes"]
769
  __slots__ = ["duration", "on_master", "on_nodes", "repeat"]
770 770

  
771 771

  
772 772
class OpTestAllocator(OpCode):
b/scripts/gnt-debug
50 50
  delay = float(args[0])
51 51
  op = opcodes.OpTestDelay(duration=delay,
52 52
                           on_master=opts.on_master,
53
                           on_nodes=opts.on_nodes)
53
                           on_nodes=opts.on_nodes,
54
                           repeat=opts.repeat)
54 55
  SubmitOpCode(op, opts=opts)
55 56

  
56 57
  return 0
......
161 162
                action="store_false", help="Do not sleep in the master code"),
162 163
     cli_option("-n", dest="on_nodes", default=[],
163 164
                action="append", help="Select nodes to sleep on"),
165
     cli_option("-r", "--repeat", type="int", default="0", dest="repeat",
166
                help="Number of times to repeat the sleep"),
164 167
     ],
165 168
    "[opts...] <duration>", "Executes a TestDelay OpCode"),
166 169
  'submit-job': (

Also available in: Unified diff