Re-add the 'live' parameter to migration opcodes
authorIustin Pop <iustin@google.com>
Tue, 17 Aug 2010 12:18:34 +0000 (14:18 +0200)
committerIustin Pop <iustin@google.com>
Tue, 17 Aug 2010 12:36:46 +0000 (14:36 +0200)
This patch reintroduces the live parameter, for backwards compatibility
at the Luxi level. This way, clients can work transparently with both
2.1 and 2.2, even though sub-optimally.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/cmdlib.py
lib/opcodes.py

index cccfa3a..93d5ff0 100644 (file)
@@ -236,6 +236,9 @@ _PNodeName = ("node_name", _NoDefault, _TNonEmptyString)
 _PMigrationMode = ("mode", None, _TOr(_TNone,
                                       _TElemOf(constants.HT_MIGRATION_MODES)))
 
+#: the obsolete 'live' mode (boolean)
+_PMigrationLive = ("live", None, _TMaybeBool)
+
 
 # End types
 class LogicalUnit(object):
@@ -5512,6 +5515,7 @@ class LUMigrateInstance(LogicalUnit):
   _OP_PARAMS = [
     _PInstanceName,
     _PMigrationMode,
+    _PMigrationLive,
     ("cleanup", False, _TBool),
     ]
 
@@ -5743,6 +5747,7 @@ class LUMigrateNode(LogicalUnit):
   _OP_PARAMS = [
     _PNodeName,
     _PMigrationMode,
+    _PMigrationLive,
     ]
   REQ_BGL = False
 
@@ -5847,7 +5852,19 @@ class TLMigrateInstance(Tasklet):
 
     self.instance = instance
 
-    if self.lu.op.mode is None:
+    if self.lu.op.live is not None and self.lu.op.mode is not None:
+      raise errors.OpPrereqError("Only one of the 'live' and 'mode'"
+                                 " parameters are accepted",
+                                 errors.ECODE_INVAL)
+    if self.lu.op.live is not None:
+      if self.lu.op.live:
+        self.lu.op.mode = constants.HT_MIGRATION_LIVE
+      else:
+        self.lu.op.mode = constants.HT_MIGRATION_NONLIVE
+      # reset the 'live' parameter to None so that repeated
+      # invocations of CheckPrereq do not raise an exception
+      self.lu.op.live = None
+    elif 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.mode = i_hv[constants.HV_MIGRATION_MODE]
index 457d442..0bd9c35 100644 (file)
@@ -442,6 +442,7 @@ class OpMigrateNode(OpCode):
   __slots__ = [
     "node_name",
     "mode",
+    "live",
     ]
 
 
@@ -565,7 +566,7 @@ class OpMigrateInstance(OpCode):
   """
   OP_ID = "OP_INSTANCE_MIGRATE"
   OP_DSC_FIELD = "instance_name"
-  __slots__ = ["instance_name", "mode", "cleanup"]
+  __slots__ = ["instance_name", "mode", "cleanup", "live"]
 
 
 class OpMoveInstance(OpCode):