Commit dd47a0f0 authored by Iustin Pop's avatar Iustin Pop
Browse files

iallocator: rename mem_size to memory



Currently, the iallocator in 'allocate' requires mem_size on input
but serialises that as 'memory'. This inconsistency makes it hard to
automatically validate the parameters, hence this patch renames
mem_size.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 36bbf5b0
......@@ -164,7 +164,7 @@ def TestAllocator(opts, args):
name=args[0],
evac_nodes=args,
instances=args,
mem_size=opts.mem,
memory=opts.memory,
disks=disks,
disk_template=opts.disk_template,
nics=nic_dict,
......@@ -568,7 +568,7 @@ commands = {
choices=list(constants.VALID_IALLOCATOR_MODES),
help=("Request mode (one of %s)" %
utils.CommaJoin(constants.VALID_IALLOCATOR_MODES))),
cli_option("--mem", default=128, type="unit",
cli_option("--memory", default=128, type="unit",
help="Memory size for the instance (MiB)"),
cli_option("--disks", default="4096,4096",
help="Comma separated list of disk sizes (MiB)"),
......
......@@ -8003,7 +8003,7 @@ class LUInstanceCreate(LogicalUnit):
tags=[],
os=self.op.os_type,
vcpus=self.be_full[constants.BE_VCPUS],
mem_size=self.be_full[constants.BE_MEMORY],
memory=self.be_full[constants.BE_MEMORY],
disks=self.disks,
nics=nics,
hypervisor=self.op.hypervisor,
......@@ -12005,7 +12005,7 @@ class IAllocator(object):
self.in_text = self.out_text = self.in_data = self.out_data = None
# init all input fields so that pylint is happy
self.mode = mode
self.mem_size = self.disks = self.disk_template = None
self.memory = self.disks = self.disk_template = None
self.os = self.tags = self.nics = self.vcpus = None
self.hypervisor = None
self.relocate_from = None
......@@ -12245,7 +12245,7 @@ class IAllocator(object):
"tags": self.tags,
"os": self.os,
"vcpus": self.vcpus,
"memory": self.mem_size,
"memory": self.memory,
"disks": self.disks,
"disk_space_total": disk_space,
"nics": self.nics,
......@@ -12325,7 +12325,7 @@ class IAllocator(object):
_MODE_DATA = {
constants.IALLOCATOR_MODE_ALLOC:
(_AddNewInstance,
["name", "mem_size", "disks", "disk_template", "os", "tags", "nics",
["name", "memory", "disks", "disk_template", "os", "tags", "nics",
"vcpus", "hypervisor"], ht.TList),
constants.IALLOCATOR_MODE_RELOC:
(_AddRelocateInstance, ["name", "relocate_from"], ht.TList),
......@@ -12473,7 +12473,7 @@ class LUTestAllocator(NoHooksLU):
"""
if self.op.mode == constants.IALLOCATOR_MODE_ALLOC:
for attr in ["mem_size", "disks", "disk_template",
for attr in ["memory", "disks", "disk_template",
"os", "tags", "nics", "vcpus"]:
if not hasattr(self.op, attr):
raise errors.OpPrereqError("Missing attribute '%s' on opcode input" %
......@@ -12532,7 +12532,7 @@ class LUTestAllocator(NoHooksLU):
ial = IAllocator(self.cfg, self.rpc,
mode=self.op.mode,
name=self.op.name,
mem_size=self.op.mem_size,
memory=self.op.memory,
disks=self.op.disks,
disk_template=self.op.disk_template,
os=self.op.os,
......
......@@ -1447,7 +1447,7 @@ class OpTestAllocator(OpCode):
("hypervisor", None, ht.TMaybeString, None),
("allocator", None, ht.TMaybeString, None),
("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
("mem_size", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
("memory", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
("os", None, ht.TMaybeString, None),
("disk_template", None, ht.TMaybeString, 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