_PNodeName = ("node_name", _NoDefault, _TNonEmptyString)
#: the migration type (live/non-live)
-_PMigrationLive = ("live", None, _TOr(_TNone,
+_PMigrationMode = ("mode", None, _TOr(_TNone,
_TElemOf(constants.HT_MIGRATION_MODES)))
HTYPE = constants.HTYPE_INSTANCE
_OP_PARAMS = [
_PInstanceName,
- _PMigrationLive,
+ _PMigrationMode,
("cleanup", False, _TBool),
]
source_node = instance.primary_node
target_node = instance.secondary_nodes[0]
env = _BuildInstanceHookEnvByObject(self, instance)
- env["MIGRATE_LIVE"] = self.op.live
+ env["MIGRATE_LIVE"] = self._migrater.live
env["MIGRATE_CLEANUP"] = self.op.cleanup
env.update({
"OLD_PRIMARY": source_node,
HTYPE = constants.HTYPE_NODE
_OP_PARAMS = [
_PNodeName,
- _PMigrationLive,
+ _PMigrationMode,
]
REQ_BGL = False
class TLMigrateInstance(Tasklet):
+ """Tasklet class for instance migration.
+
+ @type live: boolean
+ @ivar live: whether the migration will be done live or non-live;
+ this variable is initalized only after CheckPrereq has run
+
+ """
def __init__(self, lu, instance_name, cleanup):
"""Initializes this class.
self.instance = instance
- if self.lu.op.live is None:
+ if self.lu.op.mode is None:
# read the default value from the hypervisor
i_hv = self.cfg.GetClusterInfo().FillHV(instance, skip_globals=False)
- self.lu.op.live = i_hv[constants.HV_MIGRATION_MODE]
+ self.lu.op.mode = i_hv[constants.HV_MIGRATION_MODE]
- self.live = self.lu.op.live == constants.HT_MIGRATION_LIVE
+ self.live = self.lu.op.mode == constants.HT_MIGRATION_LIVE
def _WaitUntilSync(self):
"""Poll with custom rpc for disk sync.
#
#
-# Copyright (C) 2006, 2007 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
OP_DSC_FIELD = "node_name"
__slots__ = [
"node_name",
- "live",
+ "mode",
]
node.
@ivar instance_name: the name of the instance
+ @ivar mode: the migration mode (live, non-live or None for auto)
"""
OP_ID = "OP_INSTANCE_MIGRATE"
OP_DSC_FIELD = "instance_name"
- __slots__ = ["instance_name", "live", "cleanup"]
+ __slots__ = ["instance_name", "mode", "cleanup"]
class OpMoveInstance(OpCode):
"--migration-mode options can be passed",
errors.ECODE_INVAL)
if not opts.live: # --non-live passed
- live = constants.HT_MIGRATION_NONLIVE
+ mode = constants.HT_MIGRATION_NONLIVE
else:
- live = opts.migration_mode
+ mode = opts.migration_mode
- op = opcodes.OpMigrateInstance(instance_name=instance_name, live=live,
+ op = opcodes.OpMigrateInstance(instance_name=instance_name, mode=mode,
cleanup=opts.cleanup)
SubmitOpCode(op, cl=cl, opts=opts)
return 0
"--migration-mode options can be passed",
errors.ECODE_INVAL)
if not opts.live: # --non-live passed
- live = constants.HT_MIGRATION_NONLIVE
+ mode = constants.HT_MIGRATION_NONLIVE
else:
- live = opts.migration_mode
- op = opcodes.OpMigrateNode(node_name=args[0], live=live)
+ mode = opts.migration_mode
+ op = opcodes.OpMigrateNode(node_name=args[0], mode=mode)
SubmitOpCode(op, cl=cl, opts=opts)