Revision 8c35561f

b/lib/cmdlib.py
233 233
_PNodeName = ("node_name", _NoDefault, _TNonEmptyString)
234 234

  
235 235
#: the migration type (live/non-live)
236
_PMigrationLive = ("live", None, _TOr(_TNone,
236
_PMigrationMode = ("mode", None, _TOr(_TNone,
237 237
                                      _TElemOf(constants.HT_MIGRATION_MODES)))
238 238

  
239 239

  
......
5490 5490
  HTYPE = constants.HTYPE_INSTANCE
5491 5491
  _OP_PARAMS = [
5492 5492
    _PInstanceName,
5493
    _PMigrationLive,
5493
    _PMigrationMode,
5494 5494
    ("cleanup", False, _TBool),
5495 5495
    ]
5496 5496

  
......
5520 5520
    source_node = instance.primary_node
5521 5521
    target_node = instance.secondary_nodes[0]
5522 5522
    env = _BuildInstanceHookEnvByObject(self, instance)
5523
    env["MIGRATE_LIVE"] = self.op.live
5523
    env["MIGRATE_LIVE"] = self._migrater.live
5524 5524
    env["MIGRATE_CLEANUP"] = self.op.cleanup
5525 5525
    env.update({
5526 5526
        "OLD_PRIMARY": source_node,
......
5721 5721
  HTYPE = constants.HTYPE_NODE
5722 5722
  _OP_PARAMS = [
5723 5723
    _PNodeName,
5724
    _PMigrationLive,
5724
    _PMigrationMode,
5725 5725
    ]
5726 5726
  REQ_BGL = False
5727 5727

  
......
5769 5769

  
5770 5770

  
5771 5771
class TLMigrateInstance(Tasklet):
5772
  """Tasklet class for instance migration.
5773

  
5774
  @type live: boolean
5775
  @ivar live: whether the migration will be done live or non-live;
5776
      this variable is initalized only after CheckPrereq has run
5777

  
5778
  """
5772 5779
  def __init__(self, lu, instance_name, cleanup):
5773 5780
    """Initializes this class.
5774 5781

  
......
5819 5826

  
5820 5827
    self.instance = instance
5821 5828

  
5822
    if self.lu.op.live is None:
5829
    if self.lu.op.mode is None:
5823 5830
      # read the default value from the hypervisor
5824 5831
      i_hv = self.cfg.GetClusterInfo().FillHV(instance, skip_globals=False)
5825
      self.lu.op.live = i_hv[constants.HV_MIGRATION_MODE]
5832
      self.lu.op.mode = i_hv[constants.HV_MIGRATION_MODE]
5826 5833

  
5827
    self.live = self.lu.op.live == constants.HT_MIGRATION_LIVE
5834
    self.live = self.lu.op.mode == constants.HT_MIGRATION_LIVE
5828 5835

  
5829 5836
  def _WaitUntilSync(self):
5830 5837
    """Poll with custom rpc for disk sync.
b/lib/opcodes.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007 Google Inc.
4
# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
440 440
  OP_DSC_FIELD = "node_name"
441 441
  __slots__ = [
442 442
    "node_name",
443
    "live",
443
    "mode",
444 444
    ]
445 445

  
446 446

  
......
559 559
  node.
560 560

  
561 561
  @ivar instance_name: the name of the instance
562
  @ivar mode: the migration mode (live, non-live or None for auto)
562 563

  
563 564
  """
564 565
  OP_ID = "OP_INSTANCE_MIGRATE"
565 566
  OP_DSC_FIELD = "instance_name"
566
  __slots__ = ["instance_name", "live", "cleanup"]
567
  __slots__ = ["instance_name", "mode", "cleanup"]
567 568

  
568 569

  
569 570
class OpMoveInstance(OpCode):
b/scripts/gnt-instance
903 903
                               "--migration-mode options can be passed",
904 904
                               errors.ECODE_INVAL)
905 905
  if not opts.live: # --non-live passed
906
    live = constants.HT_MIGRATION_NONLIVE
906
    mode = constants.HT_MIGRATION_NONLIVE
907 907
  else:
908
    live = opts.migration_mode
908
    mode = opts.migration_mode
909 909

  
910
  op = opcodes.OpMigrateInstance(instance_name=instance_name, live=live,
910
  op = opcodes.OpMigrateInstance(instance_name=instance_name, mode=mode,
911 911
                                 cleanup=opts.cleanup)
912 912
  SubmitOpCode(op, cl=cl, opts=opts)
913 913
  return 0
b/scripts/gnt-node
366 366
                               "--migration-mode options can be passed",
367 367
                               errors.ECODE_INVAL)
368 368
  if not opts.live: # --non-live passed
369
    live = constants.HT_MIGRATION_NONLIVE
369
    mode = constants.HT_MIGRATION_NONLIVE
370 370
  else:
371
    live = opts.migration_mode
372
  op = opcodes.OpMigrateNode(node_name=args[0], live=live)
371
    mode = opts.migration_mode
372
  op = opcodes.OpMigrateNode(node_name=args[0], mode=mode)
373 373
  SubmitOpCode(op, cl=cl, opts=opts)
374 374

  
375 375

  

Also available in: Unified diff