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
37 Bulk-mode means that for the resources which usually return just a list
38 of child resources (e.g. ``/2/instances`` which returns just instance
39 names), the output will instead contain detailed data for all these
40 subresources. This is more efficient than query-ing the sub-resources
46 The optional *dry-run* argument, if provided and set to a positive
47 integer value (e.g. ``?dry-run=1``), signals to Ganeti that the job
48 should not be executed, only the pre-execution checks will be done.
50 This is useful in trying to determine (without guarantees though, as in
51 the meantime the cluster state could have changed) if the operation is
52 likely to succeed or at least start executing.
57 Force operation to continue even if it will cause the cluster to become
58 inconsistent (e.g. because there are not enough master candidates).
63 You can access the API using your favorite programming language as long
64 as it supports network connections.
73 wget -q -O - https://CLUSTERNAME:5080/2/info
77 curl https://CLUSTERNAME:5080/2/info
88 f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info')
95 .. warning:: While it's possible to use JavaScript, it poses several
96 potential problems, including browser blocking request due to
97 non-standard ports or different domain names. Fetching the data on
98 the webserver is easier.
100 .. highlight:: javascript
104 var url = 'https://CLUSTERNAME:5080/2/info';
106 var xmlreq = new XMLHttpRequest();
107 xmlreq.onreadystatechange = function () {
108 if (xmlreq.readyState != 4) return;
109 if (xmlreq.status == 200) {
110 info = eval("(" + xmlreq.responseText + ")");
113 alert('Error fetching cluster info');
117 xmlreq.open('GET', url, true);
123 .. highlight:: javascript
130 It supports the following commands: ``GET``.
135 Shows the list of mapped resources.
137 Returns: a dictionary with 'name' and 'uri' keys for each of them.
142 The ``/2`` resource, the root of the version 2 API.
144 It supports the following commands: ``GET``.
149 Show the list of mapped resources.
151 Returns: a dictionary with ``name`` and ``uri`` keys for each of them.
156 Cluster information resource.
158 It supports the following commands: ``GET``.
163 Returns cluster information.
168 "config_version": 2000000,
170 "software_version": "2.0.0~beta2",
171 "os_api_version": 10,
173 "candidate_pool_size": 10,
174 "enabled_hypervisors": [
180 "default_hypervisor": "fake",
181 "master": "node1.example.com",
186 "protocol_version": 20,
189 "auto_balance": true,
197 ``/2/redistribute-config``
198 ++++++++++++++++++++++++++
200 Redistribute configuration to all nodes.
202 It supports the following commands: ``PUT``.
207 Redistribute configuration to all nodes. The result will be a job id.
213 The instances resource.
215 It supports the following commands: ``GET``, ``POST``.
220 Returns a list of all available instances.
226 "name": "web.example.com",
227 "uri": "\/instances\/web.example.com"
230 "name": "mail.example.com",
231 "uri": "\/instances\/mail.example.com"
235 If the optional *bulk* argument is provided and set to a true value (i.e
236 ``?bulk=1``), the output contains detailed information about instances
248 "name": "web.example.com",
249 "tags": ["tag1", "tag2"],
257 "pnode": "node1.example.com",
258 "nic.macs": ["01:23:45:67:89:01"],
259 "snodes": ["node2.example.com"],
260 "disk_template": "drbd",
274 If the optional *dry-run* argument is provided and set to a positive
275 integer valu (e.g. ``?dry-run=1``), the job will not be actually
276 executed, only the pre-execution checks will be done. Query-ing the job
277 result will return, in both dry-run and normal case, the list of nodes
278 selected for the instance.
280 Returns: a job ID that can be used later for polling.
282 ``/2/instances/[instance_name]``
283 ++++++++++++++++++++++++++++++++
285 Instance-specific resource.
287 It supports the following commands: ``GET``, ``DELETE``.
292 Returns information about an instance, similar to the bulk output from
300 It supports the ``dry-run`` argument.
303 ``/2/instances/[instance_name]/info``
304 +++++++++++++++++++++++++++++++++++++++
306 It supports the following commands: ``GET``.
311 Requests detailed information about the instance. An optional parameter,
312 ``static`` (bool), can be set to return only static information from the
313 configuration without querying the instance's nodes. The result will be
317 ``/2/instances/[instance_name]/reboot``
318 +++++++++++++++++++++++++++++++++++++++
320 Reboots URI for an instance.
322 It supports the following commands: ``POST``.
327 Reboots the instance.
329 The URI takes optional ``type=hard|soft|full`` and
330 ``ignore_secondaries=False|True`` parameters.
332 It supports the ``dry-run`` argument.
335 ``/2/instances/[instance_name]/shutdown``
336 +++++++++++++++++++++++++++++++++++++++++
338 Instance shutdown URI.
340 It supports the following commands: ``PUT``.
345 Shutdowns an instance.
347 It supports the ``dry-run`` argument.
350 ``/2/instances/[instance_name]/startup``
351 ++++++++++++++++++++++++++++++++++++++++
353 Instance startup URI.
355 It supports the following commands: ``PUT``.
362 The URI takes an optional ``force=False|True`` parameter to start the
363 instance if even if secondary disks are failing.
365 It supports the ``dry-run`` argument.
367 ``/2/instances/[instance_name]/reinstall``
368 ++++++++++++++++++++++++++++++++++++++++++++++
370 Installs the operating system again.
372 It supports the following commands: ``POST``.
377 Takes the parameters ``os`` (OS template name) and ``nostartup`` (bool).
380 ``/2/instances/[instance_name]/replace-disks``
381 ++++++++++++++++++++++++++++++++++++++++++++++
383 Replaces disks on an instance.
385 It supports the following commands: ``POST``.
390 Takes the parameters ``mode`` (one of ``replace_on_primary``,
391 ``replace_on_secondary``, ``replace_new_secondary`` or
392 ``replace_auto``), ``disks`` (comma separated list of disk indexes),
393 ``remote_node`` and ``iallocator``.
396 ``/2/instances/[instance_name]/tags``
397 +++++++++++++++++++++++++++++++++++++
399 Manages per-instance tags.
401 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
406 Returns a list of tags.
410 ["tag1", "tag2", "tag3"]
417 The request as a list of strings should be ``PUT`` to this URI. The
418 result will be a job id.
420 It supports the ``dry-run`` argument.
428 In order to delete a set of tags, the DELETE request should be addressed
431 /tags?tag=[tag]&tag=[tag]
433 It supports the ``dry-run`` argument.
439 The ``/2/jobs`` resource.
441 It supports the following commands: ``GET``.
446 Returns a dictionary of jobs.
448 Returns: a dictionary with jobs id and uri.
456 It supports the following commands: ``GET``, ``DELETE``.
461 Returns a job status.
463 Returns: a dictionary with job parameters.
467 - id: job ID as a number
468 - status: current job status as a string
469 - ops: involved OpCodes as a list of dictionaries for each opcodes in
471 - opstatus: OpCodes status as a list
472 - opresult: OpCodes results as a list of lists
477 Cancel a not-yet-started job.
484 It supports the following commands: ``GET``.
489 Returns a list of all nodes.
495 "id": "node1.example.com",
496 "uri": "\/instances\/node1.example.com"
499 "id": "node2.example.com",
500 "uri": "\/instances\/node2.example.com"
504 If the optional 'bulk' argument is provided and set to 'true' value (i.e
505 '?bulk=1'), the output contains detailed information about nodes as a
515 "name": "www.example.com",
526 ``/2/nodes/[node_name]``
527 +++++++++++++++++++++++++++++++++
529 Returns information about a node.
531 It supports the following commands: ``GET``.
533 ``/2/nodes/[node_name]/evacuate``
534 +++++++++++++++++++++++++++++++++
536 Evacuates all secondary instances off a node.
538 It supports the following commands: ``POST``.
543 To evacuate a node, either one of the ``iallocator`` or ``remote_node``
544 parameters must be passed:
546 evacuate?iallocator=[iallocator]
547 evacuate?remote_node=[nodeX.example.com]
549 ``/2/nodes/[node_name]/migrate``
550 +++++++++++++++++++++++++++++++++
552 Migrates all primary instances from a node.
554 It supports the following commands: ``POST``.
559 No parameters are required, but ``live`` can be set to a boolean value.
563 ``/2/nodes/[node_name]/role``
564 +++++++++++++++++++++++++++++
568 It supports the following commands: ``GET``, ``PUT``.
570 The role is always one of the following:
581 Returns the current node role.
590 Change the node role.
592 The request is a string which should be PUT to this URI. The result will
595 It supports the ``force`` argument.
597 ``/2/nodes/[node_name]/storage``
598 ++++++++++++++++++++++++++++++++
600 Manages storage units on the node.
605 Requests a list of storage units on a node. Requires the parameters
606 ``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and
607 ``output_fields``. The result will be a job id, using which the result
610 ``/2/nodes/[node_name]/storage/modify``
611 +++++++++++++++++++++++++++++++++++++++
613 Modifies storage units on the node.
618 Modifies parameters of storage units on the node. Requires the
619 parameters ``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``)
620 and ``name`` (name of the storage unit). Parameters can be passed
621 additionally. Currently only ``allocatable`` (bool) is supported. The
622 result will be a job id.
624 ``/2/nodes/[node_name]/storage/repair``
625 +++++++++++++++++++++++++++++++++++++++
627 Repairs a storage unit on the node.
632 Repairs a storage unit on the node. Requires the parameters
633 ``storage_type`` (currently only ``lvm-vg`` can be repaired) and
634 ``name`` (name of the storage unit). The result will be a job id.
636 ``/2/nodes/[node_name]/tags``
637 +++++++++++++++++++++++++++++
639 Manages per-node tags.
641 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
646 Returns a list of tags.
650 ["tag1", "tag2", "tag3"]
657 The request as a list of strings should be PUT to this URI. The result
660 It supports the ``dry-run`` argument.
667 In order to delete a set of tags, the DELETE request should be addressed
670 /tags?tag=[tag]&tag=[tag]
672 It supports the ``dry-run`` argument.
680 It supports the following commands: ``GET``.
685 Return a list of all OSes.
687 Can return error 500 in case of a problem. Since this is a costly
688 operation for Ganeti 2.0, it is not recommended to execute it too often.
697 Manages cluster tags.
699 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
704 Returns the cluster tags.
708 ["tag1", "tag2", "tag3"]
715 The request as a list of strings should be PUT to this URI. The result
718 It supports the ``dry-run`` argument.
726 In order to delete a set of tags, the DELETE request should be addressed
729 /tags?tag=[tag]&tag=[tag]
731 It supports the ``dry-run`` argument.
737 The version resource.
739 This resource should be used to determine the remote API version and to
740 adapt clients accordingly.
742 It supports the following commands: ``GET``.
747 Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti 2.0
750 .. vim: set textwidth=72 :