Statistics
| Branch: | Tag: | Revision:

root / doc / rapi.rst @ d87e1814

History | View | Annotate | Download (13.5 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 4352bf6d Iustin Pop
Protocol
20 4352bf6d Iustin Pop
--------
21 4352bf6d Iustin Pop
22 4352bf6d Iustin Pop
The protocol used is JSON_ over HTTP designed after the REST_
23 4352bf6d Iustin Pop
principle.
24 4352bf6d Iustin Pop
25 4352bf6d Iustin Pop
.. _JSON: http://www.json.org/
26 4352bf6d Iustin Pop
.. _REST: http://en.wikipedia.org/wiki/Representational_State_Transfer
27 4352bf6d Iustin Pop
28 2cad4b91 Iustin Pop
Generic parameters
29 2cad4b91 Iustin Pop
------------------
30 2cad4b91 Iustin Pop
31 2cad4b91 Iustin Pop
A few parameter mean the same thing across all resources which implement it.
32 2cad4b91 Iustin Pop
33 2cad4b91 Iustin Pop
``bulk``
34 2cad4b91 Iustin Pop
++++++++
35 2cad4b91 Iustin Pop
36 2cad4b91 Iustin Pop
Bulk-mode means that for the resources which usually return just a
37 2cad4b91 Iustin Pop
list of child resources (e.g. ``/2/instances`` which returns just
38 2cad4b91 Iustin Pop
instance names), the output will instead contain detailed data for all
39 2cad4b91 Iustin Pop
these subresources. This is more efficient than query-ing the
40 2cad4b91 Iustin Pop
sub-resources themselves.
41 2cad4b91 Iustin Pop
42 2cad4b91 Iustin Pop
``dry-run``
43 2cad4b91 Iustin Pop
+++++++++++
44 2cad4b91 Iustin Pop
45 2cad4b91 Iustin Pop
The optional *dry-run* argument, if provided and set to a positive
46 2cad4b91 Iustin Pop
integer value (e.g. ``?dry-run=1``), signals to Ganeti that the job
47 2cad4b91 Iustin Pop
should not be executed, only the pre-execution checks will be done.
48 2cad4b91 Iustin Pop
49 2cad4b91 Iustin Pop
This is useful in trying to determine (without guarantees though, as
50 2cad4b91 Iustin Pop
in the meantime the cluster state could have changed) if the operation
51 2cad4b91 Iustin Pop
is likely to succeed or at least start executing.
52 2cad4b91 Iustin Pop
53 3427d34f Michael Hanselmann
``force``
54 3427d34f Michael Hanselmann
+++++++++++
55 3427d34f Michael Hanselmann
56 3427d34f Michael Hanselmann
Force operation to continue even if it will cause the cluster to become
57 3427d34f Michael Hanselmann
inconsistent (e.g. because there are not enough master candidates).
58 3427d34f Michael Hanselmann
59 4352bf6d Iustin Pop
Usage examples
60 4352bf6d Iustin Pop
--------------
61 4352bf6d Iustin Pop
62 4352bf6d Iustin Pop
You can access the API using your favorite programming language as
63 4352bf6d Iustin Pop
long as it supports network connections.
64 4352bf6d Iustin Pop
65 4352bf6d Iustin Pop
Shell
66 4352bf6d Iustin Pop
+++++
67 4352bf6d Iustin Pop
68 c8e0a534 Iustin Pop
.. highlight:: sh
69 c8e0a534 Iustin Pop
70 4352bf6d Iustin Pop
Using wget::
71 4352bf6d Iustin Pop
72 c8e0a534 Iustin Pop
   wget -q -O - https://CLUSTERNAME:5080/2/info
73 4352bf6d Iustin Pop
74 4352bf6d Iustin Pop
or curl::
75 4352bf6d Iustin Pop
76 4352bf6d Iustin Pop
  curl https://CLUSTERNAME:5080/2/info
77 4352bf6d Iustin Pop
78 4352bf6d Iustin Pop
79 4352bf6d Iustin Pop
Python
80 4352bf6d Iustin Pop
++++++
81 4352bf6d Iustin Pop
82 c8e0a534 Iustin Pop
.. highlight: python
83 4352bf6d Iustin Pop
84 4352bf6d Iustin Pop
  import urllib2
85 4fb301b5 Tim Boring
  f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info')
86 4352bf6d Iustin Pop
  print f.read()
87 4352bf6d Iustin Pop
88 4352bf6d Iustin Pop
89 4352bf6d Iustin Pop
JavaScript
90 4352bf6d Iustin Pop
++++++++++
91 4352bf6d Iustin Pop
92 2cad4b91 Iustin Pop
.. warning:: While it's possible to use JavaScript, it poses several
93 2cad4b91 Iustin Pop
  potential problems, including browser blocking request due to
94 2cad4b91 Iustin Pop
  non-standard ports or different domain names. Fetching the data on
95 2cad4b91 Iustin Pop
  the webserver is easier.
96 4352bf6d Iustin Pop
97 c8e0a534 Iustin Pop
.. highlight:: javascript
98 c8e0a534 Iustin Pop
99 4352bf6d Iustin Pop
::
100 4352bf6d Iustin Pop
101 4fb301b5 Tim Boring
  var url = 'https://CLUSTERNAME:5080/2/info';
102 4352bf6d Iustin Pop
  var info;
103 4352bf6d Iustin Pop
  var xmlreq = new XMLHttpRequest();
104 4352bf6d Iustin Pop
  xmlreq.onreadystatechange = function () {
105 4352bf6d Iustin Pop
    if (xmlreq.readyState != 4) return;
106 4352bf6d Iustin Pop
    if (xmlreq.status == 200) {
107 4352bf6d Iustin Pop
      info = eval("(" + xmlreq.responseText + ")");
108 4352bf6d Iustin Pop
      alert(info);
109 4352bf6d Iustin Pop
    } else {
110 4352bf6d Iustin Pop
      alert('Error fetching cluster info');
111 4352bf6d Iustin Pop
    }
112 4352bf6d Iustin Pop
    xmlreq = null;
113 4352bf6d Iustin Pop
  };
114 4352bf6d Iustin Pop
  xmlreq.open('GET', url, true);
115 4352bf6d Iustin Pop
  xmlreq.send(null);
116 4352bf6d Iustin Pop
117 4352bf6d Iustin Pop
Resources
118 4352bf6d Iustin Pop
---------
119 4352bf6d Iustin Pop
120 c8e0a534 Iustin Pop
.. highlight:: javascript
121 6d81475c Iustin Pop
122 c8e0a534 Iustin Pop
``/``
123 c8e0a534 Iustin Pop
+++++
124 6d81475c Iustin Pop
125 c8e0a534 Iustin Pop
The root resource.
126 6d81475c Iustin Pop
127 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
128 6d81475c Iustin Pop
129 c8e0a534 Iustin Pop
``GET``
130 c8e0a534 Iustin Pop
~~~~~~~
131 6d81475c Iustin Pop
132 c8e0a534 Iustin Pop
Shows the list of mapped resources.
133 6d81475c Iustin Pop
134 c8e0a534 Iustin Pop
Returns: a dictionary with 'name' and 'uri' keys for each of them.
135 6d81475c Iustin Pop
136 c8e0a534 Iustin Pop
``/2``
137 c8e0a534 Iustin Pop
++++++
138 6d81475c Iustin Pop
139 c8e0a534 Iustin Pop
The ``/2`` resource, the root of the version 2 API.
140 6d81475c Iustin Pop
141 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
142 6d81475c Iustin Pop
143 c8e0a534 Iustin Pop
``GET``
144 c8e0a534 Iustin Pop
~~~~~~~
145 6d81475c Iustin Pop
146 c8e0a534 Iustin Pop
Show the list of mapped resources.
147 6d81475c Iustin Pop
148 c8e0a534 Iustin Pop
Returns: a dictionary with ``name`` and ``uri`` keys for each of them.
149 6d81475c Iustin Pop
150 c8e0a534 Iustin Pop
``/2/info``
151 c8e0a534 Iustin Pop
+++++++++++
152 6d81475c Iustin Pop
153 c8e0a534 Iustin Pop
Cluster information resource.
154 6d81475c Iustin Pop
155 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
156 6d81475c Iustin Pop
157 c8e0a534 Iustin Pop
``GET``
158 c8e0a534 Iustin Pop
~~~~~~~
159 6d81475c Iustin Pop
160 c8e0a534 Iustin Pop
Returns cluster information.
161 6d81475c Iustin Pop
162 c8e0a534 Iustin Pop
Example::
163 6d81475c Iustin Pop
164 6d81475c Iustin Pop
  {
165 6d81475c Iustin Pop
    "config_version": 2000000,
166 6d81475c Iustin Pop
    "name": "cluster",
167 6d81475c Iustin Pop
    "software_version": "2.0.0~beta2",
168 6d81475c Iustin Pop
    "os_api_version": 10,
169 6d81475c Iustin Pop
    "export_version": 0,
170 6d81475c Iustin Pop
    "candidate_pool_size": 10,
171 6d81475c Iustin Pop
    "enabled_hypervisors": [
172 6d81475c Iustin Pop
      "fake"
173 6d81475c Iustin Pop
    ],
174 6d81475c Iustin Pop
    "hvparams": {
175 6d81475c Iustin Pop
      "fake": {}
176 6d81475c Iustin Pop
     },
177 6d81475c Iustin Pop
    "default_hypervisor": "fake",
178 6d81475c Iustin Pop
    "master": "node1.example.com",
179 6d81475c Iustin Pop
    "architecture": [
180 6d81475c Iustin Pop
      "64bit",
181 6d81475c Iustin Pop
      "x86_64"
182 6d81475c Iustin Pop
    ],
183 6d81475c Iustin Pop
    "protocol_version": 20,
184 6d81475c Iustin Pop
    "beparams": {
185 6d81475c Iustin Pop
      "default": {
186 6d81475c Iustin Pop
        "auto_balance": true,
187 6d81475c Iustin Pop
        "vcpus": 1,
188 6d81475c Iustin Pop
        "memory": 128
189 6d81475c Iustin Pop
       }
190 6d81475c Iustin Pop
      }
191 6d81475c Iustin Pop
    }
192 6d81475c Iustin Pop
193 c8e0a534 Iustin Pop
``/2/instances``
194 c8e0a534 Iustin Pop
++++++++++++++++
195 6d81475c Iustin Pop
196 c8e0a534 Iustin Pop
The instances resource.
197 6d81475c Iustin Pop
198 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``POST``.
199 6d81475c Iustin Pop
200 c8e0a534 Iustin Pop
``GET``
201 c8e0a534 Iustin Pop
~~~~~~~
202 6d81475c Iustin Pop
203 c8e0a534 Iustin Pop
Returns a list of all available instances.
204 6d81475c Iustin Pop
205 c8e0a534 Iustin Pop
Example::
206 6d81475c Iustin Pop
207 6d81475c Iustin Pop
    [
208 6d81475c Iustin Pop
      {
209 6d81475c Iustin Pop
        "name": "web.example.com",
210 6d81475c Iustin Pop
        "uri": "\/instances\/web.example.com"
211 6d81475c Iustin Pop
      },
212 6d81475c Iustin Pop
      {
213 6d81475c Iustin Pop
        "name": "mail.example.com",
214 6d81475c Iustin Pop
        "uri": "\/instances\/mail.example.com"
215 6d81475c Iustin Pop
      }
216 6d81475c Iustin Pop
    ]
217 6d81475c Iustin Pop
218 c8e0a534 Iustin Pop
If the optional *bulk* argument is provided and set to a true value
219 c8e0a534 Iustin Pop
(i.e ``?bulk=1``), the output contains detailed information about
220 c8e0a534 Iustin Pop
instances as a list.
221 6d81475c Iustin Pop
222 c8e0a534 Iustin Pop
Example::
223 6d81475c Iustin Pop
224 6d81475c Iustin Pop
    [
225 6d81475c Iustin Pop
      {
226 6d81475c Iustin Pop
         "status": "running",
227 6d81475c Iustin Pop
         "disk_usage": 20480,
228 6d81475c Iustin Pop
         "nic.bridges": [
229 6d81475c Iustin Pop
           "xen-br0"
230 6d81475c Iustin Pop
          ],
231 6d81475c Iustin Pop
         "name": "web.example.com",
232 6d81475c Iustin Pop
         "tags": ["tag1", "tag2"],
233 6d81475c Iustin Pop
         "beparams": {
234 6d81475c Iustin Pop
           "vcpus": 2,
235 6d81475c Iustin Pop
           "memory": 512
236 6d81475c Iustin Pop
         },
237 6d81475c Iustin Pop
         "disk.sizes": [
238 6d81475c Iustin Pop
             20480
239 6d81475c Iustin Pop
         ],
240 6d81475c Iustin Pop
         "pnode": "node1.example.com",
241 6d81475c Iustin Pop
         "nic.macs": ["01:23:45:67:89:01"],
242 6d81475c Iustin Pop
         "snodes": ["node2.example.com"],
243 6d81475c Iustin Pop
         "disk_template": "drbd",
244 6d81475c Iustin Pop
         "admin_state": true,
245 6d81475c Iustin Pop
         "os": "debian-etch",
246 6d81475c Iustin Pop
         "oper_state": true
247 6d81475c Iustin Pop
      },
248 6d81475c Iustin Pop
      ...
249 6d81475c Iustin Pop
    ]
250 6d81475c Iustin Pop
251 6d81475c Iustin Pop
252 c8e0a534 Iustin Pop
``POST``
253 c8e0a534 Iustin Pop
~~~~~~~~
254 6d81475c Iustin Pop
255 c8e0a534 Iustin Pop
Creates an instance.
256 6d81475c Iustin Pop
257 2cad4b91 Iustin Pop
If the optional *dry-run* argument is provided and set to a positive
258 2cad4b91 Iustin Pop
integer valu (e.g. ``?dry-run=1``), the job will not be actually
259 2cad4b91 Iustin Pop
executed, only the pre-execution checks will be done. Query-ing the
260 2cad4b91 Iustin Pop
job result will return, in both dry-run and normal case, the list of
261 2cad4b91 Iustin Pop
nodes selected for the instance.
262 2cad4b91 Iustin Pop
263 c8e0a534 Iustin Pop
Returns: a job ID that can be used later for polling.
264 6d81475c Iustin Pop
265 c8e0a534 Iustin Pop
``/2/instances/[instance_name]``
266 c8e0a534 Iustin Pop
++++++++++++++++++++++++++++++++
267 6d81475c Iustin Pop
268 c8e0a534 Iustin Pop
Instance-specific resource.
269 6d81475c Iustin Pop
270 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``DELETE``.
271 6d81475c Iustin Pop
272 c8e0a534 Iustin Pop
``GET``
273 c8e0a534 Iustin Pop
~~~~~~~
274 6d81475c Iustin Pop
275 c8e0a534 Iustin Pop
Returns information about an instance, similar to the bulk output from
276 c8e0a534 Iustin Pop
the instance list.
277 6d81475c Iustin Pop
278 c8e0a534 Iustin Pop
``DELETE``
279 c8e0a534 Iustin Pop
~~~~~~~~~~
280 6d81475c Iustin Pop
281 c8e0a534 Iustin Pop
Deletes an instance.
282 6d81475c Iustin Pop
283 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
284 2cad4b91 Iustin Pop
285 6d81475c Iustin Pop
286 d8260842 Michael Hanselmann
``/2/instances/[instance_name]/info``
287 d8260842 Michael Hanselmann
+++++++++++++++++++++++++++++++++++++++
288 d8260842 Michael Hanselmann
289 d8260842 Michael Hanselmann
It supports the following commands: ``GET``.
290 d8260842 Michael Hanselmann
291 d8260842 Michael Hanselmann
``GET``
292 d8260842 Michael Hanselmann
~~~~~~~
293 d8260842 Michael Hanselmann
294 d8260842 Michael Hanselmann
Requests detailed information about the instance. An optional parameter,
295 d8260842 Michael Hanselmann
``static`` (bool), can be set to return only static information from the
296 d8260842 Michael Hanselmann
configuration without querying the instance's nodes. The result will be a job
297 d8260842 Michael Hanselmann
id.
298 d8260842 Michael Hanselmann
299 d8260842 Michael Hanselmann
300 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/reboot``
301 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++++
302 6d81475c Iustin Pop
303 c8e0a534 Iustin Pop
Reboots URI for an instance.
304 6d81475c Iustin Pop
305 c8e0a534 Iustin Pop
It supports the following commands: ``POST``.
306 6d81475c Iustin Pop
307 c8e0a534 Iustin Pop
``POST``
308 c8e0a534 Iustin Pop
~~~~~~~~
309 6d81475c Iustin Pop
310 c8e0a534 Iustin Pop
Reboots the instance.
311 6d81475c Iustin Pop
312 c8e0a534 Iustin Pop
The URI takes optional ``type=hard|soft|full`` and
313 c8e0a534 Iustin Pop
``ignore_secondaries=False|True`` parameters.
314 6d81475c Iustin Pop
315 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
316 2cad4b91 Iustin Pop
317 2cad4b91 Iustin Pop
318 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/shutdown``
319 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++++++
320 6d81475c Iustin Pop
321 c8e0a534 Iustin Pop
Instance shutdown URI.
322 6d81475c Iustin Pop
323 c8e0a534 Iustin Pop
It supports the following commands: ``PUT``.
324 6d81475c Iustin Pop
325 c8e0a534 Iustin Pop
``PUT``
326 c8e0a534 Iustin Pop
~~~~~~~
327 6d81475c Iustin Pop
328 c8e0a534 Iustin Pop
Shutdowns an instance.
329 6d81475c Iustin Pop
330 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
331 2cad4b91 Iustin Pop
332 6d81475c Iustin Pop
333 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/startup``
334 c8e0a534 Iustin Pop
++++++++++++++++++++++++++++++++++++++++
335 6d81475c Iustin Pop
336 c8e0a534 Iustin Pop
Instance startup URI.
337 6d81475c Iustin Pop
338 c8e0a534 Iustin Pop
It supports the following commands: ``PUT``.
339 6d81475c Iustin Pop
340 c8e0a534 Iustin Pop
``PUT``
341 c8e0a534 Iustin Pop
~~~~~~~
342 6d81475c Iustin Pop
343 c8e0a534 Iustin Pop
Startup an instance.
344 6d81475c Iustin Pop
345 c8e0a534 Iustin Pop
The URI takes an optional ``force=False|True`` parameter to start the
346 c8e0a534 Iustin Pop
instance if even if secondary disks are failing.
347 6d81475c Iustin Pop
348 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
349 2cad4b91 Iustin Pop
350 2cad4b91 Iustin Pop
351 4c98b915 Michael Hanselmann
``/2/instances/[instance_name]/replace-disks``
352 4c98b915 Michael Hanselmann
++++++++++++++++++++++++++++++++++++++++++++++
353 4c98b915 Michael Hanselmann
354 4c98b915 Michael Hanselmann
Replaces disks on an instance.
355 4c98b915 Michael Hanselmann
356 4c98b915 Michael Hanselmann
It supports the following commands: ``POST``.
357 4c98b915 Michael Hanselmann
358 4c98b915 Michael Hanselmann
``POST``
359 4c98b915 Michael Hanselmann
~~~~~~~~
360 4c98b915 Michael Hanselmann
361 4c98b915 Michael Hanselmann
Takes the parameters ``mode`` (one of ``replace_on_primary``,
362 4c98b915 Michael Hanselmann
``replace_on_secondary``, ``replace_new_secondary`` or ``replace_auto``),
363 4c98b915 Michael Hanselmann
``disks`` (comma separated list of disk indexes), ``remote_node`` and
364 4c98b915 Michael Hanselmann
``iallocator``.
365 4c98b915 Michael Hanselmann
366 4c98b915 Michael Hanselmann
367 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/tags``
368 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++
369 6d81475c Iustin Pop
370 c8e0a534 Iustin Pop
Manages per-instance tags.
371 6d81475c Iustin Pop
372 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
373 6d81475c Iustin Pop
374 c8e0a534 Iustin Pop
``GET``
375 c8e0a534 Iustin Pop
~~~~~~~
376 6d81475c Iustin Pop
377 c8e0a534 Iustin Pop
Returns a list of tags.
378 6d81475c Iustin Pop
379 c8e0a534 Iustin Pop
Example::
380 6d81475c Iustin Pop
381 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
382 6d81475c Iustin Pop
383 c8e0a534 Iustin Pop
``PUT``
384 c8e0a534 Iustin Pop
~~~~~~~
385 6d81475c Iustin Pop
386 c8e0a534 Iustin Pop
Add a set of tags.
387 6d81475c Iustin Pop
388 c8e0a534 Iustin Pop
The request as a list of strings should be ``PUT`` to this URI. The
389 c8e0a534 Iustin Pop
result willl be a job id.
390 6d81475c Iustin Pop
391 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
392 2cad4b91 Iustin Pop
393 2cad4b91 Iustin Pop
394 c8e0a534 Iustin Pop
``DELETE``
395 c8e0a534 Iustin Pop
~~~~~~~~~~
396 6d81475c Iustin Pop
397 c8e0a534 Iustin Pop
Delete a tag.
398 6d81475c Iustin Pop
399 c8e0a534 Iustin Pop
In order to delete a set of tags, the DELETE request should be
400 c8e0a534 Iustin Pop
addressed to URI like::
401 6d81475c Iustin Pop
402 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
403 6d81475c Iustin Pop
404 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
405 2cad4b91 Iustin Pop
406 2cad4b91 Iustin Pop
407 c8e0a534 Iustin Pop
``/2/jobs``
408 c8e0a534 Iustin Pop
+++++++++++
409 6d81475c Iustin Pop
410 c8e0a534 Iustin Pop
The ``/2/jobs`` resource.
411 6d81475c Iustin Pop
412 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
413 6d81475c Iustin Pop
414 c8e0a534 Iustin Pop
``GET``
415 c8e0a534 Iustin Pop
~~~~~~~
416 6d81475c Iustin Pop
417 c8e0a534 Iustin Pop
Returns a dictionary of jobs.
418 6d81475c Iustin Pop
419 c8e0a534 Iustin Pop
Returns: a dictionary with jobs id and uri.
420 6d81475c Iustin Pop
421 c8e0a534 Iustin Pop
``/2/jobs/[job_id]``
422 c8e0a534 Iustin Pop
++++++++++++++++++++
423 6d81475c Iustin Pop
424 6d81475c Iustin Pop
425 c8e0a534 Iustin Pop
Individual job URI.
426 6d81475c Iustin Pop
427 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``DELETE``.
428 6d81475c Iustin Pop
429 c8e0a534 Iustin Pop
``GET``
430 c8e0a534 Iustin Pop
~~~~~~~
431 6d81475c Iustin Pop
432 c8e0a534 Iustin Pop
Returns a job status.
433 6d81475c Iustin Pop
434 c8e0a534 Iustin Pop
Returns: a dictionary with job parameters.
435 6d81475c Iustin Pop
436 c8e0a534 Iustin Pop
The result includes:
437 6d81475c Iustin Pop
438 c8e0a534 Iustin Pop
- id: job ID as a number
439 c8e0a534 Iustin Pop
- status: current job status as a string
440 c8e0a534 Iustin Pop
- ops: involved OpCodes as a list of dictionaries for each
441 c8e0a534 Iustin Pop
  opcodes in the job
442 c8e0a534 Iustin Pop
- opstatus: OpCodes status as a list
443 c8e0a534 Iustin Pop
- opresult: OpCodes results as a list of lists
444 6d81475c Iustin Pop
445 c8e0a534 Iustin Pop
``DELETE``
446 c8e0a534 Iustin Pop
~~~~~~~~~~
447 6d81475c Iustin Pop
448 c8e0a534 Iustin Pop
Cancel a not-yet-started job.
449 6d81475c Iustin Pop
450 c8e0a534 Iustin Pop
``/2/nodes``
451 c8e0a534 Iustin Pop
++++++++++++
452 6d81475c Iustin Pop
453 c8e0a534 Iustin Pop
Nodes resource.
454 6d81475c Iustin Pop
455 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
456 6d81475c Iustin Pop
457 c8e0a534 Iustin Pop
``GET``
458 c8e0a534 Iustin Pop
~~~~~~~
459 6d81475c Iustin Pop
460 c8e0a534 Iustin Pop
Returns a list of all nodes.
461 6d81475c Iustin Pop
462 c8e0a534 Iustin Pop
Example::
463 6d81475c Iustin Pop
464 6d81475c Iustin Pop
    [
465 6d81475c Iustin Pop
      {
466 6d81475c Iustin Pop
        "id": "node1.example.com",
467 6d81475c Iustin Pop
        "uri": "\/instances\/node1.example.com"
468 6d81475c Iustin Pop
      },
469 6d81475c Iustin Pop
      {
470 6d81475c Iustin Pop
        "id": "node2.example.com",
471 6d81475c Iustin Pop
        "uri": "\/instances\/node2.example.com"
472 6d81475c Iustin Pop
      }
473 6d81475c Iustin Pop
    ]
474 6d81475c Iustin Pop
475 c8e0a534 Iustin Pop
If the optional 'bulk' argument is provided and set to 'true' value
476 c8e0a534 Iustin Pop
(i.e '?bulk=1'), the output contains detailed information about nodes
477 c8e0a534 Iustin Pop
as a list.
478 6d81475c Iustin Pop
479 c8e0a534 Iustin Pop
Example::
480 6d81475c Iustin Pop
481 6d81475c Iustin Pop
    [
482 6d81475c Iustin Pop
      {
483 6d81475c Iustin Pop
        "pinst_cnt": 1,
484 6d81475c Iustin Pop
        "mfree": 31280,
485 6d81475c Iustin Pop
        "mtotal": 32763,
486 6d81475c Iustin Pop
        "name": "www.example.com",
487 6d81475c Iustin Pop
        "tags": [],
488 6d81475c Iustin Pop
        "mnode": 512,
489 6d81475c Iustin Pop
        "dtotal": 5246208,
490 6d81475c Iustin Pop
        "sinst_cnt": 2,
491 6d81475c Iustin Pop
        "dfree": 5171712,
492 6d81475c Iustin Pop
        "offline": false
493 6d81475c Iustin Pop
      },
494 6d81475c Iustin Pop
      ...
495 6d81475c Iustin Pop
    ]
496 6d81475c Iustin Pop
497 73452f12 Michael Hanselmann
``/2/nodes/[node_name]/evacuate``
498 73452f12 Michael Hanselmann
+++++++++++++++++++++++++++++++++
499 73452f12 Michael Hanselmann
500 73452f12 Michael Hanselmann
Evacuates all secondary instances off a node.
501 73452f12 Michael Hanselmann
502 73452f12 Michael Hanselmann
It supports the following commands: ``POST``.
503 73452f12 Michael Hanselmann
504 73452f12 Michael Hanselmann
``POST``
505 73452f12 Michael Hanselmann
~~~~~~~~
506 73452f12 Michael Hanselmann
507 73452f12 Michael Hanselmann
To evacuate a node, either one of the ``iallocator`` or ``remote_node``
508 73452f12 Michael Hanselmann
parameters must be passed:
509 73452f12 Michael Hanselmann
510 73452f12 Michael Hanselmann
    evacuate?iallocator=[iallocator]
511 73452f12 Michael Hanselmann
    evacuate?remote_node=[nodeX.example.com]
512 73452f12 Michael Hanselmann
513 1c482bab Michael Hanselmann
``/2/nodes/[node_name]/migrate``
514 1c482bab Michael Hanselmann
+++++++++++++++++++++++++++++++++
515 1c482bab Michael Hanselmann
516 1c482bab Michael Hanselmann
Migrates all primary instances from a node.
517 1c482bab Michael Hanselmann
518 1c482bab Michael Hanselmann
It supports the following commands: ``POST``.
519 1c482bab Michael Hanselmann
520 1c482bab Michael Hanselmann
``POST``
521 1c482bab Michael Hanselmann
~~~~~~~~
522 1c482bab Michael Hanselmann
523 1c482bab Michael Hanselmann
No parameters are required, but ``live`` can be set to a boolean value.
524 1c482bab Michael Hanselmann
525 1c482bab Michael Hanselmann
    migrate?live=[0|1]
526 1c482bab Michael Hanselmann
527 64dae8fc Michael Hanselmann
``/2/nodes/[node_name]/role``
528 64dae8fc Michael Hanselmann
+++++++++++++++++++++++++++++
529 64dae8fc Michael Hanselmann
530 64dae8fc Michael Hanselmann
Manages node role.
531 64dae8fc Michael Hanselmann
532 64dae8fc Michael Hanselmann
It supports the following commands: ``GET``, ``PUT``.
533 64dae8fc Michael Hanselmann
534 64dae8fc Michael Hanselmann
The role is always one of the following:
535 64dae8fc Michael Hanselmann
536 64dae8fc Michael Hanselmann
  - drained
537 64dae8fc Michael Hanselmann
  - master
538 64dae8fc Michael Hanselmann
  - master-candidate
539 64dae8fc Michael Hanselmann
  - offline
540 64dae8fc Michael Hanselmann
  - regular
541 64dae8fc Michael Hanselmann
542 64dae8fc Michael Hanselmann
``GET``
543 64dae8fc Michael Hanselmann
~~~~~~~
544 64dae8fc Michael Hanselmann
545 64dae8fc Michael Hanselmann
Returns the current node role.
546 64dae8fc Michael Hanselmann
547 64dae8fc Michael Hanselmann
Example::
548 64dae8fc Michael Hanselmann
549 64dae8fc Michael Hanselmann
    "master-candidate"
550 64dae8fc Michael Hanselmann
551 64dae8fc Michael Hanselmann
``PUT``
552 64dae8fc Michael Hanselmann
~~~~~~~
553 64dae8fc Michael Hanselmann
554 64dae8fc Michael Hanselmann
Change the node role.
555 64dae8fc Michael Hanselmann
556 64dae8fc Michael Hanselmann
The request is a string which should be PUT to this URI. The result will be a
557 64dae8fc Michael Hanselmann
job id.
558 64dae8fc Michael Hanselmann
559 64dae8fc Michael Hanselmann
It supports the ``force`` argument.
560 64dae8fc Michael Hanselmann
561 7a95a954 Michael Hanselmann
``/2/nodes/[node_name]/storage``
562 7a95a954 Michael Hanselmann
++++++++++++++++++++++++++++++++
563 7a95a954 Michael Hanselmann
564 7a95a954 Michael Hanselmann
Manages storage units on the node.
565 7a95a954 Michael Hanselmann
566 7a95a954 Michael Hanselmann
``GET``
567 7a95a954 Michael Hanselmann
~~~~~~~
568 7a95a954 Michael Hanselmann
569 7a95a954 Michael Hanselmann
Requests a list of storage units on a node. Requires the parameters
570 7a95a954 Michael Hanselmann
``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and
571 7a95a954 Michael Hanselmann
``output_fields``. The result will be a job id, using which the result can be
572 7a95a954 Michael Hanselmann
retrieved.
573 7a95a954 Michael Hanselmann
574 1e82bc80 Michael Hanselmann
``/2/nodes/[node_name]/storage/modify``
575 1e82bc80 Michael Hanselmann
+++++++++++++++++++++++++++++++++++++++
576 1e82bc80 Michael Hanselmann
577 1e82bc80 Michael Hanselmann
Modifies storage units on the node.
578 1e82bc80 Michael Hanselmann
579 1e82bc80 Michael Hanselmann
``PUT``
580 1e82bc80 Michael Hanselmann
~~~~~~~
581 1e82bc80 Michael Hanselmann
582 1e82bc80 Michael Hanselmann
Modifies parameters of storage units on the node. Requires the parameters
583 1e82bc80 Michael Hanselmann
``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and ``name`` (name
584 1e82bc80 Michael Hanselmann
of the storage unit).  Parameters can be passed additionally. Currently only
585 1e82bc80 Michael Hanselmann
``allocatable`` (bool) is supported. The result will be a job id.
586 1e82bc80 Michael Hanselmann
587 723f4565 Michael Hanselmann
``/2/nodes/[node_name]/storage/repair``
588 723f4565 Michael Hanselmann
+++++++++++++++++++++++++++++++++++++++
589 723f4565 Michael Hanselmann
590 723f4565 Michael Hanselmann
Repairs a storage unit on the node.
591 723f4565 Michael Hanselmann
592 723f4565 Michael Hanselmann
``PUT``
593 723f4565 Michael Hanselmann
~~~~~~~
594 723f4565 Michael Hanselmann
595 723f4565 Michael Hanselmann
Repairs a storage unit on the node. Requires the parameters ``storage_type``
596 723f4565 Michael Hanselmann
(currently only ``lvm-vg`` can be repaired) and ``name`` (name of the storage
597 723f4565 Michael Hanselmann
unit). The result will be a job id.
598 723f4565 Michael Hanselmann
599 c8e0a534 Iustin Pop
``/2/nodes/[node_name]/tags``
600 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++
601 6d81475c Iustin Pop
602 c8e0a534 Iustin Pop
Manages per-node tags.
603 6d81475c Iustin Pop
604 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
605 6d81475c Iustin Pop
606 c8e0a534 Iustin Pop
``GET``
607 c8e0a534 Iustin Pop
~~~~~~~
608 6d81475c Iustin Pop
609 c8e0a534 Iustin Pop
Returns a list of tags.
610 6d81475c Iustin Pop
611 c8e0a534 Iustin Pop
Example::
612 6d81475c Iustin Pop
613 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
614 6d81475c Iustin Pop
615 c8e0a534 Iustin Pop
``PUT``
616 c8e0a534 Iustin Pop
~~~~~~~
617 6d81475c Iustin Pop
618 c8e0a534 Iustin Pop
Add a set of tags.
619 6d81475c Iustin Pop
620 c8e0a534 Iustin Pop
The request as a list of strings should be PUT to this URI. The result
621 c8e0a534 Iustin Pop
will be a job id.
622 6d81475c Iustin Pop
623 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
624 2cad4b91 Iustin Pop
625 c8e0a534 Iustin Pop
``DELETE``
626 c8e0a534 Iustin Pop
~~~~~~~~~~
627 6d81475c Iustin Pop
628 c8e0a534 Iustin Pop
Deletes tags.
629 6d81475c Iustin Pop
630 c8e0a534 Iustin Pop
In order to delete a set of tags, the DELETE request should be
631 c8e0a534 Iustin Pop
addressed to URI like::
632 6d81475c Iustin Pop
633 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
634 6d81475c Iustin Pop
635 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
636 2cad4b91 Iustin Pop
637 2cad4b91 Iustin Pop
638 c8e0a534 Iustin Pop
``/2/os``
639 c8e0a534 Iustin Pop
+++++++++
640 6d81475c Iustin Pop
641 c8e0a534 Iustin Pop
OS resource.
642 6d81475c Iustin Pop
643 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
644 6d81475c Iustin Pop
645 c8e0a534 Iustin Pop
``GET``
646 c8e0a534 Iustin Pop
~~~~~~~
647 6d81475c Iustin Pop
648 c8e0a534 Iustin Pop
Return a list of all OSes.
649 6d81475c Iustin Pop
650 c8e0a534 Iustin Pop
Can return error 500 in case of a problem. Since this is a costly
651 c8e0a534 Iustin Pop
operation for Ganeti 2.0, it is not recommended to execute it too
652 c8e0a534 Iustin Pop
often.
653 6d81475c Iustin Pop
654 c8e0a534 Iustin Pop
Example::
655 6d81475c Iustin Pop
656 c8e0a534 Iustin Pop
    ["debian-etch"]
657 6d81475c Iustin Pop
658 c8e0a534 Iustin Pop
``/2/tags``
659 c8e0a534 Iustin Pop
+++++++++++
660 6d81475c Iustin Pop
661 c8e0a534 Iustin Pop
Manages cluster tags.
662 6d81475c Iustin Pop
663 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
664 6d81475c Iustin Pop
665 c8e0a534 Iustin Pop
``GET``
666 c8e0a534 Iustin Pop
~~~~~~~
667 6d81475c Iustin Pop
668 c8e0a534 Iustin Pop
Returns the cluster tags.
669 6d81475c Iustin Pop
670 c8e0a534 Iustin Pop
Example::
671 6d81475c Iustin Pop
672 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
673 6d81475c Iustin Pop
674 c8e0a534 Iustin Pop
``PUT``
675 c8e0a534 Iustin Pop
~~~~~~~
676 6d81475c Iustin Pop
677 c8e0a534 Iustin Pop
Adds a set of tags.
678 6d81475c Iustin Pop
679 c8e0a534 Iustin Pop
The request as a list of strings should be PUT to this URI. The result
680 c8e0a534 Iustin Pop
will be a job id.
681 6d81475c Iustin Pop
682 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
683 2cad4b91 Iustin Pop
684 2cad4b91 Iustin Pop
685 c8e0a534 Iustin Pop
``DELETE``
686 c8e0a534 Iustin Pop
~~~~~~~~~~
687 6d81475c Iustin Pop
688 c8e0a534 Iustin Pop
Deletes tags.
689 6d81475c Iustin Pop
690 c8e0a534 Iustin Pop
In order to delete a set of tags, the DELETE request should be
691 c8e0a534 Iustin Pop
addressed to URI like::
692 6d81475c Iustin Pop
693 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
694 6d81475c Iustin Pop
695 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
696 2cad4b91 Iustin Pop
697 2cad4b91 Iustin Pop
698 c8e0a534 Iustin Pop
``/version``
699 c8e0a534 Iustin Pop
++++++++++++
700 6d81475c Iustin Pop
701 c8e0a534 Iustin Pop
The version resource.
702 6d81475c Iustin Pop
703 c8e0a534 Iustin Pop
This resource should be used to determine the remote API version and
704 c8e0a534 Iustin Pop
to adapt clients accordingly.
705 6d81475c Iustin Pop
706 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
707 6d81475c Iustin Pop
708 c8e0a534 Iustin Pop
``GET``
709 c8e0a534 Iustin Pop
~~~~~~~
710 6d81475c Iustin Pop
711 c8e0a534 Iustin Pop
Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti
712 c8e0a534 Iustin Pop
2.0 returns ``2``.