Revision cf472233 lib/cmdlib.py

b/lib/cmdlib.py
2481 2481
  HPATH = "instance-remove"
2482 2482
  HTYPE = constants.HTYPE_INSTANCE
2483 2483
  _OP_REQP = ["instance_name", "ignore_failures"]
2484
  REQ_BGL = False
2485

  
2486
  def ExpandNames(self):
2487
    self._ExpandAndLockInstance()
2488
    self.needed_locks[locking.LEVEL_NODE] = []
2489
    self.recalculate_locks[locking.LEVEL_NODE] = constants.LOCKS_REPLACE
2490

  
2491
  def DeclareLocks(self, level):
2492
    if level == locking.LEVEL_NODE:
2493
      self._LockInstancesNodes()
2484 2494

  
2485 2495
  def BuildHooksEnv(self):
2486 2496
    """Build hooks env.
......
2498 2508
    This checks that the instance is in the cluster.
2499 2509

  
2500 2510
    """
2501
    instance = self.cfg.GetInstanceInfo(
2502
      self.cfg.ExpandInstanceName(self.op.instance_name))
2503
    if instance is None:
2504
      raise errors.OpPrereqError("Instance '%s' not known" %
2505
                                 self.op.instance_name)
2506
    self.instance = instance
2511
    self.instance = self.cfg.GetInstanceInfo(self.op.instance_name)
2512
    assert self.instance is not None, \
2513
      "Cannot retrieve locked instance %s" % self.op.instance_name
2507 2514

  
2508 2515
  def Exec(self, feedback_fn):
2509 2516
    """Remove the instance.
......
2531 2538
    logger.Info("removing instance %s out of cluster config" % instance.name)
2532 2539

  
2533 2540
    self.cfg.RemoveInstance(instance.name)
2534
    # Remove the new instance from the Ganeti Lock Manager
2535
    self.context.glm.remove(locking.LEVEL_INSTANCE, instance.name)
2541
    self.remove_locks[locking.LEVEL_INSTANCE] = instance.name
2536 2542

  
2537 2543

  
2538 2544
class LUQueryInstances(NoHooksLU):

Also available in: Unified diff