From 091232220479c4b35c69d19d53a729c9874d8fda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com>
Date: Tue, 28 Aug 2012 13:14:58 +0200
Subject: [PATCH] Fix gnt-debug iallocator
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There was an issue with the recent ipolicy introduction which lead to a
bug in gnt-debug iallocator. It was not providing the spindle_use field
and therefore it wont let you create a valid iallocator request.

Signed-off-by: RenΓ© Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/client/gnt_debug.py | 5 ++++-
 lib/cmdlib.py           | 1 +
 lib/opcodes.py          | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/client/gnt_debug.py b/lib/client/gnt_debug.py
index 228733b5d..5eb58a29f 100644
--- a/lib/client/gnt_debug.py
+++ b/lib/client/gnt_debug.py
@@ -174,7 +174,8 @@ def TestAllocator(opts, args):
                                direction=opts.direction,
                                allocator=opts.iallocator,
                                evac_mode=opts.evac_mode,
-                               target_groups=target_groups)
+                               target_groups=target_groups,
+                               spindle_use=opts.spindle_use)
   result = SubmitOpCode(op, opts=opts)
   ToStdout("%s" % result)
   return 0
@@ -672,6 +673,8 @@ commands = {
                       utils.CommaJoin(constants.IALLOCATOR_NEVAC_MODES))),
      cli_option("--target-groups", help="Target groups for relocation",
                 default=[], action="append"),
+     cli_option("--spindle-use", help="How many spindles to use",
+                default=1, type="int"),
      DRY_RUN_OPT, PRIORITY_OPT,
      ],
     "{opts...} <instance>", "Executes a TestAllocator OpCode"),
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index cf2769e82..3860d559d 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -15295,6 +15295,7 @@ class LUTestAllocator(NoHooksLU):
                        nics=self.op.nics,
                        vcpus=self.op.vcpus,
                        hypervisor=self.op.hypervisor,
+                       spindle_use=self.op.spindle_use,
                        )
     elif self.op.mode == constants.IALLOCATOR_MODE_RELOC:
       ial = IAllocator(self.cfg, self.rpc,
diff --git a/lib/opcodes.py b/lib/opcodes.py
index aa7cce1e0..3243e0ea7 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -1853,6 +1853,7 @@ class OpTestAllocator(OpCode):
     ("evac_mode", None,
      ht.TOr(ht.TNone, ht.TElemOf(constants.IALLOCATOR_NEVAC_MODES)), None),
     ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), None),
+    ("spindle_use", 1, ht.TPositiveInt, None),
     ]
 
 
-- 
GitLab