Commit 8c35561f authored by Iustin Pop's avatar Iustin Pop
Browse files

Rename the OpMigrate* parameter 'live' to 'mode'



This is needed as now the parameter is no longer boolean, but tri-state.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 783a6c0b
...@@ -233,7 +233,7 @@ _PInstanceName = ("instance_name", _NoDefault, _TNonEmptyString) ...@@ -233,7 +233,7 @@ _PInstanceName = ("instance_name", _NoDefault, _TNonEmptyString)
_PNodeName = ("node_name", _NoDefault, _TNonEmptyString) _PNodeName = ("node_name", _NoDefault, _TNonEmptyString)
#: the migration type (live/non-live) #: the migration type (live/non-live)
_PMigrationLive = ("live", None, _TOr(_TNone, _PMigrationMode = ("mode", None, _TOr(_TNone,
_TElemOf(constants.HT_MIGRATION_MODES))) _TElemOf(constants.HT_MIGRATION_MODES)))
...@@ -5490,7 +5490,7 @@ class LUMigrateInstance(LogicalUnit): ...@@ -5490,7 +5490,7 @@ class LUMigrateInstance(LogicalUnit):
HTYPE = constants.HTYPE_INSTANCE HTYPE = constants.HTYPE_INSTANCE
_OP_PARAMS = [ _OP_PARAMS = [
_PInstanceName, _PInstanceName,
_PMigrationLive, _PMigrationMode,
("cleanup", False, _TBool), ("cleanup", False, _TBool),
] ]
...@@ -5520,7 +5520,7 @@ class LUMigrateInstance(LogicalUnit): ...@@ -5520,7 +5520,7 @@ class LUMigrateInstance(LogicalUnit):
source_node = instance.primary_node source_node = instance.primary_node
target_node = instance.secondary_nodes[0] target_node = instance.secondary_nodes[0]
env = _BuildInstanceHookEnvByObject(self, instance) env = _BuildInstanceHookEnvByObject(self, instance)
env["MIGRATE_LIVE"] = self.op.live env["MIGRATE_LIVE"] = self._migrater.live
env["MIGRATE_CLEANUP"] = self.op.cleanup env["MIGRATE_CLEANUP"] = self.op.cleanup
env.update({ env.update({
"OLD_PRIMARY": source_node, "OLD_PRIMARY": source_node,
...@@ -5721,7 +5721,7 @@ class LUMigrateNode(LogicalUnit): ...@@ -5721,7 +5721,7 @@ class LUMigrateNode(LogicalUnit):
HTYPE = constants.HTYPE_NODE HTYPE = constants.HTYPE_NODE
_OP_PARAMS = [ _OP_PARAMS = [
_PNodeName, _PNodeName,
_PMigrationLive, _PMigrationMode,
] ]
REQ_BGL = False REQ_BGL = False
...@@ -5769,6 +5769,13 @@ class LUMigrateNode(LogicalUnit): ...@@ -5769,6 +5769,13 @@ class LUMigrateNode(LogicalUnit):
class TLMigrateInstance(Tasklet): 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): def __init__(self, lu, instance_name, cleanup):
"""Initializes this class. """Initializes this class.
...@@ -5819,12 +5826,12 @@ class TLMigrateInstance(Tasklet): ...@@ -5819,12 +5826,12 @@ class TLMigrateInstance(Tasklet):
self.instance = instance self.instance = instance
if self.lu.op.live is None: if self.lu.op.mode is None:
# read the default value from the hypervisor # read the default value from the hypervisor
i_hv = self.cfg.GetClusterInfo().FillHV(instance, skip_globals=False) 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): def _WaitUntilSync(self):
"""Poll with custom rpc for disk sync. """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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -440,7 +440,7 @@ class OpMigrateNode(OpCode): ...@@ -440,7 +440,7 @@ class OpMigrateNode(OpCode):
OP_DSC_FIELD = "node_name" OP_DSC_FIELD = "node_name"
__slots__ = [ __slots__ = [
"node_name", "node_name",
"live", "mode",
] ]
...@@ -559,11 +559,12 @@ class OpMigrateInstance(OpCode): ...@@ -559,11 +559,12 @@ class OpMigrateInstance(OpCode):
node. node.
@ivar instance_name: the name of the instance @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_ID = "OP_INSTANCE_MIGRATE"
OP_DSC_FIELD = "instance_name" OP_DSC_FIELD = "instance_name"
__slots__ = ["instance_name", "live", "cleanup"] __slots__ = ["instance_name", "mode", "cleanup"]
class OpMoveInstance(OpCode): class OpMoveInstance(OpCode):
......
...@@ -903,11 +903,11 @@ def MigrateInstance(opts, args): ...@@ -903,11 +903,11 @@ def MigrateInstance(opts, args):
"--migration-mode options can be passed", "--migration-mode options can be passed",
errors.ECODE_INVAL) errors.ECODE_INVAL)
if not opts.live: # --non-live passed if not opts.live: # --non-live passed
live = constants.HT_MIGRATION_NONLIVE mode = constants.HT_MIGRATION_NONLIVE
else: 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) cleanup=opts.cleanup)
SubmitOpCode(op, cl=cl, opts=opts) SubmitOpCode(op, cl=cl, opts=opts)
return 0 return 0
......
...@@ -366,10 +366,10 @@ def MigrateNode(opts, args): ...@@ -366,10 +366,10 @@ def MigrateNode(opts, args):
"--migration-mode options can be passed", "--migration-mode options can be passed",
errors.ECODE_INVAL) errors.ECODE_INVAL)
if not opts.live: # --non-live passed if not opts.live: # --non-live passed
live = constants.HT_MIGRATION_NONLIVE mode = constants.HT_MIGRATION_NONLIVE
else: else:
live = opts.migration_mode mode = opts.migration_mode
op = opcodes.OpMigrateNode(node_name=args[0], live=live) op = opcodes.OpMigrateNode(node_name=args[0], mode=mode)
SubmitOpCode(op, cl=cl, opts=opts) SubmitOpCode(op, cl=cl, opts=opts)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment