Revision c9e5c064 lib/cmdlib.py

b/lib/cmdlib.py
2580 2580
  HPATH = "instance-failover"
2581 2581
  HTYPE = constants.HTYPE_INSTANCE
2582 2582
  _OP_REQP = ["instance_name", "ignore_consistency"]
2583
  REQ_BGL = False
2584

  
2585
  def ExpandNames(self):
2586
    self._ExpandAndLockInstance()
2587
    self.needed_locks[locking.LEVEL_NODE] = []
2588
    self.recalculate_locks[locking.LEVEL_NODE] = 'replace'
2589

  
2590
  def DeclareLocks(self, level):
2591
    if level == locking.LEVEL_NODE:
2592
      self._LockInstancesNodes()
2583 2593

  
2584 2594
  def BuildHooksEnv(self):
2585 2595
    """Build hooks env.
......
2600 2610
    This checks that the instance is in the cluster.
2601 2611

  
2602 2612
    """
2603
    instance = self.cfg.GetInstanceInfo(
2604
      self.cfg.ExpandInstanceName(self.op.instance_name))
2605
    if instance is None:
2606
      raise errors.OpPrereqError("Instance '%s' not known" %
2607
                                 self.op.instance_name)
2613
    self.instance = instance = self.cfg.GetInstanceInfo(self.op.instance_name)
2614
    assert self.instance is not None, \
2615
      "Cannot retrieve locked instance %s" % self.op.instance_name
2608 2616

  
2609 2617
    if instance.disk_template not in constants.DTS_NET_MIRROR:
2610 2618
      raise errors.OpPrereqError("Instance's disk layout is not"
......
2627 2635
                                 " exist on destination node '%s'" %
2628 2636
                                 (brlist, target_node))
2629 2637

  
2630
    self.instance = instance
2631

  
2632 2638
  def Exec(self, feedback_fn):
2633 2639
    """Failover an instance.
2634 2640

  

Also available in: Unified diff