Add gnt-instance move
authorIustin Pop <iustin@google.com>
Fri, 21 Aug 2009 14:07:49 +0000 (16:07 +0200)
committerIustin Pop <iustin@google.com>
Mon, 24 Aug 2009 12:13:42 +0000 (14:13 +0200)
This uses the new LUMoveInstance. It supports only single-instance moves.

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

man/gnt-instance.sgml
scripts/gnt-instance

index 17a8073..4bd5442 100644 (file)
@@ -2072,6 +2072,44 @@ y/[n]/?: y
         </para>
       </refsect3>
 
+      <refsect3>
+        <title>MOVE</title>
+
+        <cmdsynopsis>
+          <command>move</command>
+          <arg>-f</arg>
+          <arg>-n <replaceable>node</replaceable></arg>
+          <arg>--submit</arg>
+          <arg choice="req"><replaceable>instance</replaceable></arg>
+        </cmdsynopsis>
+
+        <para>
+          Move will move the instance to an arbitrary node in the
+          cluster. This works only for instances having a plain or
+          file disk template.
+        </para>
+
+        <para>
+          Note that since this operation is done via data copy, it
+          will take a long time for big disks (similar to
+          replace-disks for a drbd instance).
+        </para>
+
+        <para>
+          The <option>--submit</option> option is used to send the job to
+          the master daemon but not wait for its completion. The job
+          ID will be shown so that it can be examined via
+          <command>gnt-job info</command>.
+        </para>
+
+        <para>
+          Example:
+          <screen>
+# gnt-instance move -n node3.example.com instance1.example.com
+          </screen>
+        </para>
+      </refsect3>
+
     </refsect2>
 
     <refsect2>
index a0ae7c0..2d0fe8c 100755 (executable)
@@ -952,6 +952,33 @@ def MigrateInstance(opts, args):
   return 0
 
 
+def MoveInstance(opts, args):
+  """Move an instance.
+
+  @param opts: the command line options selected by the user
+  @type args: list
+  @param args: should contain only one element, the instance name
+  @rtype: int
+  @return: the desired exit code
+
+  """
+  cl = GetClient()
+  instance_name = args[0]
+  force = opts.force
+
+  if not force:
+    usertext = ("Instance %s will be moved."
+                " This requires a shutdown of the instance. Continue?" %
+                (instance_name,))
+    if not AskUser(usertext):
+      return 1
+
+  op = opcodes.OpMoveInstance(instance_name=instance_name,
+                              target_node=opts.target_node)
+  SubmitOrSend(op, opts, cl=cl)
+  return 0
+
+
 def ConnectToInstanceConsole(opts, args):
   """Connect to the console of an instance.
 
@@ -1435,6 +1462,15 @@ commands = {
                "[-f] <instance>",
                "Migrate instance to its secondary node"
                " (only for instances of type drbd)"),
+  'move': (MoveInstance, ARGS_ONE,
+           [DEBUG_OPT, FORCE_OPT, SUBMIT_OPT,
+            make_option("-n", "--new-node", dest="target_node",
+                        help="Destinattion node", metavar="NODE",
+                        default=None),
+            ],
+           "[-f] <instance>",
+           "Move instance to an arbitrary node"
+           " (only for instances of type file and lv)"),
   'info': (ShowInstanceConfig, ARGS_ANY,
            [DEBUG_OPT,
             make_option("-s", "--static", dest="static",