Commit 3c049cd3 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Adapt gnt-debug iallocator



Add the new multi-alloc request to the test allocation framework. For
now we just create --count identical instances. This might need further
improvements later.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent b1e47e2d
...@@ -175,7 +175,8 @@ def TestAllocator(opts, args): ...@@ -175,7 +175,8 @@ def TestAllocator(opts, args):
allocator=opts.iallocator, allocator=opts.iallocator,
evac_mode=opts.evac_mode, evac_mode=opts.evac_mode,
target_groups=target_groups, target_groups=target_groups,
spindle_use=opts.spindle_use) spindle_use=opts.spindle_use,
count=opts.count)
result = SubmitOpCode(op, opts=opts) result = SubmitOpCode(op, opts=opts)
ToStdout("%s" % result) ToStdout("%s" % result)
return 0 return 0
...@@ -676,6 +677,8 @@ commands = { ...@@ -676,6 +677,8 @@ commands = {
default=[], action="append"), default=[], action="append"),
cli_option("--spindle-use", help="How many spindles to use", cli_option("--spindle-use", help="How many spindles to use",
default=1, type="int"), default=1, type="int"),
cli_option("--count", help="How many instances to allocate",
default=2, type="int"),
DRY_RUN_OPT, PRIORITY_OPT, DRY_RUN_OPT, PRIORITY_OPT,
], ],
"{opts...} <instance>", "Executes a TestAllocator OpCode"), "{opts...} <instance>", "Executes a TestAllocator OpCode"),
......
...@@ -14824,7 +14824,8 @@ class LUTestAllocator(NoHooksLU): ...@@ -14824,7 +14824,8 @@ class LUTestAllocator(NoHooksLU):
This checks the opcode parameters depending on the director and mode test. This checks the opcode parameters depending on the director and mode test.
   
""" """
if self.op.mode == constants.IALLOCATOR_MODE_ALLOC: if self.op.mode in (constants.IALLOCATOR_MODE_ALLOC,
constants.IALLOCATOR_MODE_MULTI_ALLOC):
for attr in ["memory", "disks", "disk_template", for attr in ["memory", "disks", "disk_template",
"os", "tags", "nics", "vcpus"]: "os", "tags", "nics", "vcpus"]:
if not hasattr(self.op, attr): if not hasattr(self.op, attr):
...@@ -14896,6 +14897,20 @@ class LUTestAllocator(NoHooksLU): ...@@ -14896,6 +14897,20 @@ class LUTestAllocator(NoHooksLU):
elif self.op.mode == constants.IALLOCATOR_MODE_NODE_EVAC: elif self.op.mode == constants.IALLOCATOR_MODE_NODE_EVAC:
req = iallocator.IAReqNodeEvac(instances=self.op.instances, req = iallocator.IAReqNodeEvac(instances=self.op.instances,
evac_mode=self.op.evac_mode) evac_mode=self.op.evac_mode)
elif self.op.mode == constants.IALLOCATOR_MODE_MULTI_ALLOC:
disk_template = self.op.disk_template
insts = [iallocator.IAReqInstanceAlloc(name="%s%s" % (self.op.name, idx),
memory=self.op.memory,
disks=self.op.disks,
disk_template=disk_template,
os=self.op.os,
tags=self.op.tags,
nics=self.op.nics,
vcpus=self.op.vcpus,
spindle_use=self.op.spindle_use,
hypervisor=self.op.hypervisor)
for idx in range(self.op.count)]
req = iallocator.IAReqMultiInstanceAlloc(instances=insts)
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)
......
...@@ -1839,6 +1839,7 @@ class OpTestAllocator(OpCode): ...@@ -1839,6 +1839,7 @@ class OpTestAllocator(OpCode):
ht.TOr(ht.TNone, ht.TElemOf(constants.IALLOCATOR_NEVAC_MODES)), None), ht.TOr(ht.TNone, ht.TElemOf(constants.IALLOCATOR_NEVAC_MODES)), None),
("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), None), ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), None),
("spindle_use", 1, ht.TPositiveInt, None), ("spindle_use", 1, ht.TPositiveInt, None),
("count", 1, ht.TPositiveInt, 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