Revision 1c6e5787

b/lib/cmdlib.py
6090 6090

  
6091 6091
    self._migrater = TLMigrateInstance(self, self.op.instance_name,
6092 6092
                                       cleanup=self.op.cleanup,
6093
                                       iallocator=self.op.iallocator,
6094
                                       target_node=self.op.target_node,
6095 6093
                                       failover=False,
6096 6094
                                       fallback=self.op.allow_failover)
6097 6095
    self.tasklets = [self._migrater]
......
6353 6351
      logging.debug("Migrating instance %s", inst.name)
6354 6352
      names.append(inst.name)
6355 6353

  
6356
      tasklets.append(TLMigrateInstance(self, inst.name, cleanup=False,
6357
                                        iallocator=self.op.iallocator,
6358
                                        taget_node=None))
6354
      tasklets.append(TLMigrateInstance(self, inst.name, cleanup=False))
6359 6355

  
6360 6356
      if inst.disk_template in constants.DTS_EXT_MIRROR:
6361 6357
        # We need to lock all nodes, as the iallocator will choose the
......
6420 6416
  @ivar shutdown_timeout: In case of failover timeout of the shutdown
6421 6417

  
6422 6418
  """
6423
  def __init__(self, lu, instance_name, cleanup=False, iallocator=None,
6424
               target_node=None, failover=False, fallback=False,
6419
  def __init__(self, lu, instance_name, cleanup=False,
6420
               failover=False, fallback=False,
6425 6421
               ignore_consistency=False,
6426 6422
               shutdown_timeout=constants.DEFAULT_SHUTDOWN_TIMEOUT):
6427 6423
    """Initializes this class.
......
6433 6429
    self.instance_name = instance_name
6434 6430
    self.cleanup = cleanup
6435 6431
    self.live = False # will be overridden later
6436
    self.iallocator = iallocator
6437
    self.target_node = target_node
6438 6432
    self.failover = failover
6439 6433
    self.fallback = fallback
6440 6434
    self.ignore_consistency = ignore_consistency
......
6469 6463
    if instance.disk_template in constants.DTS_EXT_MIRROR:
6470 6464
      _CheckIAllocatorOrNode(self.lu, "iallocator", "target_node")
6471 6465

  
6472
      if self.iallocator:
6466
      if self.lu.op.iallocator:
6473 6467
        self._RunAllocator()
6468
      else:
6469
        # We set set self.target_node as it is required by
6470
        # BuildHooksEnv
6471
        self.target_node = self.lu.op.target_node
6474 6472

  
6475 6473
      # self.target_node is already populated, either directly or by the
6476 6474
      # iallocator run
......
6488 6486
                                        " %s disk template" %
6489 6487
                                        instance.disk_template)
6490 6488
      target_node = secondary_nodes[0]
6491
      if self.iallocator or (self.target_node and
6492
                             self.target_node != target_node):
6489
      if self.lu.op.iallocator or (self.target_node and
6490
                                   self.target_node != target_node):
6493 6491
        if self.failover:
6494 6492
          text = "failed over"
6495 6493
        else:
......
6566 6564
                                    self.instance.primary_node],
6567 6565
                     )
6568 6566

  
6569
    ial.Run(self.iallocator)
6567
    ial.Run(self.lu.op.iallocator)
6570 6568

  
6571 6569
    if not ial.success:
6572 6570
      raise errors.OpPrereqError("Can't compute nodes using"
6573 6571
                                 " iallocator '%s': %s" %
6574
                                 (self.iallocator, ial.info),
6572
                                 (self.lu.op.iallocator, ial.info),
6575 6573
                                 errors.ECODE_NORES)
6576 6574
    if len(ial.result) != ial.required_nodes:
6577 6575
      raise errors.OpPrereqError("iallocator '%s' returned invalid number"
6578 6576
                                 " of nodes (%s), required %s" %
6579
                                 (self.iallocator, len(ial.result),
6577
                                 (self.lu.op.iallocator, len(ial.result),
6580 6578
                                  ial.required_nodes), errors.ECODE_FAULT)
6581 6579
    self.target_node = ial.result[0]
6582 6580
    self.lu.LogInfo("Selected nodes for instance %s via iallocator %s: %s",
6583
                 self.instance_name, self.iallocator,
6581
                 self.instance_name, self.lu.op.iallocator,
6584 6582
                 utils.CommaJoin(ial.result))
6585 6583

  
6586 6584
  def _WaitUntilSync(self):

Also available in: Unified diff