Commit 823a72bc authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement support for mevac in OpTestAllocator


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 7f60a422
......@@ -8861,6 +8861,10 @@ class LUTestAllocator(NoHooksLU):
fname = _ExpandInstanceName(self.cfg, self.op.name)
self.op.name = fname
self.relocate_from = self.cfg.GetInstanceInfo(fname).secondary_nodes
elif self.op.mode == constants.IALLOCATOR_MODE_MEVAC:
if not hasattr(self.op, "evac_nodes"):
raise errors.OpPrereqError("Missing attribute 'evac_nodes' on"
" opcode input", errors.ECODE_INVAL)
else:
raise errors.OpPrereqError("Invalid test allocator mode '%s'" %
self.op.mode, errors.ECODE_INVAL)
......@@ -8890,12 +8894,19 @@ class LUTestAllocator(NoHooksLU):
vcpus=self.op.vcpus,
hypervisor=self.op.hypervisor,
)
else:
elif self.op.mode == constants.IALLOCATOR_MODE_RELOC:
ial = IAllocator(self.cfg, self.rpc,
mode=self.op.mode,
name=self.op.name,
relocate_from=list(self.relocate_from),
)
elif self.op.mode == constants.IALLOCATOR_MODE_MEVAC:
ial = IAllocator(self.cfg, self.rpc,
mode=self.op.mode,
evac_nodes=self.op.evac_nodes)
else:
raise errors.ProgrammerError("Uncatched mode %s in"
" LUTestAllocator.Exec", self.op.mode)
if self.op.direction == constants.IALLOCATOR_DIR_IN:
result = ial.in_text
......
......@@ -725,6 +725,7 @@ class OpTestAllocator(OpCode):
"direction", "mode", "allocator", "name",
"mem_size", "disks", "disk_template",
"os", "tags", "nics", "vcpus", "hypervisor",
"evac_nodes",
]
......
......@@ -140,6 +140,7 @@ def TestAllocator(opts, args):
op = opcodes.OpTestAllocator(mode=opts.mode,
name=args[0],
evac_nodes=args,
mem_size=opts.mem,
disks=disks,
disk_template=opts.disk_template,
......@@ -177,14 +178,14 @@ commands = {
"<op_list_file...>", "Submits jobs built from json files"
" containing a list of serialized opcodes"),
'allocator': (
TestAllocator, ARGS_ONE_INSTANCE,
TestAllocator, [ArgUnknown(min=1)],
[cli_option("--dir", dest="direction",
default="in", choices=["in", "out"],
help="Show allocator input (in) or allocator"
" results (out)"),
IALLOCATOR_OPT,
cli_option("-m", "--mode", default="relocate",
choices=["relocate", "allocate"],
choices=["relocate", "allocate", "multi-evacuate"],
help="Request mode, either allocate or relocate"),
cli_option("--mem", default=128, type="unit",
help="Memory size for the instance (MiB)"),
......
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