Commit b1e47e2d authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Adding new multi-allocation request



Now that we've the refactoring done, we can easily add the new mode and
everything works.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 2bbf280e
......@@ -212,6 +212,11 @@ In all cases, it includes:
off their node(s). These are described in a separate :ref:`design
document <multi-reloc-detailed-design>`.
The ``multi-allocate`` request is used to allocate multiple
instances on the cluster. The request is beside of that very
similiar to the ``allocate`` one. For more details look at
:doc:`Ganeti bulk create <design-bulk-create>`.
For both allocate and relocate mode, the following extra keys are needed
in the ``request`` dictionary:
......@@ -311,6 +316,11 @@ As for ``node-evacuate``, it needs the following request arguments:
should be considered for relocating instances to; type
*list of strings*
``multi-allocate`` needs the following request arguments:
instances
a list of request dicts
Response message
~~~~~~~~~~~~~~~~
......@@ -338,6 +348,12 @@ result
serialized opcodes; see the :ref:`design document
<multi-reloc-result>` for a detailed description
for the ``multi-allocate`` mode this is a tuple of 2 lists, the first
being element of the tuple is a list of succeeded allocation, with the
instance name as first element of each entry and the node placement in
the second. The second element of the tuple is the instance list of
failed allocations.
.. note:: Current Ganeti version accepts either ``result`` or ``nodes``
as a backwards-compatibility measure (older versions only supported
``nodes``)
......
......@@ -352,6 +352,14 @@ TNumber = TOr(TInt, TFloat)
TRelativeJobId = WithDesc("RelativeJobId")(TStrictNegativeInt)
def TInstanceOf(my_inst):
"""Checks if a given value is an instance of my_inst.
"""
desc = WithDesc("Instance of %s" % (Parens(my_inst), ))
return desc(lambda val: isinstance(val, my_inst))
def TListOf(my_type):
"""Checks if a given value is a list with all elements of the same type.
......
......@@ -186,6 +186,29 @@ class IAReqInstanceAlloc(IARequestBase):
}
class IAReqMultiInstanceAlloc(IARequestBase):
"""An multi instance allocation request.
"""
MODE = constants.IALLOCATOR_MODE_MULTI_ALLOC
REQ_PARAMS = [
("instances", ht.TListOf(ht.TInstanceOf(IAReqInstanceAlloc)))
]
_MASUCCESS = \
ht.TListOf(ht.TAnd(ht.TIsLength(2),
ht.TItems([ht.TNonEmptyString,
ht.TListOf(ht.TNonEmptyString),
])))
_MAFAILED = ht.TListOf(ht.TNonEmptyString)
REQ_RESULT = ht.TListOf(ht.TAnd(ht.TIsLength(2),
ht.TItems([_MASUCCESS, _MAFAILED])))
def GetRequest(self, cfg):
return {
"instances": [iareq.GetRequest(cfg) for iareq in self.instances]
}
class IAReqRelocate(IARequestBase):
"""A relocation request.
......
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