Statistics
| Branch: | Tag: | Revision:

root / doc / rapi.rst @ 7a95a954

History | View | Annotate | Download (12 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 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/reboot``
287 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++++
288 6d81475c Iustin Pop
289 c8e0a534 Iustin Pop
Reboots URI for an instance.
290 6d81475c Iustin Pop
291 c8e0a534 Iustin Pop
It supports the following commands: ``POST``.
292 6d81475c Iustin Pop
293 c8e0a534 Iustin Pop
``POST``
294 c8e0a534 Iustin Pop
~~~~~~~~
295 6d81475c Iustin Pop
296 c8e0a534 Iustin Pop
Reboots the instance.
297 6d81475c Iustin Pop
298 c8e0a534 Iustin Pop
The URI takes optional ``type=hard|soft|full`` and
299 c8e0a534 Iustin Pop
``ignore_secondaries=False|True`` parameters.
300 6d81475c Iustin Pop
301 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
302 2cad4b91 Iustin Pop
303 2cad4b91 Iustin Pop
304 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/shutdown``
305 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++++++
306 6d81475c Iustin Pop
307 c8e0a534 Iustin Pop
Instance shutdown URI.
308 6d81475c Iustin Pop
309 c8e0a534 Iustin Pop
It supports the following commands: ``PUT``.
310 6d81475c Iustin Pop
311 c8e0a534 Iustin Pop
``PUT``
312 c8e0a534 Iustin Pop
~~~~~~~
313 6d81475c Iustin Pop
314 c8e0a534 Iustin Pop
Shutdowns an instance.
315 6d81475c Iustin Pop
316 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
317 2cad4b91 Iustin Pop
318 6d81475c Iustin Pop
319 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/startup``
320 c8e0a534 Iustin Pop
++++++++++++++++++++++++++++++++++++++++
321 6d81475c Iustin Pop
322 c8e0a534 Iustin Pop
Instance startup URI.
323 6d81475c Iustin Pop
324 c8e0a534 Iustin Pop
It supports the following commands: ``PUT``.
325 6d81475c Iustin Pop
326 c8e0a534 Iustin Pop
``PUT``
327 c8e0a534 Iustin Pop
~~~~~~~
328 6d81475c Iustin Pop
329 c8e0a534 Iustin Pop
Startup an instance.
330 6d81475c Iustin Pop
331 c8e0a534 Iustin Pop
The URI takes an optional ``force=False|True`` parameter to start the
332 c8e0a534 Iustin Pop
instance if even if secondary disks are failing.
333 6d81475c Iustin Pop
334 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
335 2cad4b91 Iustin Pop
336 2cad4b91 Iustin Pop
337 c8e0a534 Iustin Pop
``/2/instances/[instance_name]/tags``
338 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++++++++++
339 6d81475c Iustin Pop
340 c8e0a534 Iustin Pop
Manages per-instance tags.
341 6d81475c Iustin Pop
342 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
343 6d81475c Iustin Pop
344 c8e0a534 Iustin Pop
``GET``
345 c8e0a534 Iustin Pop
~~~~~~~
346 6d81475c Iustin Pop
347 c8e0a534 Iustin Pop
Returns a list of tags.
348 6d81475c Iustin Pop
349 c8e0a534 Iustin Pop
Example::
350 6d81475c Iustin Pop
351 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
352 6d81475c Iustin Pop
353 c8e0a534 Iustin Pop
``PUT``
354 c8e0a534 Iustin Pop
~~~~~~~
355 6d81475c Iustin Pop
356 c8e0a534 Iustin Pop
Add a set of tags.
357 6d81475c Iustin Pop
358 c8e0a534 Iustin Pop
The request as a list of strings should be ``PUT`` to this URI. The
359 c8e0a534 Iustin Pop
result willl be a job id.
360 6d81475c Iustin Pop
361 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
362 2cad4b91 Iustin Pop
363 2cad4b91 Iustin Pop
364 c8e0a534 Iustin Pop
``DELETE``
365 c8e0a534 Iustin Pop
~~~~~~~~~~
366 6d81475c Iustin Pop
367 c8e0a534 Iustin Pop
Delete a tag.
368 6d81475c Iustin Pop
369 c8e0a534 Iustin Pop
In order to delete a set of tags, the DELETE request should be
370 c8e0a534 Iustin Pop
addressed to URI like::
371 6d81475c Iustin Pop
372 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
373 6d81475c Iustin Pop
374 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
375 2cad4b91 Iustin Pop
376 2cad4b91 Iustin Pop
377 c8e0a534 Iustin Pop
``/2/jobs``
378 c8e0a534 Iustin Pop
+++++++++++
379 6d81475c Iustin Pop
380 c8e0a534 Iustin Pop
The ``/2/jobs`` resource.
381 6d81475c Iustin Pop
382 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
383 6d81475c Iustin Pop
384 c8e0a534 Iustin Pop
``GET``
385 c8e0a534 Iustin Pop
~~~~~~~
386 6d81475c Iustin Pop
387 c8e0a534 Iustin Pop
Returns a dictionary of jobs.
388 6d81475c Iustin Pop
389 c8e0a534 Iustin Pop
Returns: a dictionary with jobs id and uri.
390 6d81475c Iustin Pop
391 c8e0a534 Iustin Pop
``/2/jobs/[job_id]``
392 c8e0a534 Iustin Pop
++++++++++++++++++++
393 6d81475c Iustin Pop
394 6d81475c Iustin Pop
395 c8e0a534 Iustin Pop
Individual job URI.
396 6d81475c Iustin Pop
397 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``DELETE``.
398 6d81475c Iustin Pop
399 c8e0a534 Iustin Pop
``GET``
400 c8e0a534 Iustin Pop
~~~~~~~
401 6d81475c Iustin Pop
402 c8e0a534 Iustin Pop
Returns a job status.
403 6d81475c Iustin Pop
404 c8e0a534 Iustin Pop
Returns: a dictionary with job parameters.
405 6d81475c Iustin Pop
406 c8e0a534 Iustin Pop
The result includes:
407 6d81475c Iustin Pop
408 c8e0a534 Iustin Pop
- id: job ID as a number
409 c8e0a534 Iustin Pop
- status: current job status as a string
410 c8e0a534 Iustin Pop
- ops: involved OpCodes as a list of dictionaries for each
411 c8e0a534 Iustin Pop
  opcodes in the job
412 c8e0a534 Iustin Pop
- opstatus: OpCodes status as a list
413 c8e0a534 Iustin Pop
- opresult: OpCodes results as a list of lists
414 6d81475c Iustin Pop
415 c8e0a534 Iustin Pop
``DELETE``
416 c8e0a534 Iustin Pop
~~~~~~~~~~
417 6d81475c Iustin Pop
418 c8e0a534 Iustin Pop
Cancel a not-yet-started job.
419 6d81475c Iustin Pop
420 c8e0a534 Iustin Pop
``/2/nodes``
421 c8e0a534 Iustin Pop
++++++++++++
422 6d81475c Iustin Pop
423 c8e0a534 Iustin Pop
Nodes resource.
424 6d81475c Iustin Pop
425 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
426 6d81475c Iustin Pop
427 c8e0a534 Iustin Pop
``GET``
428 c8e0a534 Iustin Pop
~~~~~~~
429 6d81475c Iustin Pop
430 c8e0a534 Iustin Pop
Returns a list of all nodes.
431 6d81475c Iustin Pop
432 c8e0a534 Iustin Pop
Example::
433 6d81475c Iustin Pop
434 6d81475c Iustin Pop
    [
435 6d81475c Iustin Pop
      {
436 6d81475c Iustin Pop
        "id": "node1.example.com",
437 6d81475c Iustin Pop
        "uri": "\/instances\/node1.example.com"
438 6d81475c Iustin Pop
      },
439 6d81475c Iustin Pop
      {
440 6d81475c Iustin Pop
        "id": "node2.example.com",
441 6d81475c Iustin Pop
        "uri": "\/instances\/node2.example.com"
442 6d81475c Iustin Pop
      }
443 6d81475c Iustin Pop
    ]
444 6d81475c Iustin Pop
445 c8e0a534 Iustin Pop
If the optional 'bulk' argument is provided and set to 'true' value
446 c8e0a534 Iustin Pop
(i.e '?bulk=1'), the output contains detailed information about nodes
447 c8e0a534 Iustin Pop
as a list.
448 6d81475c Iustin Pop
449 c8e0a534 Iustin Pop
Example::
450 6d81475c Iustin Pop
451 6d81475c Iustin Pop
    [
452 6d81475c Iustin Pop
      {
453 6d81475c Iustin Pop
        "pinst_cnt": 1,
454 6d81475c Iustin Pop
        "mfree": 31280,
455 6d81475c Iustin Pop
        "mtotal": 32763,
456 6d81475c Iustin Pop
        "name": "www.example.com",
457 6d81475c Iustin Pop
        "tags": [],
458 6d81475c Iustin Pop
        "mnode": 512,
459 6d81475c Iustin Pop
        "dtotal": 5246208,
460 6d81475c Iustin Pop
        "sinst_cnt": 2,
461 6d81475c Iustin Pop
        "dfree": 5171712,
462 6d81475c Iustin Pop
        "offline": false
463 6d81475c Iustin Pop
      },
464 6d81475c Iustin Pop
      ...
465 6d81475c Iustin Pop
    ]
466 6d81475c Iustin Pop
467 73452f12 Michael Hanselmann
``/2/nodes/[node_name]/evacuate``
468 73452f12 Michael Hanselmann
+++++++++++++++++++++++++++++++++
469 73452f12 Michael Hanselmann
470 73452f12 Michael Hanselmann
Evacuates all secondary instances off a node.
471 73452f12 Michael Hanselmann
472 73452f12 Michael Hanselmann
It supports the following commands: ``POST``.
473 73452f12 Michael Hanselmann
474 73452f12 Michael Hanselmann
``POST``
475 73452f12 Michael Hanselmann
~~~~~~~~
476 73452f12 Michael Hanselmann
477 73452f12 Michael Hanselmann
To evacuate a node, either one of the ``iallocator`` or ``remote_node``
478 73452f12 Michael Hanselmann
parameters must be passed:
479 73452f12 Michael Hanselmann
480 73452f12 Michael Hanselmann
    evacuate?iallocator=[iallocator]
481 73452f12 Michael Hanselmann
    evacuate?remote_node=[nodeX.example.com]
482 73452f12 Michael Hanselmann
483 1c482bab Michael Hanselmann
``/2/nodes/[node_name]/migrate``
484 1c482bab Michael Hanselmann
+++++++++++++++++++++++++++++++++
485 1c482bab Michael Hanselmann
486 1c482bab Michael Hanselmann
Migrates all primary instances from a node.
487 1c482bab Michael Hanselmann
488 1c482bab Michael Hanselmann
It supports the following commands: ``POST``.
489 1c482bab Michael Hanselmann
490 1c482bab Michael Hanselmann
``POST``
491 1c482bab Michael Hanselmann
~~~~~~~~
492 1c482bab Michael Hanselmann
493 1c482bab Michael Hanselmann
No parameters are required, but ``live`` can be set to a boolean value.
494 1c482bab Michael Hanselmann
495 1c482bab Michael Hanselmann
    migrate?live=[0|1]
496 1c482bab Michael Hanselmann
497 64dae8fc Michael Hanselmann
``/2/nodes/[node_name]/role``
498 64dae8fc Michael Hanselmann
+++++++++++++++++++++++++++++
499 64dae8fc Michael Hanselmann
500 64dae8fc Michael Hanselmann
Manages node role.
501 64dae8fc Michael Hanselmann
502 64dae8fc Michael Hanselmann
It supports the following commands: ``GET``, ``PUT``.
503 64dae8fc Michael Hanselmann
504 64dae8fc Michael Hanselmann
The role is always one of the following:
505 64dae8fc Michael Hanselmann
506 64dae8fc Michael Hanselmann
  - drained
507 64dae8fc Michael Hanselmann
  - master
508 64dae8fc Michael Hanselmann
  - master-candidate
509 64dae8fc Michael Hanselmann
  - offline
510 64dae8fc Michael Hanselmann
  - regular
511 64dae8fc Michael Hanselmann
512 64dae8fc Michael Hanselmann
``GET``
513 64dae8fc Michael Hanselmann
~~~~~~~
514 64dae8fc Michael Hanselmann
515 64dae8fc Michael Hanselmann
Returns the current node role.
516 64dae8fc Michael Hanselmann
517 64dae8fc Michael Hanselmann
Example::
518 64dae8fc Michael Hanselmann
519 64dae8fc Michael Hanselmann
    "master-candidate"
520 64dae8fc Michael Hanselmann
521 64dae8fc Michael Hanselmann
``PUT``
522 64dae8fc Michael Hanselmann
~~~~~~~
523 64dae8fc Michael Hanselmann
524 64dae8fc Michael Hanselmann
Change the node role.
525 64dae8fc Michael Hanselmann
526 64dae8fc Michael Hanselmann
The request is a string which should be PUT to this URI. The result will be a
527 64dae8fc Michael Hanselmann
job id.
528 64dae8fc Michael Hanselmann
529 64dae8fc Michael Hanselmann
It supports the ``force`` argument.
530 64dae8fc Michael Hanselmann
531 7a95a954 Michael Hanselmann
``/2/nodes/[node_name]/storage``
532 7a95a954 Michael Hanselmann
++++++++++++++++++++++++++++++++
533 7a95a954 Michael Hanselmann
534 7a95a954 Michael Hanselmann
Manages storage units on the node.
535 7a95a954 Michael Hanselmann
536 7a95a954 Michael Hanselmann
``GET``
537 7a95a954 Michael Hanselmann
~~~~~~~
538 7a95a954 Michael Hanselmann
539 7a95a954 Michael Hanselmann
Requests a list of storage units on a node. Requires the parameters
540 7a95a954 Michael Hanselmann
``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and
541 7a95a954 Michael Hanselmann
``output_fields``. The result will be a job id, using which the result can be
542 7a95a954 Michael Hanselmann
retrieved.
543 7a95a954 Michael Hanselmann
544 c8e0a534 Iustin Pop
``/2/nodes/[node_name]/tags``
545 c8e0a534 Iustin Pop
+++++++++++++++++++++++++++++
546 6d81475c Iustin Pop
547 c8e0a534 Iustin Pop
Manages per-node tags.
548 6d81475c Iustin Pop
549 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
550 6d81475c Iustin Pop
551 c8e0a534 Iustin Pop
``GET``
552 c8e0a534 Iustin Pop
~~~~~~~
553 6d81475c Iustin Pop
554 c8e0a534 Iustin Pop
Returns a list of tags.
555 6d81475c Iustin Pop
556 c8e0a534 Iustin Pop
Example::
557 6d81475c Iustin Pop
558 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
559 6d81475c Iustin Pop
560 c8e0a534 Iustin Pop
``PUT``
561 c8e0a534 Iustin Pop
~~~~~~~
562 6d81475c Iustin Pop
563 c8e0a534 Iustin Pop
Add a set of tags.
564 6d81475c Iustin Pop
565 c8e0a534 Iustin Pop
The request as a list of strings should be PUT to this URI. The result
566 c8e0a534 Iustin Pop
will be a job id.
567 6d81475c Iustin Pop
568 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
569 2cad4b91 Iustin Pop
570 c8e0a534 Iustin Pop
``DELETE``
571 c8e0a534 Iustin Pop
~~~~~~~~~~
572 6d81475c Iustin Pop
573 c8e0a534 Iustin Pop
Deletes tags.
574 6d81475c Iustin Pop
575 c8e0a534 Iustin Pop
In order to delete a set of tags, the DELETE request should be
576 c8e0a534 Iustin Pop
addressed to URI like::
577 6d81475c Iustin Pop
578 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
579 6d81475c Iustin Pop
580 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
581 2cad4b91 Iustin Pop
582 2cad4b91 Iustin Pop
583 c8e0a534 Iustin Pop
``/2/os``
584 c8e0a534 Iustin Pop
+++++++++
585 6d81475c Iustin Pop
586 c8e0a534 Iustin Pop
OS resource.
587 6d81475c Iustin Pop
588 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
589 6d81475c Iustin Pop
590 c8e0a534 Iustin Pop
``GET``
591 c8e0a534 Iustin Pop
~~~~~~~
592 6d81475c Iustin Pop
593 c8e0a534 Iustin Pop
Return a list of all OSes.
594 6d81475c Iustin Pop
595 c8e0a534 Iustin Pop
Can return error 500 in case of a problem. Since this is a costly
596 c8e0a534 Iustin Pop
operation for Ganeti 2.0, it is not recommended to execute it too
597 c8e0a534 Iustin Pop
often.
598 6d81475c Iustin Pop
599 c8e0a534 Iustin Pop
Example::
600 6d81475c Iustin Pop
601 c8e0a534 Iustin Pop
    ["debian-etch"]
602 6d81475c Iustin Pop
603 c8e0a534 Iustin Pop
``/2/tags``
604 c8e0a534 Iustin Pop
+++++++++++
605 6d81475c Iustin Pop
606 c8e0a534 Iustin Pop
Manages cluster tags.
607 6d81475c Iustin Pop
608 c8e0a534 Iustin Pop
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
609 6d81475c Iustin Pop
610 c8e0a534 Iustin Pop
``GET``
611 c8e0a534 Iustin Pop
~~~~~~~
612 6d81475c Iustin Pop
613 c8e0a534 Iustin Pop
Returns the cluster tags.
614 6d81475c Iustin Pop
615 c8e0a534 Iustin Pop
Example::
616 6d81475c Iustin Pop
617 c8e0a534 Iustin Pop
    ["tag1", "tag2", "tag3"]
618 6d81475c Iustin Pop
619 c8e0a534 Iustin Pop
``PUT``
620 c8e0a534 Iustin Pop
~~~~~~~
621 6d81475c Iustin Pop
622 c8e0a534 Iustin Pop
Adds a set of tags.
623 6d81475c Iustin Pop
624 c8e0a534 Iustin Pop
The request as a list of strings should be PUT to this URI. The result
625 c8e0a534 Iustin Pop
will be a job id.
626 6d81475c Iustin Pop
627 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
628 2cad4b91 Iustin Pop
629 2cad4b91 Iustin Pop
630 c8e0a534 Iustin Pop
``DELETE``
631 c8e0a534 Iustin Pop
~~~~~~~~~~
632 6d81475c Iustin Pop
633 c8e0a534 Iustin Pop
Deletes tags.
634 6d81475c Iustin Pop
635 c8e0a534 Iustin Pop
In order to delete a set of tags, the DELETE request should be
636 c8e0a534 Iustin Pop
addressed to URI like::
637 6d81475c Iustin Pop
638 c8e0a534 Iustin Pop
    /tags?tag=[tag]&tag=[tag]
639 6d81475c Iustin Pop
640 2cad4b91 Iustin Pop
It supports the ``dry-run`` argument.
641 2cad4b91 Iustin Pop
642 2cad4b91 Iustin Pop
643 c8e0a534 Iustin Pop
``/version``
644 c8e0a534 Iustin Pop
++++++++++++
645 6d81475c Iustin Pop
646 c8e0a534 Iustin Pop
The version resource.
647 6d81475c Iustin Pop
648 c8e0a534 Iustin Pop
This resource should be used to determine the remote API version and
649 c8e0a534 Iustin Pop
to adapt clients accordingly.
650 6d81475c Iustin Pop
651 c8e0a534 Iustin Pop
It supports the following commands: ``GET``.
652 6d81475c Iustin Pop
653 c8e0a534 Iustin Pop
``GET``
654 c8e0a534 Iustin Pop
~~~~~~~
655 6d81475c Iustin Pop
656 c8e0a534 Iustin Pop
Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti
657 c8e0a534 Iustin Pop
2.0 returns ``2``.