Revision 1986b21f

b/lib/cmdlib.py
349 349
                                                self.op.instance_name)
350 350
    self.needed_locks[locking.LEVEL_INSTANCE] = self.op.instance_name
351 351

  
352
  def _LockInstancesNodes(self, primary_only=False):
352
  def _LockInstancesNodes(self, primary_only=False,
353
                          level=locking.LEVEL_NODE):
353 354
    """Helper function to declare instances' nodes for locking.
354 355

  
355 356
    This function should be called after locking one or more instances to lock
......
370 371

  
371 372
    @type primary_only: boolean
372 373
    @param primary_only: only lock primary nodes of locked instances
374
    @param level: Which lock level to use for locking nodes
373 375

  
374 376
    """
375
    assert locking.LEVEL_NODE in self.recalculate_locks, \
377
    assert level in self.recalculate_locks, \
376 378
      "_LockInstancesNodes helper function called with no nodes to recalculate"
377 379

  
378 380
    # TODO: check if we're really been called with the instance locks held
......
387 389
      if not primary_only:
388 390
        wanted_nodes.extend(instance.secondary_nodes)
389 391

  
390
    if self.recalculate_locks[locking.LEVEL_NODE] == constants.LOCKS_REPLACE:
391
      self.needed_locks[locking.LEVEL_NODE] = wanted_nodes
392
    elif self.recalculate_locks[locking.LEVEL_NODE] == constants.LOCKS_APPEND:
393
      self.needed_locks[locking.LEVEL_NODE].extend(wanted_nodes)
392
    if self.recalculate_locks[level] == constants.LOCKS_REPLACE:
393
      self.needed_locks[level] = wanted_nodes
394
    elif self.recalculate_locks[level] == constants.LOCKS_APPEND:
395
      self.needed_locks[level].extend(wanted_nodes)
396
    else:
397
      raise errors.ProgrammerError("Unknown recalculation mode")
394 398

  
395
    del self.recalculate_locks[locking.LEVEL_NODE]
399
    del self.recalculate_locks[level]
396 400

  
397 401

  
398 402
class NoHooksLU(LogicalUnit): # pylint: disable=W0223

Also available in: Unified diff