From 9fa567b3b6b73d3728a29b0464328f93f016d991 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com>
Date: Tue, 13 Dec 2011 10:35:40 +0100
Subject: [PATCH] gnt-node: Add instance policy to migrate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: RenΓ© Nussbaumer <rn@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/client/gnt_node.py | 5 +++--
 lib/cmdlib.py          | 3 ++-
 lib/opcodes.py         | 1 +
 man/gnt-node.rst       | 5 ++++-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/client/gnt_node.py b/lib/client/gnt_node.py
index f2fa3f79e..9fff35ff0 100644
--- a/lib/client/gnt_node.py
+++ b/lib/client/gnt_node.py
@@ -426,7 +426,8 @@ def MigrateNode(opts, args):
 
   op = opcodes.OpNodeMigrate(node_name=args[0], mode=mode,
                              iallocator=opts.iallocator,
-                             target_node=opts.dst_node)
+                             target_node=opts.dst_node,
+                             ignore_ipolicy=opts.ignore_ipolicy)
 
   result = SubmitOpCode(op, cl=cl, opts=opts)
 
@@ -899,7 +900,7 @@ commands = {
   "migrate": (
     MigrateNode, ARGS_ONE_NODE,
     [FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, DST_NODE_OPT,
-     IALLOCATOR_OPT, PRIORITY_OPT],
+     IALLOCATOR_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT],
     "[-f] <node>",
     "Migrate all the primary instance on a node away from it"
     " (only for instances of type drbd)"),
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 38fb083c5..b1f6f550f 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -7612,7 +7612,8 @@ class LUNodeMigrate(LogicalUnit):
                                  mode=self.op.mode,
                                  live=self.op.live,
                                  iallocator=self.op.iallocator,
-                                 target_node=self.op.target_node)]
+                                 target_node=self.op.target_node,
+                                 ignore_ipolicy=self.op.ignore_ipolicy)]
       for inst in _GetNodePrimaryInstances(self.cfg, self.op.node_name)
       ]
 
diff --git a/lib/opcodes.py b/lib/opcodes.py
index 3f6a845cc..eb6a4de07 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -1046,6 +1046,7 @@ class OpNodeMigrate(OpCode):
     _PMigrationMode,
     _PMigrationLive,
     _PMigrationTargetNode,
+    _PIgnoreIpolicy,
     ("iallocator", None, ht.TMaybeString,
      "Iallocator for deciding the target node for shared-storage instances"),
     ]
diff --git a/man/gnt-node.rst b/man/gnt-node.rst
index 70a3a47c1..15b663cd0 100644
--- a/man/gnt-node.rst
+++ b/man/gnt-node.rst
@@ -238,7 +238,7 @@ MIGRATE
 ~~~~~~~
 
 **migrate** [-f] [--non-live] [--migration-mode=live\|non-live]
-{*node*}
+[--ignore-ipolicy] {*node*}
 
 This command will migrate all instances having the given node as
 primary to their secondary nodes. This works only for instances
@@ -248,6 +248,9 @@ As for the **gnt-instance migrate** command, the options
 ``--no-live`` and ``--migration-mode`` can be given to influence
 the migration type.
 
+If ``--ignore-ipolicy`` is given any instance policy violations occuring
+during this operation are ignored.
+
 Example::
 
     # gnt-node migrate node1.example.com
-- 
GitLab