From 823a72bc29f0b4995182f05221010295f523d783 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 17 Feb 2010 10:25:59 +0100 Subject: [PATCH] Implement support for mevac in OpTestAllocator Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/cmdlib.py | 13 ++++++++++++- lib/opcodes.py | 1 + scripts/gnt-debug | 5 +++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index b6adbfe25..2ce59839f 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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 diff --git a/lib/opcodes.py b/lib/opcodes.py index b72204f23..dc5ac6c27 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -725,6 +725,7 @@ class OpTestAllocator(OpCode): "direction", "mode", "allocator", "name", "mem_size", "disks", "disk_template", "os", "tags", "nics", "vcpus", "hypervisor", + "evac_nodes", ] diff --git a/scripts/gnt-debug b/scripts/gnt-debug index 532a4c77e..5dc7dc630 100755 --- a/scripts/gnt-debug +++ b/scripts/gnt-debug @@ -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)"), -- GitLab