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.
---
 lib/client/gnt_debug.py |    4 ++--
 lib/cmdlib.py           |   12 ++++++------
 lib/opcodes.py          |    2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/client/gnt_debug.py b/lib/client/gnt_debug.py
index 6985781..8065dd7 100644
--- a/lib/client/gnt_debug.py
+++ b/lib/client/gnt_debug.py
@@ -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)"),
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 8274d81..9188cf8 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -8009,7 +8009,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,
@@ -12011,7 +12011,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
@@ -12251,7 +12251,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,
@@ -12331,7 +12331,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),
@@ -12479,7 +12479,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" %
@@ -12538,7 +12538,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,
diff --git a/lib/opcodes.py b/lib/opcodes.py
index 6a5f3be..ce28539 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -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),
-- 
1.7.3.1

Reply via email to