Revision b1e47e2d
b/doc/iallocator.rst | ||
---|---|---|
212 | 212 |
off their node(s). These are described in a separate :ref:`design |
213 | 213 |
document <multi-reloc-detailed-design>`. |
214 | 214 |
|
215 |
The ``multi-allocate`` request is used to allocate multiple |
|
216 |
instances on the cluster. The request is beside of that very |
|
217 |
similiar to the ``allocate`` one. For more details look at |
|
218 |
:doc:`Ganeti bulk create <design-bulk-create>`. |
|
219 |
|
|
215 | 220 |
For both allocate and relocate mode, the following extra keys are needed |
216 | 221 |
in the ``request`` dictionary: |
217 | 222 |
|
... | ... | |
311 | 316 |
should be considered for relocating instances to; type |
312 | 317 |
*list of strings* |
313 | 318 |
|
319 |
``multi-allocate`` needs the following request arguments: |
|
320 |
|
|
321 |
instances |
|
322 |
a list of request dicts |
|
323 |
|
|
314 | 324 |
Response message |
315 | 325 |
~~~~~~~~~~~~~~~~ |
316 | 326 |
|
... | ... | |
338 | 348 |
serialized opcodes; see the :ref:`design document |
339 | 349 |
<multi-reloc-result>` for a detailed description |
340 | 350 |
|
351 |
for the ``multi-allocate`` mode this is a tuple of 2 lists, the first |
|
352 |
being element of the tuple is a list of succeeded allocation, with the |
|
353 |
instance name as first element of each entry and the node placement in |
|
354 |
the second. The second element of the tuple is the instance list of |
|
355 |
failed allocations. |
|
356 |
|
|
341 | 357 |
.. note:: Current Ganeti version accepts either ``result`` or ``nodes`` |
342 | 358 |
as a backwards-compatibility measure (older versions only supported |
343 | 359 |
``nodes``) |
b/lib/ht.py | ||
---|---|---|
352 | 352 |
TRelativeJobId = WithDesc("RelativeJobId")(TStrictNegativeInt) |
353 | 353 |
|
354 | 354 |
|
355 |
def TInstanceOf(my_inst): |
|
356 |
"""Checks if a given value is an instance of my_inst. |
|
357 |
|
|
358 |
""" |
|
359 |
desc = WithDesc("Instance of %s" % (Parens(my_inst), )) |
|
360 |
return desc(lambda val: isinstance(val, my_inst)) |
|
361 |
|
|
362 |
|
|
355 | 363 |
def TListOf(my_type): |
356 | 364 |
"""Checks if a given value is a list with all elements of the same type. |
357 | 365 |
|
b/lib/masterd/iallocator.py | ||
---|---|---|
186 | 186 |
} |
187 | 187 |
|
188 | 188 |
|
189 |
class IAReqMultiInstanceAlloc(IARequestBase): |
|
190 |
"""An multi instance allocation request. |
|
191 |
|
|
192 |
""" |
|
193 |
MODE = constants.IALLOCATOR_MODE_MULTI_ALLOC |
|
194 |
REQ_PARAMS = [ |
|
195 |
("instances", ht.TListOf(ht.TInstanceOf(IAReqInstanceAlloc))) |
|
196 |
] |
|
197 |
_MASUCCESS = \ |
|
198 |
ht.TListOf(ht.TAnd(ht.TIsLength(2), |
|
199 |
ht.TItems([ht.TNonEmptyString, |
|
200 |
ht.TListOf(ht.TNonEmptyString), |
|
201 |
]))) |
|
202 |
_MAFAILED = ht.TListOf(ht.TNonEmptyString) |
|
203 |
REQ_RESULT = ht.TListOf(ht.TAnd(ht.TIsLength(2), |
|
204 |
ht.TItems([_MASUCCESS, _MAFAILED]))) |
|
205 |
|
|
206 |
def GetRequest(self, cfg): |
|
207 |
return { |
|
208 |
"instances": [iareq.GetRequest(cfg) for iareq in self.instances] |
|
209 |
} |
|
210 |
|
|
211 |
|
|
189 | 212 |
class IAReqRelocate(IARequestBase): |
190 | 213 |
"""A relocation request. |
191 | 214 |
|
Also available in: Unified diff