Statistics
| Branch: | Tag: | Revision:

root / doc / rapi.rst @ 3882937a

History | View | Annotate | Download (26 kB)

1 4352bf6d Iustin Pop
Ganeti remote API
2 4352bf6d Iustin Pop
=================
3 4352bf6d Iustin Pop
4 c8e0a534 Iustin Pop
Documents Ganeti version |version|
5 4352bf6d Iustin Pop
6 4352bf6d Iustin Pop
.. contents::
7 4352bf6d Iustin Pop
8 4352bf6d Iustin Pop
Introduction
9 4352bf6d Iustin Pop
------------
10 4352bf6d Iustin Pop
11 4352bf6d Iustin Pop
Ganeti supports a remote API for enable external tools to easily
12 4352bf6d Iustin Pop
retrieve information about a cluster's state. The remote API daemon,
13 4352bf6d Iustin Pop
*ganeti-rapi*, is automatically started on the master node. By default
14 4352bf6d Iustin Pop
it runs on TCP port 5080, but this can be changed either in
15 4352bf6d Iustin Pop
``.../constants.py`` or via the command line parameter *-p*. SSL mode,
16 4352bf6d Iustin Pop
which is used by default, can also be disabled by passing command line
17 4352bf6d Iustin Pop
parameters.
18 4352bf6d Iustin Pop
19 c099b8d8 Michael Hanselmann
20 c099b8d8 Michael Hanselmann
Users and passwords
21 c099b8d8 Michael Hanselmann
-------------------
22 c099b8d8 Michael Hanselmann
23 c099b8d8 Michael Hanselmann
``ganeti-rapi`` reads users and passwords from a file (usually
24 c099b8d8 Michael Hanselmann
``/var/lib/ganeti/rapi_users``) on startup. After modifying the password
25 c099b8d8 Michael Hanselmann
file, ``ganeti-rapi`` must be restarted.
26 c099b8d8 Michael Hanselmann
27 c099b8d8 Michael Hanselmann
Each line consists of two or three fields separated by whitespace. The
28 c099b8d8 Michael Hanselmann
first two fields are for username and password. The third field is
29 c099b8d8 Michael Hanselmann
optional and can be used to specify per-user options. Currently,
30 c099b8d8 Michael Hanselmann
``write`` is the only option supported and enables the user to execute
31 ab2e463a Michael Hanselmann
operations modifying the cluster. Lines starting with the hash sign
32 ab2e463a Michael Hanselmann
(``#``) are treated as comments.
33 c099b8d8 Michael Hanselmann
34 c099b8d8 Michael Hanselmann
Passwords can either be written in clear text or as a hash. Clear text
35 c099b8d8 Michael Hanselmann
passwords may not start with an opening brace (``{``) or they must be
36 c099b8d8 Michael Hanselmann
prefixed with ``{cleartext}``. To use the hashed form, get the MD5 hash
37 c099b8d8 Michael Hanselmann
of the string ``$username:Ganeti Remote API:$password`` (e.g. ``echo -n
38 ab2e463a Michael Hanselmann
'jack:Ganeti Remote API:abc123' | openssl md5``) [#pwhash]_ and prefix
39 ab2e463a Michael Hanselmann
it with ``{ha1}``. Using the scheme prefix for all passwords is
40 ab2e463a Michael Hanselmann
recommended. Scheme prefixes are not case sensitive.
41 c099b8d8 Michael Hanselmann
42 c099b8d8 Michael Hanselmann
Example::
43 c099b8d8 Michael Hanselmann
44 c099b8d8 Michael Hanselmann
  # Give Jack and Fred read-only access
45 c099b8d8 Michael Hanselmann
  jack abc123
46 c099b8d8 Michael Hanselmann
  fred {cleartext}foo555
47 c099b8d8 Michael Hanselmann
48 c099b8d8 Michael Hanselmann
  # Give write access to an imaginary instance creation script
49 c099b8d8 Michael Hanselmann
  autocreator xyz789 write
50 c099b8d8 Michael Hanselmann
51 c099b8d8 Michael Hanselmann
  # Hashed password for Jessica
52 c099b8d8 Michael Hanselmann
  jessica {HA1}7046452df2cbb530877058712cf17bd4 write
53 c099b8d8 Michael Hanselmann
54 c099b8d8 Michael Hanselmann
55 c099b8d8 Michael Hanselmann
.. [#pwhash] Using the MD5 hash of username, realm and password is
56 c099b8d8 Michael Hanselmann
   described in RFC2617_ ("HTTP Authentication"), sections 3.2.2.2 and
57 c099b8d8 Michael Hanselmann
   3.3. The reason for using it over another algorithm is forward
58 c099b8d8 Michael Hanselmann
   compatibility. If ``ganeti-rapi`` were to implement HTTP Digest
59 c099b8d8 Michael Hanselmann
   authentication in the future, the same hash could be used.
60 c099b8d8 Michael Hanselmann
   In the current version ``ganeti-rapi``'s realm, ``Ganeti Remote
61 c099b8d8 Michael Hanselmann
   API``, can only be changed by modifying the source code.
62 c099b8d8 Michael Hanselmann
63 c099b8d8 Michael Hanselmann
64 4352bf6d Iustin Pop
Protocol
65 4352bf6d Iustin Pop
--------
66 4352bf6d Iustin Pop
67 c099b8d8 Michael Hanselmann
The protocol used is JSON_ over HTTP designed after the REST_ principle.
68 c099b8d8 Michael Hanselmann
HTTP Basic authentication as per RFC2617_ is supported.
69 4352bf6d Iustin Pop
70 4352bf6d Iustin Pop
.. _JSON: http://www.json.org/
71 4352bf6d Iustin Pop
.. _REST: http://en.wikipedia.org/wiki/Representational_State_Transfer
72 c099b8d8 Michael Hanselmann
.. _RFC2617: http://tools.ietf.org/rfc/rfc2617.txt
73 4352bf6d Iustin Pop
74 88394aa7 René Nussbaumer
75 88394aa7 René Nussbaumer
PUT or POST?
76 88394aa7 René Nussbaumer
------------
77 88394aa7 René Nussbaumer
78 88394aa7 René Nussbaumer
According to RFC2616 the main difference between PUT and POST is that
79 88394aa7 René Nussbaumer
POST can create new resources but PUT can only create the resource the
80 88394aa7 René Nussbaumer
URI was pointing to on the PUT request.
81 88394aa7 René Nussbaumer
82 88394aa7 René Nussbaumer
Unfortunately, due to historic reasons, the Ganeti RAPI library is not
83 88394aa7 René Nussbaumer
consistent with this usage, so just use the methods as documented below
84 88394aa7 René Nussbaumer
for each resource.
85 88394aa7 René Nussbaumer
86 88394aa7 René Nussbaumer
For more details have a look in the source code at
87 88394aa7 René Nussbaumer
``lib/rapi/rlib2.py``.
88 88394aa7 René Nussbaumer
89 88394aa7 René Nussbaumer
90 88394aa7 René Nussbaumer
Generic parameter types
91 88394aa7 René Nussbaumer
-----------------------
92 88394aa7 René Nussbaumer
93 88394aa7 René Nussbaumer
A few generic refered parameter types and the values they allow.
94 88394aa7 René Nussbaumer
95 88394aa7 René Nussbaumer
``bool``
96 88394aa7 René Nussbaumer
++++++++
97 88394aa7 René Nussbaumer
98 88394aa7 René Nussbaumer
A boolean option will accept ``1`` or ``0`` as numbers but not
99 88394aa7 René Nussbaumer
i.e. ``True`` or ``False``.
100 88394aa7 René Nussbaumer
101 2cad4b91 Iustin Pop
Generic parameters
102 2cad4b91 Iustin Pop
------------------
103 2cad4b91 Iustin Pop
104 7faf5110 Michael Hanselmann
A few parameter mean the same thing across all resources which implement
105 7faf5110 Michael Hanselmann
it.
106 2cad4b91 Iustin Pop
107 2cad4b91 Iustin Pop
``bulk``
108 2cad4b91 Iustin Pop
++++++++
109 2cad4b91 Iustin Pop
110 c71a1a3d Iustin Pop
Bulk-mode means that for the resources which usually return just a list
111 c71a1a3d Iustin Pop
of child resources (e.g. ``/2/instances`` which returns just instance
112 c71a1a3d Iustin Pop
names), the output will instead contain detailed data for all these
113 c71a1a3d Iustin Pop
subresources. This is more efficient than query-ing the sub-resources
114 c71a1a3d Iustin Pop
themselves.
115 2cad4b91 Iustin Pop
116 2cad4b91 Iustin Pop
``dry-run``
117 2cad4b91 Iustin Pop
+++++++++++
118 2cad4b91 Iustin Pop
119 88394aa7 René Nussbaumer
The boolean *dry-run* argument, if provided and set, signals to Ganeti
120 88394aa7 René Nussbaumer
that the job should not be executed, only the pre-execution checks will
121 88394aa7 René Nussbaumer
be done.
122 2cad4b91 Iustin Pop
123 c71a1a3d Iustin Pop
This is useful in trying to determine (without guarantees though, as in
124 c71a1a3d Iustin Pop
the meantime the cluster state could have changed) if the operation is
125 c71a1a3d Iustin Pop
likely to succeed or at least start executing.
126 2cad4b91 Iustin Pop
127 3427d34f Michael Hanselmann
``force``
128 3427d34f Michael Hanselmann
+++++++++++
129 3427d34f Michael Hanselmann
130 3427d34f Michael Hanselmann
Force operation to continue even if it will cause the cluster to become
131 3427d34f Michael Hanselmann
inconsistent (e.g. because there are not enough master candidates).
132 3427d34f Michael Hanselmann
133 4352bf6d Iustin Pop
Usage examples
134 4352bf6d Iustin Pop
--------------
135 4352bf6d Iustin Pop
136 c71a1a3d Iustin Pop
You can access the API using your favorite programming language as long
137 c71a1a3d Iustin Pop
as it supports network connections.
138 4352bf6d Iustin Pop
139 5ef5cfea Michael Hanselmann
Ganeti RAPI client
140 5ef5cfea Michael Hanselmann
++++++++++++++++++
141 5ef5cfea Michael Hanselmann
142 5ef5cfea Michael Hanselmann
Ganeti includes a standalone RAPI client, ``lib/rapi/client.py``.
143 5ef5cfea Michael Hanselmann
144 4352bf6d Iustin Pop
Shell
145 4352bf6d Iustin Pop
+++++
146 4352bf6d Iustin Pop
147 c8e0a534 Iustin Pop
.. highlight:: sh
148 c8e0a534 Iustin Pop
149 4352bf6d Iustin Pop
Using wget::
150 4352bf6d Iustin Pop
151 c8e0a534 Iustin Pop
   wget -q -O - https://CLUSTERNAME:5080/2/info
152 4352bf6d Iustin Pop
153 4352bf6d Iustin Pop
or curl::
154 4352bf6d Iustin Pop
155 4352bf6d Iustin Pop
  curl https://CLUSTERNAME:5080/2/info
156 4352bf6d Iustin Pop
157 4352bf6d Iustin Pop
158 4352bf6d Iustin Pop
Python
159 4352bf6d Iustin Pop
++++++
160 4352bf6d Iustin Pop
161 c71a1a3d Iustin Pop
.. highlight:: python
162 c71a1a3d Iustin Pop
163 c71a1a3d Iustin Pop
::
164 4352bf6d Iustin Pop
165 4352bf6d Iustin Pop
  import urllib2
166 4fb301b5 Tim Boring
  f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info')
167 4352bf6d Iustin Pop
  print f.read()
168 4352bf6d Iustin Pop
169 4352bf6d Iustin Pop
170 4352bf6d Iustin Pop
JavaScript
171 4352bf6d Iustin Pop
++++++++++
172 4352bf6d Iustin Pop
173 2cad4b91 Iustin Pop
.. warning:: While it's possible to use JavaScript, it poses several
174 c71a1a3d Iustin Pop
   potential problems, including browser blocking request due to
175 c71a1a3d Iustin Pop
   non-standard ports or different domain names. Fetching the data on
176 c71a1a3d Iustin Pop
   the webserver is easier.
177 4352bf6d Iustin Pop
178 c8e0a534 Iustin Pop
.. highlight:: javascript
179 c8e0a534 Iustin Pop
180 4352bf6d Iustin Pop
::
181 4352bf6d Iustin Pop
182 4fb301b5 Tim Boring
  var url = 'https://CLUSTERNAME:5080/2/info';
183 4352bf6d Iustin Pop
  var info;
184 4352bf6d Iustin Pop
  var xmlreq = new XMLHttpRequest();
185 4352bf6d Iustin Pop
  xmlreq.onreadystatechange = function () {
186 4352bf6d Iustin Pop
    if (xmlreq.readyState != 4) return;
187 4352bf6d Iustin Pop
    if (xmlreq.status == 200) {
188 4352bf6d Iustin Pop
      info = eval("(" + xmlreq.responseText + ")");
189 4352bf6d Iustin Pop
      alert(info);
190 4352bf6d Iustin Pop
    } else {
191 4352bf6d Iustin Pop
      alert('Error fetching cluster info');
192 4352bf6d Iustin Pop
    }
193 4352bf6d Iustin Pop
    xmlreq = null;
194 4352bf6d Iustin Pop
  };
195 4352bf6d Iustin Pop
  xmlreq.open('GET', url, true);
196 4352bf6d Iustin Pop
  xmlreq.send(null);
197 4352bf6d Iustin Pop
198 4352bf6d Iustin Pop
Resources
199 4352bf6d Iustin Pop
---------
200 4352bf6d Iustin Pop
201 c8e0a534 Iustin Pop
.. highlight:: javascript
202 6d81475c Iustin Pop
203 c8e0a534 Iustin Pop
``/``
204 c8e0a534 Iustin Pop
+++++
205 6d81475c Iustin Pop
206 c8e0a534 Iustin Pop
The root resource.
207 6d81475c Iustin Pop
208 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
209 6d81475c Iustin Pop
210 c8e0a534 Iustin Pop
``GET``
211 c8e0a534 Iustin Pop
~~~~~~~
212 6d81475c Iustin Pop
213 c8e0a534 Iustin Pop
Shows the list of mapped resources.
214 6d81475c Iustin Pop
215 c8e0a534 Iustin Pop
Returns: a dictionary with 'name' and 'uri' keys for each of them.
216 6d81475c Iustin Pop
217 c8e0a534 Iustin Pop
``/2``
218 c8e0a534 Iustin Pop
++++++
219 6d81475c Iustin Pop
220 c8e0a534 Iustin Pop
The ``/2`` resource, the root of the version 2 API.
221 6d81475c Iustin Pop
222 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
223 6d81475c Iustin Pop
224 c8e0a534 Iustin Pop
``GET``
225 c8e0a534 Iustin Pop
~~~~~~~
226 6d81475c Iustin Pop
227 c8e0a534 Iustin Pop
Show the list of mapped resources.
228 6d81475c Iustin Pop
229 c8e0a534 Iustin Pop
Returns: a dictionary with ``name`` and ``uri`` keys for each of them.
230 6d81475c Iustin Pop
231 c8e0a534 Iustin Pop
``/2/info``
232 c8e0a534 Iustin Pop
+++++++++++
233 6d81475c Iustin Pop
234 c8e0a534 Iustin Pop
Cluster information resource.
235 6d81475c Iustin Pop
236 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
237 6d81475c Iustin Pop
238 c8e0a534 Iustin Pop
``GET``
239 c8e0a534 Iustin Pop
~~~~~~~
240 6d81475c Iustin Pop
241 c8e0a534 Iustin Pop
Returns cluster information.
242 6d81475c Iustin Pop
243 c8e0a534 Iustin Pop
Example::
244 6d81475c Iustin Pop
245 6d81475c Iustin Pop
  {
246 6d81475c Iustin Pop
    "config_version": 2000000,
247 6d81475c Iustin Pop
    "name": "cluster",
248 6d81475c Iustin Pop
    "software_version": "2.0.0~beta2",
249 6d81475c Iustin Pop
    "os_api_version": 10,
250 6d81475c Iustin Pop
    "export_version": 0,
251 6d81475c Iustin Pop
    "candidate_pool_size": 10,
252 6d81475c Iustin Pop
    "enabled_hypervisors": [
253 6d81475c Iustin Pop
      "fake"
254 6d81475c Iustin Pop
    ],
255 6d81475c Iustin Pop
    "hvparams": {
256 6d81475c Iustin Pop
      "fake": {}
257 6d81475c Iustin Pop
     },
258 6d81475c Iustin Pop
    "default_hypervisor": "fake",
259 6d81475c Iustin Pop
    "master": "node1.example.com",
260 6d81475c Iustin Pop
    "architecture": [
261 6d81475c Iustin Pop
      "64bit",
262 6d81475c Iustin Pop
      "x86_64"
263 6d81475c Iustin Pop
    ],
264 6d81475c Iustin Pop
    "protocol_version": 20,
265 6d81475c Iustin Pop
    "beparams": {
266 6d81475c Iustin Pop
      "default": {
267 6d81475c Iustin Pop
        "auto_balance": true,
268 6d81475c Iustin Pop
        "vcpus": 1,
269 6d81475c Iustin Pop
        "memory": 128
270 6d81475c Iustin Pop
       }
271 6d81475c Iustin Pop
      }
272 6d81475c Iustin Pop
    }
273 6d81475c Iustin Pop
274 508e9b20 Michael Hanselmann
275 508e9b20 Michael Hanselmann
``/2/redistribute-config``
276 508e9b20 Michael Hanselmann
++++++++++++++++++++++++++
277 508e9b20 Michael Hanselmann
278 508e9b20 Michael Hanselmann
Redistribute configuration to all nodes.
279 508e9b20 Michael Hanselmann
280 508e9b20 Michael Hanselmann
It supports the following commands: ``PUT``.
281 508e9b20 Michael Hanselmann
282 508e9b20 Michael Hanselmann
``PUT``
283 508e9b20 Michael Hanselmann
~~~~~~~
284 508e9b20 Michael Hanselmann
285 508e9b20 Michael Hanselmann
Redistribute configuration to all nodes. The result will be a job id.
286 508e9b20 Michael Hanselmann
287 508e9b20 Michael Hanselmann
288 7eac4a4d Michael Hanselmann
``/2/features``
289 7eac4a4d Michael Hanselmann
+++++++++++++++
290 7eac4a4d Michael Hanselmann
291 7eac4a4d Michael Hanselmann
``GET``
292 7eac4a4d Michael Hanselmann
~~~~~~~
293 7eac4a4d Michael Hanselmann
294 7eac4a4d Michael Hanselmann
Returns a list of features supported by the RAPI server. Available
295 7eac4a4d Michael Hanselmann
features:
296 7eac4a4d Michael Hanselmann
297 7eac4a4d Michael Hanselmann
``instance-create-reqv1``
298 7eac4a4d Michael Hanselmann
  Instance creation request data version 1 supported.
299 7eac4a4d Michael Hanselmann
300 7eac4a4d Michael Hanselmann
301 c8e0a534 Iustin Pop
``/2/instances``
302 c8e0a534 Iustin Pop
++++++++++++++++
303 6d81475c Iustin Pop
304 c8e0a534 Iustin Pop
The instances resource.
305 6d81475c Iustin Pop
306 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``POST``.
307 6d81475c Iustin Pop
308 c8e0a534 Iustin Pop
``GET``
309 c8e0a534 Iustin Pop
~~~~~~~
310 6d81475c Iustin Pop
311 c8e0a534 Iustin Pop
Returns a list of all available instances.
312 6d81475c Iustin Pop
313 c8e0a534 Iustin Pop
Example::
314 6d81475c Iustin Pop
315 6d81475c Iustin Pop
    [
316 6d81475c Iustin Pop
      {
317 6d81475c Iustin Pop
        "name": "web.example.com",
318 6d81475c Iustin Pop
        "uri": "\/instances\/web.example.com"
319 6d81475c Iustin Pop
      },
320 6d81475c Iustin Pop
      {
321 6d81475c Iustin Pop
        "name": "mail.example.com",
322 6d81475c Iustin Pop
        "uri": "\/instances\/mail.example.com"
323 6d81475c Iustin Pop
      }
324 6d81475c Iustin Pop
    ]
325 6d81475c Iustin Pop
326 88394aa7 René Nussbaumer
If the optional bool *bulk* argument is provided and set to a true value
327 88394aa7 René Nussbaumer
(i.e ``?bulk=1``), the output contains detailed information about
328 88394aa7 René Nussbaumer
instances as a list.
329 6d81475c Iustin Pop
330 c8e0a534 Iustin Pop
Example::
331 6d81475c Iustin Pop
332 6d81475c Iustin Pop
    [
333 6d81475c Iustin Pop
      {
334 6d81475c Iustin Pop
         "status": "running",
335 6d81475c Iustin Pop
         "disk_usage": 20480,
336 6d81475c Iustin Pop
         "nic.bridges": [
337 6d81475c Iustin Pop
           "xen-br0"
338 6d81475c Iustin Pop
          ],
339 6d81475c Iustin Pop
         "name": "web.example.com",
340 6d81475c Iustin Pop
         "tags": ["tag1", "tag2"],
341 6d81475c Iustin Pop
         "beparams": {
342 6d81475c Iustin Pop
           "vcpus": 2,
343 6d81475c Iustin Pop
           "memory": 512
344 6d81475c Iustin Pop
         },
345 6d81475c Iustin Pop
         "disk.sizes": [
346 6d81475c Iustin Pop
             20480
347 6d81475c Iustin Pop
         ],
348 6d81475c Iustin Pop
         "pnode": "node1.example.com",
349 6d81475c Iustin Pop
         "nic.macs": ["01:23:45:67:89:01"],
350 6d81475c Iustin Pop
         "snodes": ["node2.example.com"],
351 6d81475c Iustin Pop
         "disk_template": "drbd",
352 6d81475c Iustin Pop
         "admin_state": true,
353 6d81475c Iustin Pop
         "os": "debian-etch",
354 6d81475c Iustin Pop
         "oper_state": true
355 6d81475c Iustin Pop
      },
356 6d81475c Iustin Pop
      ...
357 6d81475c Iustin Pop
    ]
358 6d81475c Iustin Pop
359 6d81475c Iustin Pop
360 c8e0a534 Iustin Pop
``POST``
361 c8e0a534 Iustin Pop
~~~~~~~~
362 6d81475c Iustin Pop
363 c8e0a534 Iustin Pop
Creates an instance.
364 6d81475c Iustin Pop
365 88394aa7 René Nussbaumer
If the optional bool *dry-run* argument is provided, the job will not be
366 88394aa7 René Nussbaumer
actually executed, only the pre-execution checks will be done. Query-ing
367 88394aa7 René Nussbaumer
the job result will return, in both dry-run and normal case, the list of
368 88394aa7 René Nussbaumer
nodes selected for the instance.
369 2cad4b91 Iustin Pop
370 c8e0a534 Iustin Pop
Returns: a job ID that can be used later for polling.
371 6d81475c Iustin Pop
372 6395cebb Michael Hanselmann
Body parameters:
373 6395cebb Michael Hanselmann
374 6395cebb Michael Hanselmann
``__version__`` (int, required)
375 6395cebb Michael Hanselmann
  Must be ``1`` (older Ganeti versions used a different format for
376 6395cebb Michael Hanselmann
  instance creation requests, version ``0``, but that format is not
377 6395cebb Michael Hanselmann
  documented).
378 dd0fa69d Michael Hanselmann
``mode`` (string, required)
379 dd0fa69d Michael Hanselmann
  Instance creation mode.
380 6395cebb Michael Hanselmann
``name`` (string, required)
381 dd0fa69d Michael Hanselmann
  Instance name.
382 6395cebb Michael Hanselmann
``disk_template`` (string, required)
383 dd0fa69d Michael Hanselmann
  Disk template for instance.
384 6395cebb Michael Hanselmann
``disks`` (list, required)
385 6395cebb Michael Hanselmann
  List of disk definitions. Example: ``[{"size": 100}, {"size": 5}]``.
386 6395cebb Michael Hanselmann
  Each disk definition must contain a ``size`` value and can contain an
387 6395cebb Michael Hanselmann
  optional ``mode`` value denoting the disk access mode (``ro`` or
388 6395cebb Michael Hanselmann
  ``rw``).
389 6395cebb Michael Hanselmann
``nics`` (list, required)
390 6395cebb Michael Hanselmann
  List of NIC (network interface) definitions. Example: ``[{}, {},
391 926feaf1 Manuel Franceschini
  {"ip": "198.51.100.4"}]``. Each NIC definition can contain the
392 926feaf1 Manuel Franceschini
  optional values ``ip``, ``mode``, ``link`` and ``bridge``.
393 b430a54d Iustin Pop
``os`` (string, required)
394 6395cebb Michael Hanselmann
  Instance operating system.
395 b430a54d Iustin Pop
``osparams`` (dictionary)
396 b430a54d Iustin Pop
  Dictionary with OS parameters. If not valid for the given OS, the job
397 b430a54d Iustin Pop
  will fail.
398 6395cebb Michael Hanselmann
``force_variant`` (bool)
399 6395cebb Michael Hanselmann
  Whether to force an unknown variant.
400 6395cebb Michael Hanselmann
``pnode`` (string)
401 6395cebb Michael Hanselmann
  Primary node.
402 6395cebb Michael Hanselmann
``snode`` (string)
403 6395cebb Michael Hanselmann
  Secondary node.
404 6395cebb Michael Hanselmann
``src_node`` (string)
405 6395cebb Michael Hanselmann
  Source node for import.
406 6395cebb Michael Hanselmann
``src_path`` (string)
407 6395cebb Michael Hanselmann
  Source directory for import.
408 6395cebb Michael Hanselmann
``start`` (bool)
409 6395cebb Michael Hanselmann
  Whether to start instance after creation.
410 6395cebb Michael Hanselmann
``ip_check`` (bool)
411 6395cebb Michael Hanselmann
  Whether to ensure instance's IP address is inactive.
412 6395cebb Michael Hanselmann
``name_check`` (bool)
413 6395cebb Michael Hanselmann
  Whether to ensure instance's name is resolvable.
414 6395cebb Michael Hanselmann
``file_storage_dir`` (string)
415 6395cebb Michael Hanselmann
  File storage directory.
416 6395cebb Michael Hanselmann
``file_driver`` (string)
417 6395cebb Michael Hanselmann
  File storage driver.
418 6395cebb Michael Hanselmann
``iallocator`` (string)
419 6395cebb Michael Hanselmann
  Instance allocator name.
420 dd0fa69d Michael Hanselmann
``source_handshake`` (list)
421 ebeb600f Michael Hanselmann
  Signed handshake from source (remote import only).
422 ebeb600f Michael Hanselmann
``source_x509_ca`` (string)
423 ebeb600f Michael Hanselmann
  Source X509 CA in PEM format (remote import only).
424 ebeb600f Michael Hanselmann
``source_instance_name`` (string)
425 ebeb600f Michael Hanselmann
  Source instance name (remote import only).
426 6395cebb Michael Hanselmann
``hypervisor`` (string)
427 6395cebb Michael Hanselmann
  Hypervisor name.
428 6395cebb Michael Hanselmann
``hvparams`` (dict)
429 6395cebb Michael Hanselmann
  Hypervisor parameters, hypervisor-dependent.
430 dd0fa69d Michael Hanselmann
``beparams`` (dict)
431 6395cebb Michael Hanselmann
  Backend parameters.
432 6395cebb Michael Hanselmann
433 6395cebb Michael Hanselmann
434 c8e0a534 Iustin Pop
``/2/instances/[instance_name]``
435 c8e0a534 Iustin Pop
++++++++++++++++++++++++++++++++
436 6d81475c Iustin Pop
437 c8e0a534 Iustin Pop
Instance-specific resource.
438 6d81475c Iustin Pop
439 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``DELETE``.
440 6d81475c Iustin Pop
441 c8e0a534 Iustin Pop
``GET``
442 c8e0a534 Iustin Pop
~~~~~~~
443 6d81475c Iustin Pop
444 c8e0a534 Iustin Pop
Returns information about an instance, similar to the bulk output from
445 c8e0a534 Iustin Pop
the instance list.
446 6d81475c Iustin Pop
447 c8e0a534 Iustin Pop
``DELETE``
448 c8e0a534 Iustin Pop
~~~~~~~~~~
449 6d81475c Iustin Pop
450 c8e0a534 Iustin Pop
Deletes an instance.
451 6d81475c Iustin Pop
452 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
453 2cad4b91 Iustin Pop
454 6d81475c Iustin Pop
455 d8260842 Michael Hanselmann
``/2/instances/[instance_name]/info``
456 d8260842 Michael Hanselmann
+++++++++++++++++++++++++++++++++++++++
457 d8260842 Michael Hanselmann
458 d8260842 Michael Hanselmann
It supports the following commands: ``GET``.
459 d8260842 Michael Hanselmann
460 d8260842 Michael Hanselmann
``GET``
461 d8260842 Michael Hanselmann
~~~~~~~
462 d8260842 Michael Hanselmann
463 d8260842 Michael Hanselmann
Requests detailed information about the instance. An optional parameter,
464 d8260842 Michael Hanselmann
``static`` (bool), can be set to return only static information from the
465 7faf5110 Michael Hanselmann
configuration without querying the instance's nodes. The result will be
466 7faf5110 Michael Hanselmann
a job id.
467 d8260842 Michael Hanselmann
468 d8260842 Michael Hanselmann
469 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/reboot``
470 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++++
471 6d81475c Iustin Pop
472 c8e0a534 Iustin Pop
Reboots URI for an instance.
473 6d81475c Iustin Pop
474 c8e0a534 Iustin Pop
It supports the following commands: ``POST``.
475 6d81475c Iustin Pop
476 c8e0a534 Iustin Pop
``POST``
477 c8e0a534 Iustin Pop
~~~~~~~~
478 6d81475c Iustin Pop
479 c8e0a534 Iustin Pop
Reboots the instance.
480 6d81475c Iustin Pop
481 88394aa7 René Nussbaumer
The URI takes optional ``type=soft|hard|full`` and
482 88394aa7 René Nussbaumer
``ignore_secondaries=0|1`` parameters.
483 88394aa7 René Nussbaumer
484 88394aa7 René Nussbaumer
``type`` defines the reboot type. ``soft`` is just a normal reboot,
485 88394aa7 René Nussbaumer
without terminating the hypervisor. ``hard`` means full shutdown
486 88394aa7 René Nussbaumer
(including terminating the hypervisor process) and startup again.
487 88394aa7 René Nussbaumer
``full`` is like ``hard`` but also recreates the configuration from
488 88394aa7 René Nussbaumer
ground up as if you would have done a ``gnt-instance shutdown`` and
489 88394aa7 René Nussbaumer
``gnt-instance start`` on it.
490 88394aa7 René Nussbaumer
491 88394aa7 René Nussbaumer
``ignore_secondaries`` is a bool argument indicating if we start the
492 88394aa7 René Nussbaumer
instance even if secondary disks are failing.
493 6d81475c Iustin Pop
494 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
495 2cad4b91 Iustin Pop
496 2cad4b91 Iustin Pop
497 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/shutdown``
498 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++++++
499 6d81475c Iustin Pop
500 c8e0a534 Iustin Pop
Instance shutdown URI.
501 6d81475c Iustin Pop
502 c8e0a534 Iustin Pop
It supports the following commands: ``PUT``.
503 6d81475c Iustin Pop
504 c8e0a534 Iustin Pop
``PUT``
505 c8e0a534 Iustin Pop
~~~~~~~
506 6d81475c Iustin Pop
507 c8e0a534 Iustin Pop
Shutdowns an instance.
508 6d81475c Iustin Pop
509 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
510 2cad4b91 Iustin Pop
511 6d81475c Iustin Pop
512 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/startup``
513 c8e0a534 Iustin Pop
++++++++++++++++++++++++++++++++++++++++
514 6d81475c Iustin Pop
515 c8e0a534 Iustin Pop
Instance startup URI.
516 6d81475c Iustin Pop
517 c8e0a534 Iustin Pop
It supports the following commands: ``PUT``.
518 6d81475c Iustin Pop
519 c8e0a534 Iustin Pop
``PUT``
520 c8e0a534 Iustin Pop
~~~~~~~
521 6d81475c Iustin Pop
522 c8e0a534 Iustin Pop
Startup an instance.
523 6d81475c Iustin Pop
524 88394aa7 René Nussbaumer
The URI takes an optional ``force=1|0`` parameter to start the
525 88394aa7 René Nussbaumer
instance even if secondary disks are failing.
526 6d81475c Iustin Pop
527 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
528 2cad4b91 Iustin Pop
529 f72542cc Michael Hanselmann
``/2/instances/[instance_name]/reinstall``
530 f72542cc Michael Hanselmann
++++++++++++++++++++++++++++++++++++++++++++++
531 f72542cc Michael Hanselmann
532 f72542cc Michael Hanselmann
Installs the operating system again.
533 f72542cc Michael Hanselmann
534 f72542cc Michael Hanselmann
It supports the following commands: ``POST``.
535 f72542cc Michael Hanselmann
536 f72542cc Michael Hanselmann
``POST``
537 f72542cc Michael Hanselmann
~~~~~~~~
538 f72542cc Michael Hanselmann
539 f72542cc Michael Hanselmann
Takes the parameters ``os`` (OS template name) and ``nostartup`` (bool).
540 f72542cc Michael Hanselmann
541 2cad4b91 Iustin Pop
542 4c98b915 Michael Hanselmann
``/2/instances/[instance_name]/replace-disks``
543 4c98b915 Michael Hanselmann
++++++++++++++++++++++++++++++++++++++++++++++
544 4c98b915 Michael Hanselmann
545 4c98b915 Michael Hanselmann
Replaces disks on an instance.
546 4c98b915 Michael Hanselmann
547 4c98b915 Michael Hanselmann
It supports the following commands: ``POST``.
548 4c98b915 Michael Hanselmann
549 4c98b915 Michael Hanselmann
``POST``
550 4c98b915 Michael Hanselmann
~~~~~~~~
551 4c98b915 Michael Hanselmann
552 4c98b915 Michael Hanselmann
Takes the parameters ``mode`` (one of ``replace_on_primary``,
553 7faf5110 Michael Hanselmann
``replace_on_secondary``, ``replace_new_secondary`` or
554 7faf5110 Michael Hanselmann
``replace_auto``), ``disks`` (comma separated list of disk indexes),
555 7faf5110 Michael Hanselmann
``remote_node`` and ``iallocator``.
556 4c98b915 Michael Hanselmann
557 88394aa7 René Nussbaumer
Either ``remote_node`` or ``iallocator`` needs to be defined when using
558 88394aa7 René Nussbaumer
``mode=replace_new_secondary``.
559 88394aa7 René Nussbaumer
560 88394aa7 René Nussbaumer
``mode`` is a mandatory parameter. ``replace_auto`` tries to determine
561 88394aa7 René Nussbaumer
the broken disk(s) on its own and replacing it.
562 88394aa7 René Nussbaumer
563 4c98b915 Michael Hanselmann
564 2263aec2 René Nussbaumer
``/2/instances/[instance_name]/activate-disks``
565 2263aec2 René Nussbaumer
+++++++++++++++++++++++++++++++++++++++++++++++
566 2263aec2 René Nussbaumer
567 2263aec2 René Nussbaumer
Activate disks on an instance.
568 2263aec2 René Nussbaumer
569 2263aec2 René Nussbaumer
It supports the following commands: ``PUT``.
570 2263aec2 René Nussbaumer
571 2263aec2 René Nussbaumer
``PUT``
572 2263aec2 René Nussbaumer
~~~~~~~
573 2263aec2 René Nussbaumer
574 88394aa7 René Nussbaumer
Takes the bool parameter ``ignore_size``. When set ignore the recorded
575 2263aec2 René Nussbaumer
size (useful for forcing activation when recorded size is wrong).
576 2263aec2 René Nussbaumer
577 2263aec2 René Nussbaumer
578 2263aec2 René Nussbaumer
``/2/instances/[instance_name]/deactivate-disks``
579 2263aec2 René Nussbaumer
+++++++++++++++++++++++++++++++++++++++++++++++++
580 2263aec2 René Nussbaumer
581 2263aec2 René Nussbaumer
Deactivate disks on an instance.
582 2263aec2 René Nussbaumer
583 2263aec2 René Nussbaumer
It supports the following commands: ``PUT``.
584 2263aec2 René Nussbaumer
585 2263aec2 René Nussbaumer
``PUT``
586 2263aec2 René Nussbaumer
~~~~~~~
587 2263aec2 René Nussbaumer
588 2263aec2 René Nussbaumer
Takes no parameters.
589 2263aec2 René Nussbaumer
590 2263aec2 René Nussbaumer
591 ebeb600f Michael Hanselmann
``/2/instances/[instance_name]/prepare-export``
592 ebeb600f Michael Hanselmann
+++++++++++++++++++++++++++++++++++++++++++++++++
593 ebeb600f Michael Hanselmann
594 ebeb600f Michael Hanselmann
Prepares an export of an instance.
595 ebeb600f Michael Hanselmann
596 ebeb600f Michael Hanselmann
It supports the following commands: ``PUT``.
597 ebeb600f Michael Hanselmann
598 ebeb600f Michael Hanselmann
``PUT``
599 ebeb600f Michael Hanselmann
~~~~~~~
600 ebeb600f Michael Hanselmann
601 ebeb600f Michael Hanselmann
Takes one parameter, ``mode``, for the export mode. Returns a job ID.
602 ebeb600f Michael Hanselmann
603 ebeb600f Michael Hanselmann
604 ebeb600f Michael Hanselmann
``/2/instances/[instance_name]/export``
605 ebeb600f Michael Hanselmann
+++++++++++++++++++++++++++++++++++++++++++++++++
606 ebeb600f Michael Hanselmann
607 ebeb600f Michael Hanselmann
Exports an instance.
608 ebeb600f Michael Hanselmann
609 ebeb600f Michael Hanselmann
It supports the following commands: ``PUT``.
610 ebeb600f Michael Hanselmann
611 ebeb600f Michael Hanselmann
``PUT``
612 ebeb600f Michael Hanselmann
~~~~~~~
613 ebeb600f Michael Hanselmann
614 ebeb600f Michael Hanselmann
Returns a job ID.
615 ebeb600f Michael Hanselmann
616 ebeb600f Michael Hanselmann
Body parameters:
617 ebeb600f Michael Hanselmann
618 ebeb600f Michael Hanselmann
``mode`` (string)
619 ebeb600f Michael Hanselmann
  Export mode.
620 ebeb600f Michael Hanselmann
``destination`` (required)
621 ebeb600f Michael Hanselmann
  Destination information, depends on export mode.
622 ebeb600f Michael Hanselmann
``shutdown`` (bool, required)
623 ebeb600f Michael Hanselmann
  Whether to shutdown instance before export.
624 ebeb600f Michael Hanselmann
``remove_instance`` (bool)
625 ebeb600f Michael Hanselmann
  Whether to remove instance after export.
626 ebeb600f Michael Hanselmann
``x509_key_name``
627 ebeb600f Michael Hanselmann
  Name of X509 key (remote export only).
628 ebeb600f Michael Hanselmann
``destination_x509_ca``
629 ebeb600f Michael Hanselmann
  Destination X509 CA (remote export only).
630 ebeb600f Michael Hanselmann
631 ebeb600f Michael Hanselmann
632 5823e0d2 Michael Hanselmann
``/2/instances/[instance_name]/migrate``
633 5823e0d2 Michael Hanselmann
++++++++++++++++++++++++++++++++++++++++
634 5823e0d2 Michael Hanselmann
635 5823e0d2 Michael Hanselmann
Migrates an instance.
636 5823e0d2 Michael Hanselmann
637 5823e0d2 Michael Hanselmann
Supports the following commands: ``PUT``.
638 5823e0d2 Michael Hanselmann
639 5823e0d2 Michael Hanselmann
``PUT``
640 5823e0d2 Michael Hanselmann
~~~~~~~
641 5823e0d2 Michael Hanselmann
642 5823e0d2 Michael Hanselmann
Returns a job ID.
643 5823e0d2 Michael Hanselmann
644 5823e0d2 Michael Hanselmann
Body parameters:
645 5823e0d2 Michael Hanselmann
646 5823e0d2 Michael Hanselmann
``mode`` (string)
647 5823e0d2 Michael Hanselmann
  Migration mode.
648 5823e0d2 Michael Hanselmann
``cleanup`` (bool)
649 5823e0d2 Michael Hanselmann
  Whether a previously failed migration should be cleaned up.
650 5823e0d2 Michael Hanselmann
651 5823e0d2 Michael Hanselmann
652 d56e7dc7 Michael Hanselmann
``/2/instances/[instance_name]/rename``
653 d56e7dc7 Michael Hanselmann
++++++++++++++++++++++++++++++++++++++++
654 d56e7dc7 Michael Hanselmann
655 d56e7dc7 Michael Hanselmann
Renames an instance.
656 d56e7dc7 Michael Hanselmann
657 d56e7dc7 Michael Hanselmann
Supports the following commands: ``PUT``.
658 d56e7dc7 Michael Hanselmann
659 d56e7dc7 Michael Hanselmann
``PUT``
660 d56e7dc7 Michael Hanselmann
~~~~~~~
661 d56e7dc7 Michael Hanselmann
662 d56e7dc7 Michael Hanselmann
Returns a job ID.
663 d56e7dc7 Michael Hanselmann
664 d56e7dc7 Michael Hanselmann
Body parameters:
665 d56e7dc7 Michael Hanselmann
666 d56e7dc7 Michael Hanselmann
``new_name`` (string, required)
667 d56e7dc7 Michael Hanselmann
  New instance name.
668 d56e7dc7 Michael Hanselmann
``ip_check`` (bool)
669 d56e7dc7 Michael Hanselmann
  Whether to ensure instance's IP address is inactive.
670 d56e7dc7 Michael Hanselmann
``name_check`` (bool)
671 d56e7dc7 Michael Hanselmann
  Whether to ensure instance's name is resolvable.
672 d56e7dc7 Michael Hanselmann
673 d56e7dc7 Michael Hanselmann
674 3882937a Michael Hanselmann
``/2/instances/[instance_name]/modify``
675 3882937a Michael Hanselmann
++++++++++++++++++++++++++++++++++++++++
676 3882937a Michael Hanselmann
677 3882937a Michael Hanselmann
Modifies an instance.
678 3882937a Michael Hanselmann
679 3882937a Michael Hanselmann
Supports the following commands: ``PUT``.
680 3882937a Michael Hanselmann
681 3882937a Michael Hanselmann
``PUT``
682 3882937a Michael Hanselmann
~~~~~~~
683 3882937a Michael Hanselmann
684 3882937a Michael Hanselmann
Returns a job ID.
685 3882937a Michael Hanselmann
686 3882937a Michael Hanselmann
Body parameters:
687 3882937a Michael Hanselmann
688 3882937a Michael Hanselmann
``osparams`` (dict)
689 3882937a Michael Hanselmann
  Dictionary with OS parameters.
690 3882937a Michael Hanselmann
``hvparams`` (dict)
691 3882937a Michael Hanselmann
  Hypervisor parameters, hypervisor-dependent.
692 3882937a Michael Hanselmann
``beparams`` (dict)
693 3882937a Michael Hanselmann
  Backend parameters.
694 3882937a Michael Hanselmann
``force`` (bool)
695 3882937a Michael Hanselmann
  Whether to force the operation.
696 3882937a Michael Hanselmann
``nics`` (list)
697 3882937a Michael Hanselmann
  List of NIC changes. Each item is of the form ``(op, settings)``.
698 3882937a Michael Hanselmann
  ``op`` can be ``add`` to add a new NIC with the specified settings,
699 3882937a Michael Hanselmann
  ``remove`` to remove the last NIC or a number to modify the settings
700 3882937a Michael Hanselmann
  of the NIC with that index.
701 3882937a Michael Hanselmann
``disks`` (list)
702 3882937a Michael Hanselmann
  List of disk changes. See ``nics``.
703 3882937a Michael Hanselmann
``disk_template`` (string)
704 3882937a Michael Hanselmann
  Disk template for instance.
705 3882937a Michael Hanselmann
``remote_node`` (string)
706 3882937a Michael Hanselmann
  Secondary node (used when changing disk template).
707 3882937a Michael Hanselmann
``os_name`` (string)
708 3882937a Michael Hanselmann
  Change instance's OS name. Does not reinstall the instance.
709 3882937a Michael Hanselmann
``force_variant`` (bool)
710 3882937a Michael Hanselmann
  Whether to force an unknown variant.
711 3882937a Michael Hanselmann
712 3882937a Michael Hanselmann
713 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/tags``
714 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++
715 6d81475c Iustin Pop
716 c8e0a534 Iustin Pop
Manages per-instance tags.
717 6d81475c Iustin Pop
718 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
719 6d81475c Iustin Pop
720 c8e0a534 Iustin Pop
``GET``
721 c8e0a534 Iustin Pop
~~~~~~~
722 6d81475c Iustin Pop
723 c8e0a534 Iustin Pop
Returns a list of tags.
724 6d81475c Iustin Pop
725 c8e0a534 Iustin Pop
Example::
726 6d81475c Iustin Pop
727 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
728 6d81475c Iustin Pop
729 c8e0a534 Iustin Pop
``PUT``
730 c8e0a534 Iustin Pop
~~~~~~~
731 6d81475c Iustin Pop
732 c8e0a534 Iustin Pop
Add a set of tags.
733 6d81475c Iustin Pop
734 c8e0a534 Iustin Pop
The request as a list of strings should be ``PUT`` to this URI. The
735 508e9b20 Michael Hanselmann
result will be a job id.
736 6d81475c Iustin Pop
737 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
738 2cad4b91 Iustin Pop
739 2cad4b91 Iustin Pop
740 c8e0a534 Iustin Pop
``DELETE``
741 c8e0a534 Iustin Pop
~~~~~~~~~~
742 6d81475c Iustin Pop
743 c8e0a534 Iustin Pop
Delete a tag.
744 6d81475c Iustin Pop
745 c71a1a3d Iustin Pop
In order to delete a set of tags, the DELETE request should be addressed
746 c71a1a3d Iustin Pop
to URI like::
747 6d81475c Iustin Pop
748 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
749 6d81475c Iustin Pop
750 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
751 2cad4b91 Iustin Pop
752 2cad4b91 Iustin Pop
753 c8e0a534 Iustin Pop
``/2/jobs``
754 c8e0a534 Iustin Pop
+++++++++++
755 6d81475c Iustin Pop
756 c8e0a534 Iustin Pop
The ``/2/jobs`` resource.
757 6d81475c Iustin Pop
758 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
759 6d81475c Iustin Pop
760 c8e0a534 Iustin Pop
``GET``
761 c8e0a534 Iustin Pop
~~~~~~~
762 6d81475c Iustin Pop
763 c8e0a534 Iustin Pop
Returns a dictionary of jobs.
764 6d81475c Iustin Pop
765 c8e0a534 Iustin Pop
Returns: a dictionary with jobs id and uri.
766 6d81475c Iustin Pop
767 c8e0a534 Iustin Pop
``/2/jobs/[job_id]``
768 c8e0a534 Iustin Pop
++++++++++++++++++++
769 6d81475c Iustin Pop
770 6d81475c Iustin Pop
771 c8e0a534 Iustin Pop
Individual job URI.
772 6d81475c Iustin Pop
773 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``DELETE``.
774 6d81475c Iustin Pop
775 c8e0a534 Iustin Pop
``GET``
776 c8e0a534 Iustin Pop
~~~~~~~
777 6d81475c Iustin Pop
778 c8e0a534 Iustin Pop
Returns a job status.
779 6d81475c Iustin Pop
780 c8e0a534 Iustin Pop
Returns: a dictionary with job parameters.
781 6d81475c Iustin Pop
782 c8e0a534 Iustin Pop
The result includes:
783 6d81475c Iustin Pop
784 c8e0a534 Iustin Pop
- id: job ID as a number
785 c8e0a534 Iustin Pop
- status: current job status as a string
786 c71a1a3d Iustin Pop
- ops: involved OpCodes as a list of dictionaries for each opcodes in
787 c71a1a3d Iustin Pop
  the job
788 c8e0a534 Iustin Pop
- opstatus: OpCodes status as a list
789 e91cfc2a Iustin Pop
- opresult: OpCodes results as a list
790 e91cfc2a Iustin Pop
791 e91cfc2a Iustin Pop
For a successful opcode, the ``opresult`` field corresponding to it will
792 e91cfc2a Iustin Pop
contain the raw result from its :term:`LogicalUnit`. In case an opcode
793 e91cfc2a Iustin Pop
has failed, its element in the opresult list will be a list of two
794 e91cfc2a Iustin Pop
elements:
795 e91cfc2a Iustin Pop
796 e91cfc2a Iustin Pop
- first element the error type (the Ganeti internal error name)
797 e91cfc2a Iustin Pop
- second element a list of either one or two elements:
798 e91cfc2a Iustin Pop
799 e91cfc2a Iustin Pop
  - the first element is the textual error description
800 e91cfc2a Iustin Pop
  - the second element, if any, will hold an error classification
801 e91cfc2a Iustin Pop
802 e91cfc2a Iustin Pop
The error classification is most useful for the ``OpPrereqError``
803 e91cfc2a Iustin Pop
error type - these errors happen before the OpCode has started
804 e91cfc2a Iustin Pop
executing, so it's possible to retry the OpCode without side
805 e91cfc2a Iustin Pop
effects. But whether it make sense to retry depends on the error
806 e91cfc2a Iustin Pop
classification:
807 e91cfc2a Iustin Pop
808 e91cfc2a Iustin Pop
``resolver_error``
809 e91cfc2a Iustin Pop
  Resolver errors. This usually means that a name doesn't exist in DNS,
810 e91cfc2a Iustin Pop
  so if it's a case of slow DNS propagation the operation can be retried
811 e91cfc2a Iustin Pop
  later.
812 e91cfc2a Iustin Pop
813 e91cfc2a Iustin Pop
``insufficient_resources``
814 e91cfc2a Iustin Pop
  Not enough resources (iallocator failure, disk space, memory,
815 e91cfc2a Iustin Pop
  etc.). If the resources on the cluster increase, the operation might
816 e91cfc2a Iustin Pop
  succeed.
817 e91cfc2a Iustin Pop
818 e91cfc2a Iustin Pop
``wrong_input``
819 e91cfc2a Iustin Pop
  Wrong arguments (at syntax level). The operation will not ever be
820 e91cfc2a Iustin Pop
  accepted unless the arguments change.
821 e91cfc2a Iustin Pop
822 e91cfc2a Iustin Pop
``wrong_state``
823 e91cfc2a Iustin Pop
  Wrong entity state. For example, live migration has been requested for
824 e91cfc2a Iustin Pop
  a down instance, or instance creation on an offline node. The
825 e91cfc2a Iustin Pop
  operation can be retried once the resource has changed state.
826 e91cfc2a Iustin Pop
827 e91cfc2a Iustin Pop
``unknown_entity``
828 e91cfc2a Iustin Pop
  Entity not found. For example, information has been requested for an
829 e91cfc2a Iustin Pop
  unknown instance.
830 e91cfc2a Iustin Pop
831 e91cfc2a Iustin Pop
``already_exists``
832 e91cfc2a Iustin Pop
  Entity already exists. For example, instance creation has been
833 e91cfc2a Iustin Pop
  requested for an already-existing instance.
834 e91cfc2a Iustin Pop
835 e91cfc2a Iustin Pop
``resource_not_unique``
836 e91cfc2a Iustin Pop
  Resource not unique (e.g. MAC or IP duplication).
837 e91cfc2a Iustin Pop
838 e91cfc2a Iustin Pop
``internal_error``
839 e91cfc2a Iustin Pop
  Internal cluster error. For example, a node is unreachable but not set
840 e91cfc2a Iustin Pop
  offline, or the ganeti node daemons are not working, etc. A
841 e91cfc2a Iustin Pop
  ``gnt-cluster verify`` should be run.
842 e91cfc2a Iustin Pop
843 e91cfc2a Iustin Pop
``environment_error``
844 e91cfc2a Iustin Pop
  Environment error (e.g. node disk error). A ``gnt-cluster verify``
845 e91cfc2a Iustin Pop
  should be run.
846 e91cfc2a Iustin Pop
847 e91cfc2a Iustin Pop
Note that in the above list, by entity we refer to a node or instance,
848 e91cfc2a Iustin Pop
while by a resource we refer to an instance's disk, or NIC, etc.
849 e91cfc2a Iustin Pop
850 6d81475c Iustin Pop
851 c8e0a534 Iustin Pop
``DELETE``
852 c8e0a534 Iustin Pop
~~~~~~~~~~
853 6d81475c Iustin Pop
854 c8e0a534 Iustin Pop
Cancel a not-yet-started job.
855 6d81475c Iustin Pop
856 793a8f7c Michael Hanselmann
857 793a8f7c Michael Hanselmann
``/2/jobs/[job_id]/wait``
858 793a8f7c Michael Hanselmann
+++++++++++++++++++++++++
859 793a8f7c Michael Hanselmann
860 793a8f7c Michael Hanselmann
``GET``
861 793a8f7c Michael Hanselmann
~~~~~~~
862 793a8f7c Michael Hanselmann
863 793a8f7c Michael Hanselmann
Waits for changes on a job. Takes the following body parameters in a
864 793a8f7c Michael Hanselmann
dict:
865 793a8f7c Michael Hanselmann
866 793a8f7c Michael Hanselmann
``fields``
867 793a8f7c Michael Hanselmann
  The job fields on which to watch for changes.
868 793a8f7c Michael Hanselmann
869 793a8f7c Michael Hanselmann
``previous_job_info``
870 793a8f7c Michael Hanselmann
  Previously received field values or None if not yet available.
871 793a8f7c Michael Hanselmann
872 793a8f7c Michael Hanselmann
``previous_log_serial``
873 793a8f7c Michael Hanselmann
  Highest log serial number received so far or None if not yet
874 793a8f7c Michael Hanselmann
  available.
875 793a8f7c Michael Hanselmann
876 793a8f7c Michael Hanselmann
Returns None if no changes have been detected and a dict with two keys,
877 793a8f7c Michael Hanselmann
``job_info`` and ``log_entries`` otherwise.
878 793a8f7c Michael Hanselmann
879 793a8f7c Michael Hanselmann
880 c8e0a534 Iustin Pop
``/2/nodes``
881 c8e0a534 Iustin Pop
++++++++++++
882 6d81475c Iustin Pop
883 c8e0a534 Iustin Pop
Nodes resource.
884 6d81475c Iustin Pop
885 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
886 6d81475c Iustin Pop
887 c8e0a534 Iustin Pop
``GET``
888 c8e0a534 Iustin Pop
~~~~~~~
889 6d81475c Iustin Pop
890 c8e0a534 Iustin Pop
Returns a list of all nodes.
891 6d81475c Iustin Pop
892 c8e0a534 Iustin Pop
Example::
893 6d81475c Iustin Pop
894 6d81475c Iustin Pop
    [
895 6d81475c Iustin Pop
      {
896 6d81475c Iustin Pop
        "id": "node1.example.com",
897 20b1bd80 Iustin Pop
        "uri": "\/nodes\/node1.example.com"
898 6d81475c Iustin Pop
      },
899 6d81475c Iustin Pop
      {
900 6d81475c Iustin Pop
        "id": "node2.example.com",
901 20b1bd80 Iustin Pop
        "uri": "\/nodes\/node2.example.com"
902 6d81475c Iustin Pop
      }
903 6d81475c Iustin Pop
    ]
904 6d81475c Iustin Pop
905 c71a1a3d Iustin Pop
If the optional 'bulk' argument is provided and set to 'true' value (i.e
906 c71a1a3d Iustin Pop
'?bulk=1'), the output contains detailed information about nodes as a
907 c71a1a3d Iustin Pop
list.
908 6d81475c Iustin Pop
909 c8e0a534 Iustin Pop
Example::
910 6d81475c Iustin Pop
911 6d81475c Iustin Pop
    [
912 6d81475c Iustin Pop
      {
913 6d81475c Iustin Pop
        "pinst_cnt": 1,
914 6d81475c Iustin Pop
        "mfree": 31280,
915 6d81475c Iustin Pop
        "mtotal": 32763,
916 6d81475c Iustin Pop
        "name": "www.example.com",
917 6d81475c Iustin Pop
        "tags": [],
918 6d81475c Iustin Pop
        "mnode": 512,
919 6d81475c Iustin Pop
        "dtotal": 5246208,
920 6d81475c Iustin Pop
        "sinst_cnt": 2,
921 6d81475c Iustin Pop
        "dfree": 5171712,
922 6d81475c Iustin Pop
        "offline": false
923 6d81475c Iustin Pop
      },
924 6d81475c Iustin Pop
      ...
925 6d81475c Iustin Pop
    ]
926 6d81475c Iustin Pop
927 f72542cc Michael Hanselmann
``/2/nodes/[node_name]``
928 f72542cc Michael Hanselmann
+++++++++++++++++++++++++++++++++
929 f72542cc Michael Hanselmann
930 f72542cc Michael Hanselmann
Returns information about a node.
931 f72542cc Michael Hanselmann
932 f72542cc Michael Hanselmann
It supports the following commands: ``GET``.
933 f72542cc Michael Hanselmann
934 73452f12 Michael Hanselmann
``/2/nodes/[node_name]/evacuate``
935 73452f12 Michael Hanselmann
+++++++++++++++++++++++++++++++++
936 73452f12 Michael Hanselmann
937 73452f12 Michael Hanselmann
Evacuates all secondary instances off a node.
938 73452f12 Michael Hanselmann
939 73452f12 Michael Hanselmann
It supports the following commands: ``POST``.
940 73452f12 Michael Hanselmann
941 73452f12 Michael Hanselmann
``POST``
942 73452f12 Michael Hanselmann
~~~~~~~~
943 73452f12 Michael Hanselmann
944 73452f12 Michael Hanselmann
To evacuate a node, either one of the ``iallocator`` or ``remote_node``
945 88394aa7 René Nussbaumer
parameters must be passed::
946 73452f12 Michael Hanselmann
947 73452f12 Michael Hanselmann
    evacuate?iallocator=[iallocator]
948 73452f12 Michael Hanselmann
    evacuate?remote_node=[nodeX.example.com]
949 73452f12 Michael Hanselmann
950 941b9309 Iustin Pop
The result value will be a list, each element being a triple of the job
951 941b9309 Iustin Pop
id (for this specific evacuation), the instance which is being evacuated
952 941b9309 Iustin Pop
by this job, and the node to which it is being relocated. In case the
953 941b9309 Iustin Pop
node is already empty, the result will be an empty list (without any
954 941b9309 Iustin Pop
jobs being submitted).
955 941b9309 Iustin Pop
956 941b9309 Iustin Pop
And additional parameter ``early_release`` signifies whether to try to
957 941b9309 Iustin Pop
parallelize the evacuations, at the risk of increasing I/O contention
958 941b9309 Iustin Pop
and increasing the chances of data loss, if the primary node of any of
959 941b9309 Iustin Pop
the instances being evacuated is not fully healthy.
960 941b9309 Iustin Pop
961 941b9309 Iustin Pop
If the dry-run parameter was specified, then the evacuation jobs were
962 941b9309 Iustin Pop
not actually submitted, and the job IDs will be null.
963 941b9309 Iustin Pop
964 941b9309 Iustin Pop
965 1c482bab Michael Hanselmann
``/2/nodes/[node_name]/migrate``
966 1c482bab Michael Hanselmann
+++++++++++++++++++++++++++++++++
967 1c482bab Michael Hanselmann
968 1c482bab Michael Hanselmann
Migrates all primary instances from a node.
969 1c482bab Michael Hanselmann
970 1c482bab Michael Hanselmann
It supports the following commands: ``POST``.
971 1c482bab Michael Hanselmann
972 1c482bab Michael Hanselmann
``POST``
973 1c482bab Michael Hanselmann
~~~~~~~~
974 1c482bab Michael Hanselmann
975 88394aa7 René Nussbaumer
No parameters are required, but the bool parameter ``live`` can be set
976 88394aa7 René Nussbaumer
to use live migration (if available).
977 1c482bab Michael Hanselmann
978 1c482bab Michael Hanselmann
    migrate?live=[0|1]
979 1c482bab Michael Hanselmann
980 64dae8fc Michael Hanselmann
``/2/nodes/[node_name]/role``
981 64dae8fc Michael Hanselmann
+++++++++++++++++++++++++++++
982 64dae8fc Michael Hanselmann
983 64dae8fc Michael Hanselmann
Manages node role.
984 64dae8fc Michael Hanselmann
985 64dae8fc Michael Hanselmann
It supports the following commands: ``GET``, ``PUT``.
986 64dae8fc Michael Hanselmann
987 64dae8fc Michael Hanselmann
The role is always one of the following:
988 64dae8fc Michael Hanselmann
989 64dae8fc Michael Hanselmann
  - drained
990 64dae8fc Michael Hanselmann
  - master
991 64dae8fc Michael Hanselmann
  - master-candidate
992 64dae8fc Michael Hanselmann
  - offline
993 64dae8fc Michael Hanselmann
  - regular
994 64dae8fc Michael Hanselmann
995 64dae8fc Michael Hanselmann
``GET``
996 64dae8fc Michael Hanselmann
~~~~~~~
997 64dae8fc Michael Hanselmann
998 64dae8fc Michael Hanselmann
Returns the current node role.
999 64dae8fc Michael Hanselmann
1000 64dae8fc Michael Hanselmann
Example::
1001 64dae8fc Michael Hanselmann
1002 64dae8fc Michael Hanselmann
    "master-candidate"
1003 64dae8fc Michael Hanselmann
1004 64dae8fc Michael Hanselmann
``PUT``
1005 64dae8fc Michael Hanselmann
~~~~~~~
1006 64dae8fc Michael Hanselmann
1007 64dae8fc Michael Hanselmann
Change the node role.
1008 64dae8fc Michael Hanselmann
1009 7faf5110 Michael Hanselmann
The request is a string which should be PUT to this URI. The result will
1010 7faf5110 Michael Hanselmann
be a job id.
1011 64dae8fc Michael Hanselmann
1012 88394aa7 René Nussbaumer
It supports the bool ``force`` argument.
1013 64dae8fc Michael Hanselmann
1014 7a95a954 Michael Hanselmann
``/2/nodes/[node_name]/storage``
1015 7a95a954 Michael Hanselmann
++++++++++++++++++++++++++++++++
1016 7a95a954 Michael Hanselmann
1017 7a95a954 Michael Hanselmann
Manages storage units on the node.
1018 7a95a954 Michael Hanselmann
1019 7a95a954 Michael Hanselmann
``GET``
1020 7a95a954 Michael Hanselmann
~~~~~~~
1021 7a95a954 Michael Hanselmann
1022 7a95a954 Michael Hanselmann
Requests a list of storage units on a node. Requires the parameters
1023 7a95a954 Michael Hanselmann
``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and
1024 7faf5110 Michael Hanselmann
``output_fields``. The result will be a job id, using which the result
1025 7faf5110 Michael Hanselmann
can be retrieved.
1026 7a95a954 Michael Hanselmann
1027 1e82bc80 Michael Hanselmann
``/2/nodes/[node_name]/storage/modify``
1028 1e82bc80 Michael Hanselmann
+++++++++++++++++++++++++++++++++++++++
1029 1e82bc80 Michael Hanselmann
1030 1e82bc80 Michael Hanselmann
Modifies storage units on the node.
1031 1e82bc80 Michael Hanselmann
1032 1e82bc80 Michael Hanselmann
``PUT``
1033 1e82bc80 Michael Hanselmann
~~~~~~~
1034 1e82bc80 Michael Hanselmann
1035 7faf5110 Michael Hanselmann
Modifies parameters of storage units on the node. Requires the
1036 7faf5110 Michael Hanselmann
parameters ``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``)
1037 7faf5110 Michael Hanselmann
and ``name`` (name of the storage unit).  Parameters can be passed
1038 7faf5110 Michael Hanselmann
additionally. Currently only ``allocatable`` (bool) is supported. The
1039 7faf5110 Michael Hanselmann
result will be a job id.
1040 1e82bc80 Michael Hanselmann
1041 723f4565 Michael Hanselmann
``/2/nodes/[node_name]/storage/repair``
1042 723f4565 Michael Hanselmann
+++++++++++++++++++++++++++++++++++++++
1043 723f4565 Michael Hanselmann
1044 723f4565 Michael Hanselmann
Repairs a storage unit on the node.
1045 723f4565 Michael Hanselmann
1046 723f4565 Michael Hanselmann
``PUT``
1047 723f4565 Michael Hanselmann
~~~~~~~
1048 723f4565 Michael Hanselmann
1049 7faf5110 Michael Hanselmann
Repairs a storage unit on the node. Requires the parameters
1050 7faf5110 Michael Hanselmann
``storage_type`` (currently only ``lvm-vg`` can be repaired) and
1051 7faf5110 Michael Hanselmann
``name`` (name of the storage unit). The result will be a job id.
1052 723f4565 Michael Hanselmann
1053 c8e0a534 Iustin Pop
``/2/nodes/[node_name]/tags``
1054 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++
1055 6d81475c Iustin Pop
1056 c8e0a534 Iustin Pop
Manages per-node tags.
1057 6d81475c Iustin Pop
1058 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1059 6d81475c Iustin Pop
1060 c8e0a534 Iustin Pop
``GET``
1061 c8e0a534 Iustin Pop
~~~~~~~
1062 6d81475c Iustin Pop
1063 c8e0a534 Iustin Pop
Returns a list of tags.
1064 6d81475c Iustin Pop
1065 c8e0a534 Iustin Pop
Example::
1066 6d81475c Iustin Pop
1067 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
1068 6d81475c Iustin Pop
1069 c8e0a534 Iustin Pop
``PUT``
1070 c8e0a534 Iustin Pop
~~~~~~~
1071 6d81475c Iustin Pop
1072 c8e0a534 Iustin Pop
Add a set of tags.
1073 6d81475c Iustin Pop
1074 c8e0a534 Iustin Pop
The request as a list of strings should be PUT to this URI. The result
1075 c8e0a534 Iustin Pop
will be a job id.
1076 6d81475c Iustin Pop
1077 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
1078 2cad4b91 Iustin Pop
1079 c8e0a534 Iustin Pop
``DELETE``
1080 c8e0a534 Iustin Pop
~~~~~~~~~~
1081 6d81475c Iustin Pop
1082 c8e0a534 Iustin Pop
Deletes tags.
1083 6d81475c Iustin Pop
1084 c71a1a3d Iustin Pop
In order to delete a set of tags, the DELETE request should be addressed
1085 c71a1a3d Iustin Pop
to URI like::
1086 6d81475c Iustin Pop
1087 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
1088 6d81475c Iustin Pop
1089 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
1090 2cad4b91 Iustin Pop
1091 2cad4b91 Iustin Pop
1092 c8e0a534 Iustin Pop
``/2/os``
1093 c8e0a534 Iustin Pop
+++++++++
1094 6d81475c Iustin Pop
1095 c8e0a534 Iustin Pop
OS resource.
1096 6d81475c Iustin Pop
1097 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
1098 6d81475c Iustin Pop
1099 c8e0a534 Iustin Pop
``GET``
1100 c8e0a534 Iustin Pop
~~~~~~~
1101 6d81475c Iustin Pop
1102 c8e0a534 Iustin Pop
Return a list of all OSes.
1103 6d81475c Iustin Pop
1104 c8e0a534 Iustin Pop
Can return error 500 in case of a problem. Since this is a costly
1105 c71a1a3d Iustin Pop
operation for Ganeti 2.0, it is not recommended to execute it too often.
1106 6d81475c Iustin Pop
1107 c8e0a534 Iustin Pop
Example::
1108 6d81475c Iustin Pop
1109 c8e0a534 Iustin Pop
    ["debian-etch"]
1110 6d81475c Iustin Pop
1111 c8e0a534 Iustin Pop
``/2/tags``
1112 c8e0a534 Iustin Pop
+++++++++++
1113 6d81475c Iustin Pop
1114 c8e0a534 Iustin Pop
Manages cluster tags.
1115 6d81475c Iustin Pop
1116 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1117 6d81475c Iustin Pop
1118 c8e0a534 Iustin Pop
``GET``
1119 c8e0a534 Iustin Pop
~~~~~~~
1120 6d81475c Iustin Pop
1121 c8e0a534 Iustin Pop
Returns the cluster tags.
1122 6d81475c Iustin Pop
1123 c8e0a534 Iustin Pop
Example::
1124 6d81475c Iustin Pop
1125 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
1126 6d81475c Iustin Pop
1127 c8e0a534 Iustin Pop
``PUT``
1128 c8e0a534 Iustin Pop
~~~~~~~
1129 6d81475c Iustin Pop
1130 c8e0a534 Iustin Pop
Adds a set of tags.
1131 6d81475c Iustin Pop
1132 c8e0a534 Iustin Pop
The request as a list of strings should be PUT to this URI. The result
1133 c8e0a534 Iustin Pop
will be a job id.
1134 6d81475c Iustin Pop
1135 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
1136 2cad4b91 Iustin Pop
1137 2cad4b91 Iustin Pop
1138 c8e0a534 Iustin Pop
``DELETE``
1139 c8e0a534 Iustin Pop
~~~~~~~~~~
1140 6d81475c Iustin Pop
1141 c8e0a534 Iustin Pop
Deletes tags.
1142 6d81475c Iustin Pop
1143 c71a1a3d Iustin Pop
In order to delete a set of tags, the DELETE request should be addressed
1144 c71a1a3d Iustin Pop
to URI like::
1145 6d81475c Iustin Pop
1146 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
1147 6d81475c Iustin Pop
1148 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
1149 2cad4b91 Iustin Pop
1150 2cad4b91 Iustin Pop
1151 c8e0a534 Iustin Pop
``/version``
1152 c8e0a534 Iustin Pop
++++++++++++
1153 6d81475c Iustin Pop
1154 c8e0a534 Iustin Pop
The version resource.
1155 6d81475c Iustin Pop
1156 c71a1a3d Iustin Pop
This resource should be used to determine the remote API version and to
1157 c71a1a3d Iustin Pop
adapt clients accordingly.
1158 6d81475c Iustin Pop
1159 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
1160 6d81475c Iustin Pop
1161 c8e0a534 Iustin Pop
``GET``
1162 c8e0a534 Iustin Pop
~~~~~~~
1163 6d81475c Iustin Pop
1164 c71a1a3d Iustin Pop
Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti 2.0
1165 c71a1a3d Iustin Pop
returns ``2``.
1166 558fd122 Michael Hanselmann
1167 558fd122 Michael Hanselmann
.. vim: set textwidth=72 :
1168 c71a1a3d Iustin Pop
.. Local Variables:
1169 c71a1a3d Iustin Pop
.. mode: rst
1170 c71a1a3d Iustin Pop
.. fill-column: 72
1171 c71a1a3d Iustin Pop
.. End: