Revision a82ce292 lib/cmdlib.py

b/lib/cmdlib.py
261 261
    self.needed_locks[locking.LEVEL_INSTANCE] = expanded_name
262 262
    self.op.instance_name = expanded_name
263 263

  
264
  def _LockInstancesNodes(self):
264
  def _LockInstancesNodes(self, primary_only=False):
265 265
    """Helper function to declare instances' nodes for locking.
266 266

  
267 267
    This function should be called after locking one or more instances to lock
......
280 280
    if level == locking.LEVEL_NODE:
281 281
      self._LockInstancesNodes()
282 282

  
283
    @type primary_only: boolean
284
    @param primary_only: only lock primary nodes of locked instances
285

  
283 286
    """
284 287
    assert locking.LEVEL_NODE in self.recalculate_locks, \
285 288
      "_LockInstancesNodes helper function called with no nodes to recalculate"
......
293 296
    for instance_name in self.acquired_locks[locking.LEVEL_INSTANCE]:
294 297
      instance = self.context.cfg.GetInstanceInfo(instance_name)
295 298
      wanted_nodes.append(instance.primary_node)
296
      wanted_nodes.extend(instance.secondary_nodes)
299
      if not primary_only:
300
        wanted_nodes.extend(instance.secondary_nodes)
297 301
    self.needed_locks[locking.LEVEL_NODE] = wanted_nodes
298 302

  
299 303
    del self.recalculate_locks[locking.LEVEL_NODE]

Also available in: Unified diff