Statistics
| Branch: | Tag: | Revision:

root / doc / iallocator.rst @ 0565f862

History | View | Annotate | Download (18 kB)

1 876860a3 Iustin Pop
Ganeti automatic instance allocation
2 876860a3 Iustin Pop
====================================
3 876860a3 Iustin Pop
4 c7a02959 Thomas Thrainer
Documents Ganeti version 2.11
5 876860a3 Iustin Pop
6 876860a3 Iustin Pop
.. contents::
7 876860a3 Iustin Pop
8 876860a3 Iustin Pop
Introduction
9 876860a3 Iustin Pop
------------
10 876860a3 Iustin Pop
11 876860a3 Iustin Pop
Currently in Ganeti the admin has to specify the exact locations for
12 876860a3 Iustin Pop
an instance's node(s). This prevents a completely automatic node
13 876860a3 Iustin Pop
evacuation, and is in general a nuisance.
14 876860a3 Iustin Pop
15 876860a3 Iustin Pop
The *iallocator* framework will enable automatic placement via
16 876860a3 Iustin Pop
external scripts, which allows customization of the cluster layout per
17 876860a3 Iustin Pop
the site's requirements.
18 876860a3 Iustin Pop
19 876860a3 Iustin Pop
User-visible changes
20 876860a3 Iustin Pop
~~~~~~~~~~~~~~~~~~~~
21 876860a3 Iustin Pop
22 876860a3 Iustin Pop
There are two parts of the ganeti operation that are impacted by the
23 876860a3 Iustin Pop
auto-allocation: how the cluster knows what the allocator algorithms
24 876860a3 Iustin Pop
are and how the admin uses these in creating instances.
25 876860a3 Iustin Pop
26 876860a3 Iustin Pop
An allocation algorithm is just the filename of a program installed in
27 876860a3 Iustin Pop
a defined list of directories.
28 876860a3 Iustin Pop
29 876860a3 Iustin Pop
Cluster configuration
30 876860a3 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~
31 876860a3 Iustin Pop
32 876860a3 Iustin Pop
At configure time, the list of the directories can be selected via the
33 876860a3 Iustin Pop
``--with-iallocator-search-path=LIST`` option, where *LIST* is a
34 876860a3 Iustin Pop
comma-separated list of directories. If not given, this defaults to
35 876860a3 Iustin Pop
``$libdir/ganeti/iallocators``, i.e. for an installation under
36 876860a3 Iustin Pop
``/usr``, this will be ``/usr/lib/ganeti/iallocators``.
37 876860a3 Iustin Pop
38 876860a3 Iustin Pop
Ganeti will then search for allocator script in the configured list,
39 876860a3 Iustin Pop
using the first one whose filename matches the one given by the user.
40 876860a3 Iustin Pop
41 876860a3 Iustin Pop
Command line interface changes
42 876860a3 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43 876860a3 Iustin Pop
44 7ed400f0 Stratos Psomadakis
The node selection options in instance add and instance replace disks
45 876860a3 Iustin Pop
can be replace by the new ``--iallocator=NAME`` option (shortened to
46 876860a3 Iustin Pop
``-I``), which will cause the auto-assignement of nodes with the
47 d71b0275 Helga Velroyen
passed iallocator. The selected node(s) will be shown as part of the
48 876860a3 Iustin Pop
command output.
49 876860a3 Iustin Pop
50 876860a3 Iustin Pop
IAllocator API
51 876860a3 Iustin Pop
--------------
52 876860a3 Iustin Pop
53 876860a3 Iustin Pop
The protocol for communication between Ganeti and an allocator script
54 876860a3 Iustin Pop
will be the following:
55 876860a3 Iustin Pop
56 876860a3 Iustin Pop
#. ganeti launches the program with a single argument, a filename that
57 876860a3 Iustin Pop
   contains a JSON-encoded structure (the input message)
58 876860a3 Iustin Pop
59 876860a3 Iustin Pop
#. if the script finishes with exit code different from zero, it is
60 876860a3 Iustin Pop
   considered a general failure and the full output will be reported to
61 876860a3 Iustin Pop
   the users; this can be the case when the allocator can't parse the
62 876860a3 Iustin Pop
   input message
63 876860a3 Iustin Pop
64 876860a3 Iustin Pop
#. if the allocator finishes with exit code zero, it is expected to
65 876860a3 Iustin Pop
   output (on its stdout) a JSON-encoded structure (the response)
66 876860a3 Iustin Pop
67 876860a3 Iustin Pop
Input message
68 876860a3 Iustin Pop
~~~~~~~~~~~~~
69 876860a3 Iustin Pop
70 876860a3 Iustin Pop
The input message will be the JSON encoding of a dictionary containing
71 61791108 Adeodato Simo
all the required information to perform the operation. We explain the
72 61791108 Adeodato Simo
contents of this dictionary in two parts: common information that every
73 61791108 Adeodato Simo
type of operation requires, and operation-specific information.
74 61791108 Adeodato Simo
75 61791108 Adeodato Simo
Common information
76 61791108 Adeodato Simo
++++++++++++++++++
77 61791108 Adeodato Simo
78 61791108 Adeodato Simo
All input dictionaries to the IAllocator must carry the following keys:
79 876860a3 Iustin Pop
80 876860a3 Iustin Pop
version
81 876860a3 Iustin Pop
  the version of the protocol; this document
82 77031881 Iustin Pop
  specifies version 2
83 876860a3 Iustin Pop
84 876860a3 Iustin Pop
cluster_name
85 876860a3 Iustin Pop
  the cluster name
86 876860a3 Iustin Pop
87 876860a3 Iustin Pop
cluster_tags
88 876860a3 Iustin Pop
  the list of cluster tags
89 876860a3 Iustin Pop
90 77031881 Iustin Pop
enabled_hypervisors
91 77031881 Iustin Pop
  the list of enabled hypervisors
92 77031881 Iustin Pop
93 e6244d00 Iustin Pop
ipolicy
94 e6244d00 Iustin Pop
  the cluster-wide instance policy (for information; the per-node group
95 e6244d00 Iustin Pop
  values take precedence and should be used instead)
96 e6244d00 Iustin Pop
97 876860a3 Iustin Pop
request
98 61791108 Adeodato Simo
  a dictionary containing the details of the request; the keys vary
99 61791108 Adeodato Simo
  depending on the type of operation that's being requested, as
100 61791108 Adeodato Simo
  explained in `Operation-specific input`_ below.
101 632fb7ec Iustin Pop
102 622444e5 Iustin Pop
nodegroups
103 622444e5 Iustin Pop
  a dictionary with the data for the cluster's node groups; it is keyed
104 622444e5 Iustin Pop
  on the group UUID, and the values are a dictionary with the following
105 622444e5 Iustin Pop
  keys:
106 622444e5 Iustin Pop
107 622444e5 Iustin Pop
  name
108 622444e5 Iustin Pop
    the node group name
109 913639fe Balazs Lecz
  alloc_policy
110 5e9bcdf4 Adeodato Simo
    the allocation policy of the node group (consult the semantics of
111 5e9bcdf4 Adeodato Simo
    this attribute in the :manpage:`gnt-group(8)` manpage)
112 2daca99b Thomas Thrainer
  networks
113 2daca99b Thomas Thrainer
    the list of network UUID's this node group is connected to
114 e6244d00 Iustin Pop
  ipolicy
115 e6244d00 Iustin Pop
    the instance policy of the node group
116 2daca99b Thomas Thrainer
  tags
117 2daca99b Thomas Thrainer
    the list of node group tags
118 622444e5 Iustin Pop
119 876860a3 Iustin Pop
instances
120 876860a3 Iustin Pop
  a dictionary with the data for the current existing instance on the
121 876860a3 Iustin Pop
  cluster, indexed by instance name; the contents are similar to the
122 876860a3 Iustin Pop
  instance definitions for the allocate mode, with the addition of:
123 876860a3 Iustin Pop
124 9ca8a7c5 Agata Murawska
  admin_state
125 876860a3 Iustin Pop
    if this instance is set to run (but not the actual status of the
126 876860a3 Iustin Pop
    instance)
127 876860a3 Iustin Pop
128 876860a3 Iustin Pop
  nodes
129 876860a3 Iustin Pop
    list of nodes on which this instance is placed; the primary node
130 876860a3 Iustin Pop
    of the instance is always the first one
131 876860a3 Iustin Pop
132 876860a3 Iustin Pop
nodes
133 876860a3 Iustin Pop
  dictionary with the data for the nodes in the cluster, indexed by
134 0d853843 Iustin Pop
  the node name; the dict contains [*]_ :
135 876860a3 Iustin Pop
136 876860a3 Iustin Pop
  total_disk
137 876860a3 Iustin Pop
    the total disk size of this node (mebibytes)
138 876860a3 Iustin Pop
139 876860a3 Iustin Pop
  free_disk
140 876860a3 Iustin Pop
    the free disk space on the node
141 876860a3 Iustin Pop
142 876860a3 Iustin Pop
  total_memory
143 876860a3 Iustin Pop
    the total memory size
144 876860a3 Iustin Pop
145 876860a3 Iustin Pop
  free_memory
146 876860a3 Iustin Pop
    free memory on the node; note that currently this does not take
147 876860a3 Iustin Pop
    into account the instances which are down on the node
148 876860a3 Iustin Pop
149 876860a3 Iustin Pop
  total_cpus
150 876860a3 Iustin Pop
    the physical number of CPUs present on the machine; depending on
151 876860a3 Iustin Pop
    the hypervisor, this might or might not be equal to how many CPUs
152 876860a3 Iustin Pop
    the node operating system sees;
153 876860a3 Iustin Pop
154 876860a3 Iustin Pop
  primary_ip
155 876860a3 Iustin Pop
    the primary IP address of the node
156 876860a3 Iustin Pop
157 876860a3 Iustin Pop
  secondary_ip
158 876860a3 Iustin Pop
    the secondary IP address of the node (the one used for the DRBD
159 876860a3 Iustin Pop
    replication); note that this can be the same as the primary one
160 876860a3 Iustin Pop
161 876860a3 Iustin Pop
  tags
162 876860a3 Iustin Pop
    list with the tags of the node
163 876860a3 Iustin Pop
164 77031881 Iustin Pop
  master_candidate:
165 77031881 Iustin Pop
    a boolean flag denoting whether this node is a master candidate
166 77031881 Iustin Pop
167 77031881 Iustin Pop
  drained:
168 77031881 Iustin Pop
    a boolean flag denoting whether this node is being drained
169 77031881 Iustin Pop
170 77031881 Iustin Pop
  offline:
171 77031881 Iustin Pop
    a boolean flag denoting whether this node is offline
172 77031881 Iustin Pop
173 77031881 Iustin Pop
  i_pri_memory:
174 77031881 Iustin Pop
    total memory required by primary instances
175 77031881 Iustin Pop
176 77031881 Iustin Pop
  i_pri_up_memory:
177 77031881 Iustin Pop
    total memory required by running primary instances
178 77031881 Iustin Pop
179 1116c3b2 Iustin Pop
  group:
180 1116c3b2 Iustin Pop
    the node group that this node belongs to
181 1116c3b2 Iustin Pop
182 77031881 Iustin Pop
  No allocations should be made on nodes having either the ``drained``
183 77031881 Iustin Pop
  or ``offline`` flags set. More details about these of node status
184 fd07c6b3 Iustin Pop
  flags is available in the manpage :manpage:`ganeti(7)`.
185 77031881 Iustin Pop
186 a1cef11c Iustin Pop
.. [*] Note that no run-time data is present for offline, drained or
187 a1cef11c Iustin Pop
   non-vm_capable nodes; this means the tags total_memory,
188 a1cef11c Iustin Pop
   reserved_memory, free_memory, total_disk, free_disk, total_cpus,
189 a1cef11c Iustin Pop
   i_pri_memory and i_pri_up memory will be absent
190 77031881 Iustin Pop
191 61791108 Adeodato Simo
Operation-specific input
192 61791108 Adeodato Simo
++++++++++++++++++++++++
193 61791108 Adeodato Simo
194 61791108 Adeodato Simo
All input dictionaries to the IAllocator carry, in the ``request``
195 61791108 Adeodato Simo
dictionary, detailed information about the operation that's being
196 61791108 Adeodato Simo
requested. The required keys vary depending on the type of operation, as
197 61791108 Adeodato Simo
follows.
198 61791108 Adeodato Simo
199 61791108 Adeodato Simo
In all cases, it includes:
200 61791108 Adeodato Simo
201 61791108 Adeodato Simo
  type
202 6d267b81 Adeodato Simo
    the request type; this can be either ``allocate``, ``relocate``,
203 f0edfcf6 Michael Hanselmann
    ``change-group`` or ``node-evacuate``. The
204 172679c9 Michael Hanselmann
    ``allocate`` request is used when a new instance needs to be placed
205 172679c9 Michael Hanselmann
    on the cluster. The ``relocate`` request is used when an existing
206 172679c9 Michael Hanselmann
    instance needs to be moved within its node group.
207 25ee7fd8 Michael Hanselmann
208 25ee7fd8 Michael Hanselmann
    The ``multi-evacuate`` protocol used to request that the script
209 25ee7fd8 Michael Hanselmann
    computes the optimal relocate solution for all secondary instances
210 f0edfcf6 Michael Hanselmann
    of the given nodes. It is now deprecated and needs only be
211 f0edfcf6 Michael Hanselmann
    implemented if backwards compatibility with Ganeti 2.4 and lower is
212 f0edfcf6 Michael Hanselmann
    needed.
213 25ee7fd8 Michael Hanselmann
214 25ee7fd8 Michael Hanselmann
    The ``change-group`` request is used to relocate multiple instances
215 25ee7fd8 Michael Hanselmann
    across multiple node groups. ``node-evacuate`` evacuates instances
216 25ee7fd8 Michael Hanselmann
    off their node(s). These are described in a separate :ref:`design
217 25ee7fd8 Michael Hanselmann
    document <multi-reloc-detailed-design>`.
218 61791108 Adeodato Simo
219 b1e47e2d Renรฉ Nussbaumer
    The ``multi-allocate`` request is used to allocate multiple
220 b1e47e2d Renรฉ Nussbaumer
    instances on the cluster. The request is beside of that very
221 b1e47e2d Renรฉ Nussbaumer
    similiar to the ``allocate`` one. For more details look at
222 b1e47e2d Renรฉ Nussbaumer
    :doc:`Ganeti bulk create <design-bulk-create>`.
223 b1e47e2d Renรฉ Nussbaumer
224 61791108 Adeodato Simo
For both allocate and relocate mode, the following extra keys are needed
225 61791108 Adeodato Simo
in the ``request`` dictionary:
226 61791108 Adeodato Simo
227 61791108 Adeodato Simo
  name
228 61791108 Adeodato Simo
    the name of the instance; if the request is a realocation, then this
229 61791108 Adeodato Simo
    name will be found in the list of instances (see below), otherwise
230 297b0cd3 Iustin Pop
    is the FQDN of the new instance; type *string*
231 61791108 Adeodato Simo
232 61791108 Adeodato Simo
  required_nodes
233 61791108 Adeodato Simo
    how many nodes should the algorithm return; while this information
234 61791108 Adeodato Simo
    can be deduced from the instace's disk template, it's better if
235 61791108 Adeodato Simo
    this computation is left to Ganeti as then allocator scripts are
236 297b0cd3 Iustin Pop
    less sensitive to changes to the disk templates; type *integer*
237 61791108 Adeodato Simo
238 61791108 Adeodato Simo
  disk_space_total
239 61791108 Adeodato Simo
    the total disk space that will be used by this instance on the
240 61791108 Adeodato Simo
    (new) nodes; again, this information can be computed from the list
241 61791108 Adeodato Simo
    of instance disks and its template type, but Ganeti is better
242 297b0cd3 Iustin Pop
    suited to compute it; type *integer*
243 61791108 Adeodato Simo
244 63fb7526 Michael Hanselmann
.. pyassert::
245 63fb7526 Michael Hanselmann
246 63fb7526 Michael Hanselmann
   constants.DISK_ACCESS_SET == set([constants.DISK_RDONLY,
247 63fb7526 Michael Hanselmann
     constants.DISK_RDWR])
248 63fb7526 Michael Hanselmann
249 61791108 Adeodato Simo
Allocation needs, in addition:
250 61791108 Adeodato Simo
251 61791108 Adeodato Simo
  disks
252 61791108 Adeodato Simo
    list of dictionaries holding the disk definitions for this
253 61791108 Adeodato Simo
    instance (in the order they are exported to the hypervisor):
254 61791108 Adeodato Simo
255 61791108 Adeodato Simo
    mode
256 63fb7526 Michael Hanselmann
      either :pyeval:`constants.DISK_RDONLY` or
257 63fb7526 Michael Hanselmann
      :pyeval:`constants.DISK_RDWR` denoting if the disk is read-only or
258 61791108 Adeodato Simo
      writable
259 61791108 Adeodato Simo
260 61791108 Adeodato Simo
    size
261 61791108 Adeodato Simo
      the size of this disk in mebibytes
262 61791108 Adeodato Simo
263 61791108 Adeodato Simo
  nics
264 61791108 Adeodato Simo
    a list of dictionaries holding the network interfaces for this
265 61791108 Adeodato Simo
    instance, containing:
266 61791108 Adeodato Simo
267 61791108 Adeodato Simo
    ip
268 61791108 Adeodato Simo
      the IP address that Ganeti know for this instance, or null
269 61791108 Adeodato Simo
270 61791108 Adeodato Simo
    mac
271 61791108 Adeodato Simo
      the MAC address for this interface
272 61791108 Adeodato Simo
273 61791108 Adeodato Simo
    bridge
274 61791108 Adeodato Simo
      the bridge to which this interface will be connected
275 61791108 Adeodato Simo
276 61791108 Adeodato Simo
  vcpus
277 61791108 Adeodato Simo
    the number of VCPUs for the instance
278 61791108 Adeodato Simo
279 61791108 Adeodato Simo
  disk_template
280 61791108 Adeodato Simo
    the disk template for the instance
281 61791108 Adeodato Simo
282 61791108 Adeodato Simo
  memory
283 61791108 Adeodato Simo
   the memory size for the instance
284 61791108 Adeodato Simo
285 61791108 Adeodato Simo
  os
286 61791108 Adeodato Simo
   the OS type for the instance
287 61791108 Adeodato Simo
288 61791108 Adeodato Simo
  tags
289 61791108 Adeodato Simo
    the list of the instance's tags
290 61791108 Adeodato Simo
291 61791108 Adeodato Simo
  hypervisor
292 61791108 Adeodato Simo
    the hypervisor of this instance
293 61791108 Adeodato Simo
294 61791108 Adeodato Simo
Relocation:
295 61791108 Adeodato Simo
296 61791108 Adeodato Simo
  relocate_from
297 1d42996b Iustin Pop
     a list of nodes to move the instance away from; for DRBD-based
298 1d42996b Iustin Pop
     instances, this will contain a single node, the current secondary
299 1d42996b Iustin Pop
     of the instance, whereas for shared-storage instance, this will
300 1d42996b Iustin Pop
     contain also a single node, the current primary of the instance;
301 1d42996b Iustin Pop
     type *list of strings*
302 61791108 Adeodato Simo
303 25ee7fd8 Michael Hanselmann
As for ``node-evacuate``, it needs the following request arguments:
304 6d267b81 Adeodato Simo
305 6d267b81 Adeodato Simo
  instances
306 25ee7fd8 Michael Hanselmann
    a list of instance names to evacuate; type *list of strings*
307 25ee7fd8 Michael Hanselmann
308 25ee7fd8 Michael Hanselmann
  evac_mode
309 25ee7fd8 Michael Hanselmann
    specify which instances to evacuate; one of ``primary-only``,
310 25ee7fd8 Michael Hanselmann
    ``secondary-only``, ``all``, type *string*
311 6d267b81 Adeodato Simo
312 25ee7fd8 Michael Hanselmann
``change-group`` needs the following request arguments:
313 25ee7fd8 Michael Hanselmann
314 25ee7fd8 Michael Hanselmann
  instances
315 25ee7fd8 Michael Hanselmann
    a list of instance names whose group to change; type
316 25ee7fd8 Michael Hanselmann
    *list of strings*
317 6d267b81 Adeodato Simo
318 6d267b81 Adeodato Simo
  target_groups
319 25ee7fd8 Michael Hanselmann
    must either be the empty list, or contain a list of group UUIDs that
320 25ee7fd8 Michael Hanselmann
    should be considered for relocating instances to; type
321 25ee7fd8 Michael Hanselmann
    *list of strings*
322 6d267b81 Adeodato Simo
323 b1e47e2d Renรฉ Nussbaumer
``multi-allocate`` needs the following request arguments:
324 b1e47e2d Renรฉ Nussbaumer
325 b1e47e2d Renรฉ Nussbaumer
  instances
326 b1e47e2d Renรฉ Nussbaumer
    a list of request dicts
327 b1e47e2d Renรฉ Nussbaumer
328 0ac2ff3b Spyros Trigazis
MonD data
329 0ac2ff3b Spyros Trigazis
+++++++++
330 0ac2ff3b Spyros Trigazis
331 0ac2ff3b Spyros Trigazis
Additional information is available from mond. Mond's data collectors
332 0ac2ff3b Spyros Trigazis
provide information that can help an allocator script make better
333 0ac2ff3b Spyros Trigazis
decisions when allocating a new instance. Mond's information may also be
334 0ac2ff3b Spyros Trigazis
accessible from a mock file mainly for testing purposes. The file will
335 0ac2ff3b Spyros Trigazis
be in JSON format and will present an array of :ref:`report objects
336 0ac2ff3b Spyros Trigazis
<monitoring-agent-format-of-the-report>`.
337 0ac2ff3b Spyros Trigazis
338 0d853843 Iustin Pop
Response message
339 0d853843 Iustin Pop
~~~~~~~~~~~~~~~~
340 876860a3 Iustin Pop
341 876860a3 Iustin Pop
The response message is much more simple than the input one. It is
342 876860a3 Iustin Pop
also a dict having three keys:
343 876860a3 Iustin Pop
344 876860a3 Iustin Pop
success
345 5bbd3f7f Michael Hanselmann
  a boolean value denoting if the allocation was successful or not
346 876860a3 Iustin Pop
347 876860a3 Iustin Pop
info
348 876860a3 Iustin Pop
  a string with information from the scripts; if the allocation fails,
349 876860a3 Iustin Pop
  this will be shown to the user
350 876860a3 Iustin Pop
351 632fb7ec Iustin Pop
result
352 632fb7ec Iustin Pop
  the output of the algorithm; even if the algorithm failed
353 632fb7ec Iustin Pop
  (i.e. success is false), this must be returned as an empty list
354 632fb7ec Iustin Pop
355 632fb7ec Iustin Pop
  for allocate/relocate, this is the list of node(s) for the instance;
356 632fb7ec Iustin Pop
  note that the length of this list must equal the ``requested_nodes``
357 632fb7ec Iustin Pop
  entry in the input message, otherwise Ganeti will consider the result
358 632fb7ec Iustin Pop
  as failed
359 632fb7ec Iustin Pop
360 172679c9 Michael Hanselmann
  for the ``node-evacuate`` and ``change-group`` modes, this is a
361 172679c9 Michael Hanselmann
  dictionary containing, among other information, a list of lists of
362 172679c9 Michael Hanselmann
  serialized opcodes; see the :ref:`design document
363 172679c9 Michael Hanselmann
  <multi-reloc-result>` for a detailed description
364 6d267b81 Adeodato Simo
365 b1e47e2d Renรฉ Nussbaumer
  for the ``multi-allocate`` mode this is a tuple of 2 lists, the first
366 b1e47e2d Renรฉ Nussbaumer
  being element of the tuple is a list of succeeded allocation, with the
367 b1e47e2d Renรฉ Nussbaumer
  instance name as first element of each entry and the node placement in
368 b1e47e2d Renรฉ Nussbaumer
  the second. The second element of the tuple is the instance list of
369 b1e47e2d Renรฉ Nussbaumer
  failed allocations.
370 b1e47e2d Renรฉ Nussbaumer
371 632fb7ec Iustin Pop
.. note:: Current Ganeti version accepts either ``result`` or ``nodes``
372 632fb7ec Iustin Pop
   as a backwards-compatibility measure (older versions only supported
373 632fb7ec Iustin Pop
   ``nodes``)
374 876860a3 Iustin Pop
375 876860a3 Iustin Pop
Examples
376 876860a3 Iustin Pop
--------
377 876860a3 Iustin Pop
378 876860a3 Iustin Pop
Input messages to scripts
379 876860a3 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~~~~~
380 876860a3 Iustin Pop
381 61791108 Adeodato Simo
Input message, new instance allocation (common elements are listed this
382 61791108 Adeodato Simo
time, but not included in further examples below)::
383 876860a3 Iustin Pop
384 876860a3 Iustin Pop
  {
385 61791108 Adeodato Simo
    "version": 2,
386 61791108 Adeodato Simo
    "cluster_name": "cluster1.example.com",
387 876860a3 Iustin Pop
    "cluster_tags": [],
388 61791108 Adeodato Simo
    "enabled_hypervisors": [
389 61791108 Adeodato Simo
      "xen-pvm"
390 61791108 Adeodato Simo
    ],
391 61791108 Adeodato Simo
    "nodegroups": {
392 61791108 Adeodato Simo
      "f4e06e0d-528a-4963-a5ad-10f3e114232d": {
393 61791108 Adeodato Simo
        "name": "default",
394 2daca99b Thomas Thrainer
        "alloc_policy": "preferred",
395 2daca99b Thomas Thrainer
        "networks": ["net-uuid-1", "net-uuid-2"],
396 2daca99b Thomas Thrainer
        "ipolicy": {
397 2daca99b Thomas Thrainer
          "disk-templates": ["drbd", "plain"],
398 2daca99b Thomas Thrainer
          "minmax": [
399 2daca99b Thomas Thrainer
            {
400 2daca99b Thomas Thrainer
              "max": {
401 2daca99b Thomas Thrainer
                "cpu-count": 2,
402 2daca99b Thomas Thrainer
                "disk-count": 8,
403 2daca99b Thomas Thrainer
                "disk-size": 2048,
404 2daca99b Thomas Thrainer
                "memory-size": 12800,
405 2daca99b Thomas Thrainer
                "nic-count": 8,
406 2daca99b Thomas Thrainer
                "spindle-use": 8
407 2daca99b Thomas Thrainer
              },
408 2daca99b Thomas Thrainer
              "min": {
409 2daca99b Thomas Thrainer
                "cpu-count": 1,
410 2daca99b Thomas Thrainer
                "disk-count": 1,
411 2daca99b Thomas Thrainer
                "disk-size": 1024,
412 2daca99b Thomas Thrainer
                "memory-size": 128,
413 2daca99b Thomas Thrainer
                "nic-count": 1,
414 2daca99b Thomas Thrainer
                "spindle-use": 1
415 2daca99b Thomas Thrainer
              }
416 2daca99b Thomas Thrainer
            }
417 2daca99b Thomas Thrainer
          ],
418 2daca99b Thomas Thrainer
          "spindle-ratio": 32.0,
419 2daca99b Thomas Thrainer
          "std": {
420 2daca99b Thomas Thrainer
            "cpu-count": 1,
421 2daca99b Thomas Thrainer
            "disk-count": 1,
422 2daca99b Thomas Thrainer
            "disk-size": 1024,
423 2daca99b Thomas Thrainer
            "memory-size": 128,
424 2daca99b Thomas Thrainer
            "nic-count": 1,
425 2daca99b Thomas Thrainer
            "spindle-use": 1
426 2daca99b Thomas Thrainer
          },
427 2daca99b Thomas Thrainer
          "vcpu-ratio": 4.0
428 2daca99b Thomas Thrainer
        },
429 2daca99b Thomas Thrainer
        "tags": ["ng-tag-1", "ng-tag-2"]
430 61791108 Adeodato Simo
      }
431 876860a3 Iustin Pop
    },
432 876860a3 Iustin Pop
    "instances": {
433 876860a3 Iustin Pop
      "instance1.example.com": {
434 876860a3 Iustin Pop
        "tags": [],
435 876860a3 Iustin Pop
        "should_run": false,
436 876860a3 Iustin Pop
        "disks": [
437 876860a3 Iustin Pop
          {
438 876860a3 Iustin Pop
            "mode": "w",
439 876860a3 Iustin Pop
            "size": 64
440 876860a3 Iustin Pop
          },
441 876860a3 Iustin Pop
          {
442 876860a3 Iustin Pop
            "mode": "w",
443 876860a3 Iustin Pop
            "size": 512
444 876860a3 Iustin Pop
          }
445 876860a3 Iustin Pop
        ],
446 876860a3 Iustin Pop
        "nics": [
447 876860a3 Iustin Pop
          {
448 876860a3 Iustin Pop
            "ip": null,
449 876860a3 Iustin Pop
            "mac": "aa:00:00:00:60:bf",
450 876860a3 Iustin Pop
            "bridge": "xen-br0"
451 876860a3 Iustin Pop
          }
452 876860a3 Iustin Pop
        ],
453 876860a3 Iustin Pop
        "vcpus": 1,
454 876860a3 Iustin Pop
        "disk_template": "plain",
455 876860a3 Iustin Pop
        "memory": 128,
456 876860a3 Iustin Pop
        "nodes": [
457 876860a3 Iustin Pop
          "nodee1.com"
458 876860a3 Iustin Pop
        ],
459 6f547f96 Guido Trotter
        "os": "debootstrap+default"
460 876860a3 Iustin Pop
      },
461 876860a3 Iustin Pop
      "instance2.example.com": {
462 876860a3 Iustin Pop
        "tags": [],
463 876860a3 Iustin Pop
        "should_run": false,
464 876860a3 Iustin Pop
        "disks": [
465 876860a3 Iustin Pop
          {
466 876860a3 Iustin Pop
            "mode": "w",
467 876860a3 Iustin Pop
            "size": 512
468 876860a3 Iustin Pop
          },
469 876860a3 Iustin Pop
          {
470 876860a3 Iustin Pop
            "mode": "w",
471 876860a3 Iustin Pop
            "size": 256
472 876860a3 Iustin Pop
          }
473 876860a3 Iustin Pop
        ],
474 876860a3 Iustin Pop
        "nics": [
475 876860a3 Iustin Pop
          {
476 876860a3 Iustin Pop
            "ip": null,
477 876860a3 Iustin Pop
            "mac": "aa:00:00:55:f8:38",
478 876860a3 Iustin Pop
            "bridge": "xen-br0"
479 876860a3 Iustin Pop
          }
480 876860a3 Iustin Pop
        ],
481 876860a3 Iustin Pop
        "vcpus": 1,
482 876860a3 Iustin Pop
        "disk_template": "drbd",
483 876860a3 Iustin Pop
        "memory": 512,
484 876860a3 Iustin Pop
        "nodes": [
485 876860a3 Iustin Pop
          "node2.example.com",
486 876860a3 Iustin Pop
          "node3.example.com"
487 876860a3 Iustin Pop
        ],
488 6f547f96 Guido Trotter
        "os": "debootstrap+default"
489 876860a3 Iustin Pop
      }
490 876860a3 Iustin Pop
    },
491 876860a3 Iustin Pop
    "nodes": {
492 876860a3 Iustin Pop
      "node1.example.com": {
493 876860a3 Iustin Pop
        "total_disk": 858276,
494 926feaf1 Manuel Franceschini
        "primary_ip": "198.51.100.1",
495 926feaf1 Manuel Franceschini
        "secondary_ip": "192.0.2.1",
496 876860a3 Iustin Pop
        "tags": [],
497 61791108 Adeodato Simo
        "group": "f4e06e0d-528a-4963-a5ad-10f3e114232d",
498 876860a3 Iustin Pop
        "free_memory": 3505,
499 876860a3 Iustin Pop
        "free_disk": 856740,
500 876860a3 Iustin Pop
        "total_memory": 4095
501 876860a3 Iustin Pop
      },
502 876860a3 Iustin Pop
      "node2.example.com": {
503 876860a3 Iustin Pop
        "total_disk": 858240,
504 926feaf1 Manuel Franceschini
        "primary_ip": "198.51.100.2",
505 926feaf1 Manuel Franceschini
        "secondary_ip": "192.0.2.2",
506 876860a3 Iustin Pop
        "tags": ["test"],
507 61791108 Adeodato Simo
        "group": "f4e06e0d-528a-4963-a5ad-10f3e114232d",
508 876860a3 Iustin Pop
        "free_memory": 3505,
509 876860a3 Iustin Pop
        "free_disk": 848320,
510 876860a3 Iustin Pop
        "total_memory": 4095
511 876860a3 Iustin Pop
      },
512 876860a3 Iustin Pop
      "node3.example.com.com": {
513 876860a3 Iustin Pop
        "total_disk": 572184,
514 926feaf1 Manuel Franceschini
        "primary_ip": "198.51.100.3",
515 926feaf1 Manuel Franceschini
        "secondary_ip": "192.0.2.3",
516 876860a3 Iustin Pop
        "tags": [],
517 61791108 Adeodato Simo
        "group": "f4e06e0d-528a-4963-a5ad-10f3e114232d",
518 876860a3 Iustin Pop
        "free_memory": 3505,
519 876860a3 Iustin Pop
        "free_disk": 570648,
520 876860a3 Iustin Pop
        "total_memory": 4095
521 876860a3 Iustin Pop
      }
522 61791108 Adeodato Simo
    },
523 61791108 Adeodato Simo
    "request": {
524 61791108 Adeodato Simo
      "type": "allocate",
525 61791108 Adeodato Simo
      "name": "instance3.example.com",
526 61791108 Adeodato Simo
      "required_nodes": 2,
527 61791108 Adeodato Simo
      "disk_space_total": 3328,
528 61791108 Adeodato Simo
      "disks": [
529 61791108 Adeodato Simo
        {
530 61791108 Adeodato Simo
          "mode": "w",
531 61791108 Adeodato Simo
          "size": 1024
532 61791108 Adeodato Simo
        },
533 61791108 Adeodato Simo
        {
534 61791108 Adeodato Simo
          "mode": "w",
535 61791108 Adeodato Simo
          "size": 2048
536 61791108 Adeodato Simo
        }
537 61791108 Adeodato Simo
      ],
538 61791108 Adeodato Simo
      "nics": [
539 61791108 Adeodato Simo
        {
540 61791108 Adeodato Simo
          "ip": null,
541 61791108 Adeodato Simo
          "mac": "00:11:22:33:44:55",
542 61791108 Adeodato Simo
          "bridge": null
543 61791108 Adeodato Simo
        }
544 61791108 Adeodato Simo
      ],
545 61791108 Adeodato Simo
      "vcpus": 1,
546 61791108 Adeodato Simo
      "disk_template": "drbd",
547 61791108 Adeodato Simo
      "memory": 2048,
548 61791108 Adeodato Simo
      "os": "debootstrap+default",
549 61791108 Adeodato Simo
      "tags": [
550 61791108 Adeodato Simo
        "type:test",
551 61791108 Adeodato Simo
        "owner:foo"
552 61791108 Adeodato Simo
      ],
553 61791108 Adeodato Simo
      hypervisor: "xen-pvm"
554 876860a3 Iustin Pop
    }
555 876860a3 Iustin Pop
  }
556 876860a3 Iustin Pop
557 61791108 Adeodato Simo
Input message, reallocation::
558 876860a3 Iustin Pop
559 61791108 Adeodato Simo
  {
560 61791108 Adeodato Simo
    "version": 2,
561 61791108 Adeodato Simo
    ...
562 61791108 Adeodato Simo
    "request": {
563 61791108 Adeodato Simo
      "type": "relocate",
564 61791108 Adeodato Simo
      "name": "instance2.example.com",
565 61791108 Adeodato Simo
      "required_nodes": 1,
566 61791108 Adeodato Simo
      "disk_space_total": 832,
567 61791108 Adeodato Simo
      "relocate_from": [
568 61791108 Adeodato Simo
        "node3.example.com"
569 61791108 Adeodato Simo
      ]
570 61791108 Adeodato Simo
    }
571 61791108 Adeodato Simo
  }
572 876860a3 Iustin Pop
573 632fb7ec Iustin Pop
574 876860a3 Iustin Pop
Response messages
575 876860a3 Iustin Pop
~~~~~~~~~~~~~~~~~
576 876860a3 Iustin Pop
Successful response message::
577 876860a3 Iustin Pop
578 876860a3 Iustin Pop
  {
579 61791108 Adeodato Simo
    "success": true,
580 876860a3 Iustin Pop
    "info": "Allocation successful",
581 632fb7ec Iustin Pop
    "result": [
582 876860a3 Iustin Pop
      "node2.example.com",
583 876860a3 Iustin Pop
      "node1.example.com"
584 61791108 Adeodato Simo
    ]
585 876860a3 Iustin Pop
  }
586 876860a3 Iustin Pop
587 876860a3 Iustin Pop
Failed response message::
588 876860a3 Iustin Pop
589 876860a3 Iustin Pop
  {
590 61791108 Adeodato Simo
    "success": false,
591 876860a3 Iustin Pop
    "info": "Can't find a suitable node for position 2 (already selected: node2.example.com)",
592 61791108 Adeodato Simo
    "result": []
593 876860a3 Iustin Pop
  }
594 876860a3 Iustin Pop
595 632fb7ec Iustin Pop
Successful node evacuation message::
596 632fb7ec Iustin Pop
597 632fb7ec Iustin Pop
  {
598 61791108 Adeodato Simo
    "success": true,
599 632fb7ec Iustin Pop
    "info": "Request successful",
600 632fb7ec Iustin Pop
    "result": [
601 632fb7ec Iustin Pop
      [
602 632fb7ec Iustin Pop
        "instance1",
603 632fb7ec Iustin Pop
        "node3"
604 632fb7ec Iustin Pop
      ],
605 632fb7ec Iustin Pop
      [
606 632fb7ec Iustin Pop
        "instance2",
607 632fb7ec Iustin Pop
        "node1"
608 632fb7ec Iustin Pop
      ]
609 61791108 Adeodato Simo
    ]
610 632fb7ec Iustin Pop
  }
611 632fb7ec Iustin Pop
612 632fb7ec Iustin Pop
613 876860a3 Iustin Pop
Command line messages
614 876860a3 Iustin Pop
~~~~~~~~~~~~~~~~~~~~~
615 876860a3 Iustin Pop
::
616 876860a3 Iustin Pop
617 6f547f96 Guido Trotter
  # gnt-instance add -t plain -m 2g --os-size 1g --swap-size 512m --iallocator hail -o debootstrap+default instance3
618 876860a3 Iustin Pop
  Selected nodes for the instance: node1.example.com
619 876860a3 Iustin Pop
  * creating instance disks...
620 876860a3 Iustin Pop
  [...]
621 876860a3 Iustin Pop
622 6f547f96 Guido Trotter
  # gnt-instance add -t plain -m 3400m --os-size 1g --swap-size 512m --iallocator hail -o debootstrap+default instance4
623 876860a3 Iustin Pop
  Failure: prerequisites not met for this operation:
624 6f547f96 Guido Trotter
  Can't compute nodes using iallocator 'hail': Can't find a suitable node for position 1 (already selected: )
625 876860a3 Iustin Pop
626 6f547f96 Guido Trotter
  # gnt-instance add -t drbd -m 1400m --os-size 1g --swap-size 512m --iallocator hail -o debootstrap+default instance5
627 876860a3 Iustin Pop
  Failure: prerequisites not met for this operation:
628 6f547f96 Guido Trotter
  Can't compute nodes using iallocator 'hail': Can't find a suitable node for position 2 (already selected: node1.example.com)
629 6f547f96 Guido Trotter
630 6f547f96 Guido Trotter
Reference implementation
631 6f547f96 Guido Trotter
~~~~~~~~~~~~~~~~~~~~~~~~
632 6f547f96 Guido Trotter
633 1ebe6dbd Iustin Pop
Ganeti's default iallocator is "hail" which is available when "htools"
634 1ebe6dbd Iustin Pop
components have been enabled at build time (see :doc:`install-quick` for
635 1ebe6dbd Iustin Pop
more details).
636 558fd122 Michael Hanselmann
637 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :
638 632fb7ec Iustin Pop
.. Local Variables:
639 632fb7ec Iustin Pop
.. mode: rst
640 632fb7ec Iustin Pop
.. fill-column: 72
641 632fb7ec Iustin Pop
.. End: