Add new iallocator mode to LUTestAllocator
authorMichael Hanselmann <hansmi@google.com>
Thu, 12 May 2011 16:16:35 +0000 (18:16 +0200)
committerMichael Hanselmann <hansmi@google.com>
Mon, 16 May 2011 13:41:27 +0000 (15:41 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/cmdlib.py
lib/opcodes.py

index 0a1beb8..d7e95b8 100644 (file)
@@ -12257,6 +12257,12 @@ class LUTestAllocator(NoHooksLU):
       if not hasattr(self.op, "evac_nodes"):
         raise errors.OpPrereqError("Missing attribute 'evac_nodes' on"
                                    " opcode input", errors.ECODE_INVAL)
+    elif self.op.mode == constants.IALLOCATOR_MODE_MRELOC:
+      if self.op.instances:
+        self.op.instances = _GetWantedInstances(self, self.op.instances)
+      else:
+        raise errors.OpPrereqError("Missing instances to relocate",
+                                   errors.ECODE_INVAL)
     else:
       raise errors.OpPrereqError("Invalid test allocator mode '%s'" %
                                  self.op.mode, errors.ECODE_INVAL)
@@ -12296,6 +12302,12 @@ class LUTestAllocator(NoHooksLU):
       ial = IAllocator(self.cfg, self.rpc,
                        mode=self.op.mode,
                        evac_nodes=self.op.evac_nodes)
+    elif self.op.mode == constants.IALLOCATOR_MODE_MRELOC:
+      ial = IAllocator(self.cfg, self.rpc,
+                       mode=self.op.mode,
+                       instances=self.op.instances,
+                       reloc_mode=self.op.reloc_mode,
+                       target_groups=self.op.target_groups)
     else:
       raise errors.ProgrammerError("Uncatched mode %s in"
                                    " LUTestAllocator.Exec", self.op.mode)
index 698fb45..1946284 100644 (file)
@@ -1430,6 +1430,12 @@ class OpTestAllocator(OpCode):
     ("disk_template", None, ht.TMaybeString, None),
     ("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
      None),
+    ("instances", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
+     None),
+    ("reloc_mode", None,
+     ht.TOr(ht.TNone, ht.TElemOf(constants.IALLOCATOR_MRELOC_MODES)), None),
+    ("target_groups", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
+     None),
     ]