Rename the OpMigrate* parameter 'live' to 'mode'
authorIustin Pop <iustin@google.com>
Tue, 20 Jul 2010 16:26:44 +0000 (18:26 +0200)
committerIustin Pop <iustin@google.com>
Fri, 23 Jul 2010 17:26:49 +0000 (13:26 -0400)
This is needed as now the parameter is no longer boolean, but tri-state.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

lib/cmdlib.py
lib/opcodes.py
scripts/gnt-instance
scripts/gnt-node

index b953e50..ea5331d 100644 (file)
@@ -233,7 +233,7 @@ _PInstanceName = ("instance_name", _NoDefault, _TNonEmptyString)
 _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)))
 
 
@@ -5490,7 +5490,7 @@ class LUMigrateInstance(LogicalUnit):
   HTYPE = constants.HTYPE_INSTANCE
   _OP_PARAMS = [
     _PInstanceName,
-    _PMigrationLive,
+    _PMigrationMode,
     ("cleanup", False, _TBool),
     ]
 
@@ -5520,7 +5520,7 @@ class LUMigrateInstance(LogicalUnit):
     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,
@@ -5721,7 +5721,7 @@ class LUMigrateNode(LogicalUnit):
   HTYPE = constants.HTYPE_NODE
   _OP_PARAMS = [
     _PNodeName,
-    _PMigrationLive,
+    _PMigrationMode,
     ]
   REQ_BGL = False
 
@@ -5769,6 +5769,13 @@ class LUMigrateNode(LogicalUnit):
 
 
 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.
 
@@ -5819,12 +5826,12 @@ class TLMigrateInstance(Tasklet):
 
     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.
index aacbbdd..05c0ef4 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# 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
@@ -440,7 +440,7 @@ class OpMigrateNode(OpCode):
   OP_DSC_FIELD = "node_name"
   __slots__ = [
     "node_name",
-    "live",
+    "mode",
     ]
 
 
@@ -559,11 +559,12 @@ class OpMigrateInstance(OpCode):
   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):
index cbe060c..3dd7baa 100755 (executable)
@@ -903,11 +903,11 @@ def MigrateInstance(opts, args):
                                "--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
index 49bfc95..b3d911f 100755 (executable)
@@ -366,10 +366,10 @@ def MigrateNode(opts, args):
                                "--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)