4 Documents Ganeti version |version|
11 Ganeti supports a remote API for enable external tools to easily
12 retrieve information about a cluster's state. The remote API daemon,
13 *ganeti-rapi*, is automatically started on the master node. By default
14 it runs on TCP port 5080, but this can be changed either in
15 ``.../constants.py`` or via the command line parameter *-p*. SSL mode,
16 which is used by default, can also be disabled by passing command line
22 The protocol used is JSON_ over HTTP designed after the REST_
25 .. _JSON: http://www.json.org/
26 .. _REST: http://en.wikipedia.org/wiki/Representational_State_Transfer
31 A few parameter mean the same thing across all resources which implement it.
36 Bulk-mode means that for the resources which usually return just a
37 list of child resources (e.g. ``/2/instances`` which returns just
38 instance names), the output will instead contain detailed data for all
39 these subresources. This is more efficient than query-ing the
40 sub-resources themselves.
45 The optional *dry-run* argument, if provided and set to a positive
46 integer value (e.g. ``?dry-run=1``), signals to Ganeti that the job
47 should not be executed, only the pre-execution checks will be done.
49 This is useful in trying to determine (without guarantees though, as
50 in the meantime the cluster state could have changed) if the operation
51 is likely to succeed or at least start executing.
56 Force operation to continue even if it will cause the cluster to become
57 inconsistent (e.g. because there are not enough master candidates).
62 You can access the API using your favorite programming language as
63 long as it supports network connections.
72 wget -q -O - https://CLUSTERNAME:5080/2/info
76 curl https://CLUSTERNAME:5080/2/info
85 f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info')
92 .. warning:: While it's possible to use JavaScript, it poses several
93 potential problems, including browser blocking request due to
94 non-standard ports or different domain names. Fetching the data on
95 the webserver is easier.
97 .. highlight:: javascript
101 var url = 'https://CLUSTERNAME:5080/2/info';
103 var xmlreq = new XMLHttpRequest();
104 xmlreq.onreadystatechange = function () {
105 if (xmlreq.readyState != 4) return;
106 if (xmlreq.status == 200) {
107 info = eval("(" + xmlreq.responseText + ")");
110 alert('Error fetching cluster info');
114 xmlreq.open('GET', url, true);
120 .. highlight:: javascript
127 It supports the following commands: ``GET``.
132 Shows the list of mapped resources.
134 Returns: a dictionary with 'name' and 'uri' keys for each of them.
139 The ``/2`` resource, the root of the version 2 API.
141 It supports the following commands: ``GET``.
146 Show the list of mapped resources.
148 Returns: a dictionary with ``name`` and ``uri`` keys for each of them.
153 Cluster information resource.
155 It supports the following commands: ``GET``.
160 Returns cluster information.
165 "config_version": 2000000,
167 "software_version": "2.0.0~beta2",
168 "os_api_version": 10,
170 "candidate_pool_size": 10,
171 "enabled_hypervisors": [
177 "default_hypervisor": "fake",
178 "master": "node1.example.com",
183 "protocol_version": 20,
186 "auto_balance": true,
196 The instances resource.
198 It supports the following commands: ``GET``, ``POST``.
203 Returns a list of all available instances.
209 "name": "web.example.com",
210 "uri": "\/instances\/web.example.com"
213 "name": "mail.example.com",
214 "uri": "\/instances\/mail.example.com"
218 If the optional *bulk* argument is provided and set to a true value
219 (i.e ``?bulk=1``), the output contains detailed information about
231 "name": "web.example.com",
232 "tags": ["tag1", "tag2"],
240 "pnode": "node1.example.com",
241 "nic.macs": ["01:23:45:67:89:01"],
242 "snodes": ["node2.example.com"],
243 "disk_template": "drbd",
257 If the optional *dry-run* argument is provided and set to a positive
258 integer valu (e.g. ``?dry-run=1``), the job will not be actually
259 executed, only the pre-execution checks will be done. Query-ing the
260 job result will return, in both dry-run and normal case, the list of
261 nodes selected for the instance.
263 Returns: a job ID that can be used later for polling.
265 ``/2/instances/[instance_name]``
266 ++++++++++++++++++++++++++++++++
268 Instance-specific resource.
270 It supports the following commands: ``GET``, ``DELETE``.
275 Returns information about an instance, similar to the bulk output from
283 It supports the ``dry-run`` argument.
286 ``/2/instances/[instance_name]/reboot``
287 +++++++++++++++++++++++++++++++++++++++
289 Reboots URI for an instance.
291 It supports the following commands: ``POST``.
296 Reboots the instance.
298 The URI takes optional ``type=hard|soft|full`` and
299 ``ignore_secondaries=False|True`` parameters.
301 It supports the ``dry-run`` argument.
304 ``/2/instances/[instance_name]/shutdown``
305 +++++++++++++++++++++++++++++++++++++++++
307 Instance shutdown URI.
309 It supports the following commands: ``PUT``.
314 Shutdowns an instance.
316 It supports the ``dry-run`` argument.
319 ``/2/instances/[instance_name]/startup``
320 ++++++++++++++++++++++++++++++++++++++++
322 Instance startup URI.
324 It supports the following commands: ``PUT``.
331 The URI takes an optional ``force=False|True`` parameter to start the
332 instance if even if secondary disks are failing.
334 It supports the ``dry-run`` argument.
337 ``/2/instances/[instance_name]/tags``
338 +++++++++++++++++++++++++++++++++++++
340 Manages per-instance tags.
342 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
347 Returns a list of tags.
351 ["tag1", "tag2", "tag3"]
358 The request as a list of strings should be ``PUT`` to this URI. The
359 result willl be a job id.
361 It supports the ``dry-run`` argument.
369 In order to delete a set of tags, the DELETE request should be
370 addressed to URI like::
372 /tags?tag=[tag]&tag=[tag]
374 It supports the ``dry-run`` argument.
380 The ``/2/jobs`` resource.
382 It supports the following commands: ``GET``.
387 Returns a dictionary of jobs.
389 Returns: a dictionary with jobs id and uri.
397 It supports the following commands: ``GET``, ``DELETE``.
402 Returns a job status.
404 Returns: a dictionary with job parameters.
408 - id: job ID as a number
409 - status: current job status as a string
410 - ops: involved OpCodes as a list of dictionaries for each
412 - opstatus: OpCodes status as a list
413 - opresult: OpCodes results as a list of lists
418 Cancel a not-yet-started job.
425 It supports the following commands: ``GET``.
430 Returns a list of all nodes.
436 "id": "node1.example.com",
437 "uri": "\/instances\/node1.example.com"
440 "id": "node2.example.com",
441 "uri": "\/instances\/node2.example.com"
445 If the optional 'bulk' argument is provided and set to 'true' value
446 (i.e '?bulk=1'), the output contains detailed information about nodes
456 "name": "www.example.com",
467 ``/2/nodes/[node_name]/evacuate``
468 +++++++++++++++++++++++++++++++++
470 Evacuates all secondary instances off a node.
472 It supports the following commands: ``POST``.
477 To evacuate a node, either one of the ``iallocator`` or ``remote_node``
478 parameters must be passed:
480 evacuate?iallocator=[iallocator]
481 evacuate?remote_node=[nodeX.example.com]
483 ``/2/nodes/[node_name]/migrate``
484 +++++++++++++++++++++++++++++++++
486 Migrates all primary instances from a node.
488 It supports the following commands: ``POST``.
493 No parameters are required, but ``live`` can be set to a boolean value.
497 ``/2/nodes/[node_name]/role``
498 +++++++++++++++++++++++++++++
502 It supports the following commands: ``GET``, ``PUT``.
504 The role is always one of the following:
515 Returns the current node role.
524 Change the node role.
526 The request is a string which should be PUT to this URI. The result will be a
529 It supports the ``force`` argument.
531 ``/2/nodes/[node_name]/storage``
532 ++++++++++++++++++++++++++++++++
534 Manages storage units on the node.
539 Requests a list of storage units on a node. Requires the parameters
540 ``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and
541 ``output_fields``. The result will be a job id, using which the result can be
544 ``/2/nodes/[node_name]/tags``
545 +++++++++++++++++++++++++++++
547 Manages per-node tags.
549 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
554 Returns a list of tags.
558 ["tag1", "tag2", "tag3"]
565 The request as a list of strings should be PUT to this URI. The result
568 It supports the ``dry-run`` argument.
575 In order to delete a set of tags, the DELETE request should be
576 addressed to URI like::
578 /tags?tag=[tag]&tag=[tag]
580 It supports the ``dry-run`` argument.
588 It supports the following commands: ``GET``.
593 Return a list of all OSes.
595 Can return error 500 in case of a problem. Since this is a costly
596 operation for Ganeti 2.0, it is not recommended to execute it too
606 Manages cluster tags.
608 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
613 Returns the cluster tags.
617 ["tag1", "tag2", "tag3"]
624 The request as a list of strings should be PUT to this URI. The result
627 It supports the ``dry-run`` argument.
635 In order to delete a set of tags, the DELETE request should be
636 addressed to URI like::
638 /tags?tag=[tag]&tag=[tag]
640 It supports the ``dry-run`` argument.
646 The version resource.
648 This resource should be used to determine the remote API version and
649 to adapt clients accordingly.
651 It supports the following commands: ``GET``.
656 Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti