Revision 36870aa1 lib/cmdlib/test.py

b/lib/cmdlib/test.py
52 52
    This expands the node list, if any.
53 53

  
54 54
    """
55
    self.needed_locks = {}
56

  
57
    if self.op.on_nodes or self.op.on_master:
58
      self.needed_locks[locking.LEVEL_NODE] = []
59

  
55
    self.op.on_node_uuids = []
60 56
    if self.op.on_nodes:
61 57
      # _GetWantedNodes can be used here, but is not always appropriate to use
62 58
      # this way in ExpandNames. Check LogicalUnit.ExpandNames docstring for
63 59
      # more information.
64 60
      (self.op.on_node_uuids, self.op.on_nodes) = \
65 61
        GetWantedNodes(self, self.op.on_nodes)
66
      self.needed_locks[locking.LEVEL_NODE].extend(self.op.on_node_uuids)
67 62

  
68
    if self.op.on_master:
69
      # The node lock should be acquired for the master as well.
70
      self.needed_locks[locking.LEVEL_NODE].append(self.cfg.GetMasterNode())
63
    master_uuid = self.cfg.GetMasterNode()
64
    if self.op.on_master and master_uuid not in self.op.on_node_uuids:
65
      self.op.on_node_uuids.append(master_uuid)
66

  
67
    self.needed_locks = {}
68
    self.needed_locks[locking.LEVEL_NODE] = self.op.on_node_uuids
71 69

  
72 70
  def _TestDelay(self):
73 71
    """Do the actual sleep.
74 72

  
75 73
    """
76
    if self.op.on_master:
77
      if not utils.TestDelay(self.op.duration)[0]:
78
        raise errors.OpExecError("Error during master delay test")
79 74
    if self.op.on_node_uuids:
80 75
      result = self.rpc.call_test_delay(self.op.on_node_uuids, self.op.duration)
81 76
      for node_uuid, node_result in result.items():
82 77
        node_result.Raise("Failure during rpc call to node %s" %
83 78
                          self.cfg.GetNodeName(node_uuid))
79
    else:
80
      if not utils.TestDelay(self.op.duration)[0]:
81
        raise errors.OpExecError("Error during master delay test")
84 82

  
85 83
  def Exec(self, feedback_fn):
86 84
    """Execute the test delay opcode, with the wanted repetitions.

Also available in: Unified diff