Commit bee581e2 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add new iallocator mode to LUTestAllocator


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 55011921
...@@ -12257,6 +12257,12 @@ class LUTestAllocator(NoHooksLU): ...@@ -12257,6 +12257,12 @@ class LUTestAllocator(NoHooksLU):
if not hasattr(self.op, "evac_nodes"): if not hasattr(self.op, "evac_nodes"):
raise errors.OpPrereqError("Missing attribute 'evac_nodes' on" raise errors.OpPrereqError("Missing attribute 'evac_nodes' on"
" opcode input", errors.ECODE_INVAL) " 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: else:
raise errors.OpPrereqError("Invalid test allocator mode '%s'" % raise errors.OpPrereqError("Invalid test allocator mode '%s'" %
self.op.mode, errors.ECODE_INVAL) self.op.mode, errors.ECODE_INVAL)
...@@ -12296,6 +12302,12 @@ class LUTestAllocator(NoHooksLU): ...@@ -12296,6 +12302,12 @@ class LUTestAllocator(NoHooksLU):
ial = IAllocator(self.cfg, self.rpc, ial = IAllocator(self.cfg, self.rpc,
mode=self.op.mode, mode=self.op.mode,
evac_nodes=self.op.evac_nodes) 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: else:
raise errors.ProgrammerError("Uncatched mode %s in" raise errors.ProgrammerError("Uncatched mode %s in"
" LUTestAllocator.Exec", self.op.mode) " LUTestAllocator.Exec", self.op.mode)
......
...@@ -1430,6 +1430,12 @@ class OpTestAllocator(OpCode): ...@@ -1430,6 +1430,12 @@ class OpTestAllocator(OpCode):
("disk_template", None, ht.TMaybeString, None), ("disk_template", None, ht.TMaybeString, None),
("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)), ("evac_nodes", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
None), 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),
] ]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment