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
23 ``ganeti-rapi`` reads users and passwords from a file (usually
24 ``/var/lib/ganeti/rapi/users``) on startup. Changes to the file will be
27 Each line consists of two or three fields separated by whitespace. The
28 first two fields are for username and password. The third field is
29 optional and can be used to specify per-user options. Currently,
30 ``write`` is the only option supported and enables the user to execute
31 operations modifying the cluster. Lines starting with the hash sign
32 (``#``) are treated as comments.
34 Passwords can either be written in clear text or as a hash. Clear text
35 passwords may not start with an opening brace (``{``) or they must be
36 prefixed with ``{cleartext}``. To use the hashed form, get the MD5 hash
37 of the string ``$username:Ganeti Remote API:$password`` (e.g. ``echo -n
38 'jack:Ganeti Remote API:abc123' | openssl md5``) [#pwhash]_ and prefix
39 it with ``{ha1}``. Using the scheme prefix for all passwords is
40 recommended. Scheme prefixes are not case sensitive.
44 # Give Jack and Fred read-only access
46 fred {cleartext}foo555
48 # Give write access to an imaginary instance creation script
49 autocreator xyz789 write
51 # Hashed password for Jessica
52 jessica {HA1}7046452df2cbb530877058712cf17bd4 write
55 .. [#pwhash] Using the MD5 hash of username, realm and password is
56 described in :rfc:`2617` ("HTTP Authentication"), sections 3.2.2.2
57 and 3.3. The reason for using it over another algorithm is forward
58 compatibility. If ``ganeti-rapi`` were to implement HTTP Digest
59 authentication in the future, the same hash could be used.
60 In the current version ``ganeti-rapi``'s realm, ``Ganeti Remote
61 API``, can only be changed by modifying the source code.
67 The protocol used is JSON_ over HTTP designed after the REST_ principle.
68 HTTP Basic authentication as per :rfc:`2617` is supported.
70 .. _JSON: http://www.json.org/
71 .. _REST: http://en.wikipedia.org/wiki/Representational_State_Transfer
73 HTTP requests with a body (e.g. ``PUT`` or ``POST``) require the request
74 header ``Content-type`` be set to ``application/json`` (see :rfc:`2616`
75 (HTTP/1.1), section 7.2.1).
78 A note on JSON as used by RAPI
79 ++++++++++++++++++++++++++++++
81 JSON_ as used by Ganeti RAPI does not conform to the specification in
82 :rfc:`4627`. Section 2 defines a JSON text to be either an object
83 (``{"key": "value", …}``) or an array (``[1, 2, 3, …]``). In violation
84 of this RAPI uses plain strings (``"master-candidate"``, ``"1234"``) for
85 some requests or responses. Changing this now would likely break
86 existing clients and cause a lot of trouble.
90 Unlike Python's `JSON encoder and decoder
91 <http://docs.python.org/library/json.html>`_, other programming
92 languages or libraries may only provide a strict implementation, not
93 allowing plain values. For those, responses can usually be wrapped in an
94 array whose first element is then used, e.g. the response ``"1234"``
95 becomes ``["1234"]``. This works equally well for more complex values.
100 # Insert code to get response here
101 response = "\"1234\""
103 decoded = JSON.parse("[#{response}]").first
105 Short of modifying the encoder to allow encoding to a less strict
106 format, requests will have to be formatted by hand. Newer RAPI requests
107 already use a dictionary as their input data and shouldn't cause any
114 According to :rfc:`2616` the main difference between PUT and POST is
115 that POST can create new resources but PUT can only create the resource
116 the URI was pointing to on the PUT request.
118 Unfortunately, due to historic reasons, the Ganeti RAPI library is not
119 consistent with this usage, so just use the methods as documented below
122 For more details have a look in the source code at
123 ``lib/rapi/rlib2.py``.
126 Generic parameter types
127 -----------------------
129 A few generic refered parameter types and the values they allow.
134 A boolean option will accept ``1`` or ``0`` as numbers but not
135 i.e. ``True`` or ``False``.
140 A few parameter mean the same thing across all resources which implement
146 Bulk-mode means that for the resources which usually return just a list
147 of child resources (e.g. ``/2/instances`` which returns just instance
148 names), the output will instead contain detailed data for all these
149 subresources. This is more efficient than query-ing the sub-resources
155 The boolean *dry-run* argument, if provided and set, signals to Ganeti
156 that the job should not be executed, only the pre-execution checks will
159 This is useful in trying to determine (without guarantees though, as in
160 the meantime the cluster state could have changed) if the operation is
161 likely to succeed or at least start executing.
166 Force operation to continue even if it will cause the cluster to become
167 inconsistent (e.g. because there are not enough master candidates).
172 Some parameters are not straight forward, so we describe them in details
180 The instance policy specification is a dict with the following fields:
184 constants.IPOLICY_ALL_KEYS == set([constants.ISPECS_MIN,
185 constants.ISPECS_MAX,
186 constants.ISPECS_STD,
187 constants.IPOLICY_DTS,
188 constants.IPOLICY_VCPU_RATIO,
189 constants.IPOLICY_SPINDLE_RATIO])
194 (set(constants.ISPECS_PARAMETER_TYPES.keys()) ==
195 set([constants.ISPEC_MEM_SIZE,
196 constants.ISPEC_DISK_SIZE,
197 constants.ISPEC_DISK_COUNT,
198 constants.ISPEC_CPU_COUNT,
199 constants.ISPEC_NIC_COUNT,
200 constants.ISPEC_SPINDLE_USE]))
202 .. |ispec-min| replace:: :pyeval:`constants.ISPECS_MIN`
203 .. |ispec-max| replace:: :pyeval:`constants.ISPECS_MAX`
204 .. |ispec-std| replace:: :pyeval:`constants.ISPECS_STD`
207 |ispec-min|, |ispec-max|, |ispec-std|
208 A sub- `dict` with the following fields, which sets the limit and standard
209 values of the instances:
211 :pyeval:`constants.ISPEC_MEM_SIZE`
212 The size in MiB of the memory used
213 :pyeval:`constants.ISPEC_DISK_SIZE`
214 The size in MiB of the disk used
215 :pyeval:`constants.ISPEC_DISK_COUNT`
216 The numbers of disks used
217 :pyeval:`constants.ISPEC_CPU_COUNT`
218 The numbers of cpus used
219 :pyeval:`constants.ISPEC_NIC_COUNT`
220 The numbers of nics used
221 :pyeval:`constants.ISPEC_SPINDLE_USE`
222 The numbers of virtual disk spindles used by this instance. They are
223 not real in the sense of actual HDD spindles, but useful for
224 accounting the spindle usage on the residing node
225 :pyeval:`constants.IPOLICY_DTS`
226 A `list` of disk templates allowed for instances using this policy
227 :pyeval:`constants.IPOLICY_VCPU_RATIO`
228 Maximum ratio of virtual to physical CPUs (`float`)
229 :pyeval:`constants.IPOLICY_SPINDLE_RATIO`
230 Maximum ratio of instances to their node's ``spindle_count`` (`float`)
235 You can access the API using your favorite programming language as long
236 as it supports network connections.
241 Ganeti includes a standalone RAPI client, ``lib/rapi/client.py``.
250 wget -q -O - https://CLUSTERNAME:5080/2/info
254 curl https://CLUSTERNAME:5080/2/info
260 .. highlight:: python
265 f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info')
272 .. warning:: While it's possible to use JavaScript, it poses several
273 potential problems, including browser blocking request due to
274 non-standard ports or different domain names. Fetching the data on
275 the webserver is easier.
277 .. highlight:: javascript
281 var url = 'https://CLUSTERNAME:5080/2/info';
283 var xmlreq = new XMLHttpRequest();
284 xmlreq.onreadystatechange = function () {
285 if (xmlreq.readyState != 4) return;
286 if (xmlreq.status == 200) {
287 info = eval("(" + xmlreq.responseText + ")");
290 alert('Error fetching cluster info');
294 xmlreq.open('GET', url, true);
300 .. highlight:: javascript
305 The root resource. Has no function, but for legacy reasons the ``GET``
311 Has no function, but for legacy reasons the ``GET`` method is supported.
316 Cluster information resource.
318 It supports the following commands: ``GET``.
323 Returns cluster information.
328 "config_version": 2000000,
330 "software_version": "2.0.0~beta2",
331 "os_api_version": 10,
333 "candidate_pool_size": 10,
334 "enabled_hypervisors": [
340 "default_hypervisor": "fake",
341 "master": "node1.example.com",
346 "protocol_version": 20,
349 "auto_balance": true,
357 ``/2/redistribute-config``
358 ++++++++++++++++++++++++++
360 Redistribute configuration to all nodes.
362 It supports the following commands: ``PUT``.
367 Redistribute configuration to all nodes. The result will be a job id.
371 .. opcode_result:: OP_CLUSTER_REDIST_CONF
380 Returns a list of features supported by the RAPI server. Available
385 rlib2.ALL_FEATURES == set([rlib2._INST_CREATE_REQV1,
386 rlib2._INST_REINSTALL_REQV1,
387 rlib2._NODE_MIGRATE_REQV1,
388 rlib2._NODE_EVAC_RES1])
390 :pyeval:`rlib2._INST_CREATE_REQV1`
391 Instance creation request data version 1 supported
392 :pyeval:`rlib2._INST_REINSTALL_REQV1`
393 Instance reinstall supports body parameters
394 :pyeval:`rlib2._NODE_MIGRATE_REQV1`
395 Whether migrating a node (``/2/nodes/[node_name]/migrate``) supports
396 request body parameters
397 :pyeval:`rlib2._NODE_EVAC_RES1`
398 Whether evacuating a node (``/2/nodes/[node_name]/evacuate``) returns
399 a new-style result (see resource description)
403 ++++++++++++++++++++++++++++++++++++++++
405 Modifies cluster parameters.
407 Supports the following commands: ``PUT``.
416 .. opcode_params:: OP_CLUSTER_SET_PARAMS
420 .. opcode_result:: OP_CLUSTER_SET_PARAMS
428 It supports the following commands: ``GET``, ``POST``.
433 Returns a list of all existing node groups.
440 "uri": "\/2\/groups\/group1"
444 "uri": "\/2\/groups\/group2"
448 If the optional bool *bulk* argument is provided and set to a true value
449 (i.e ``?bulk=1``), the output contains detailed information about node
452 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.G_FIELDS))`.
464 "uuid": "0d7d407c-262e-49af-881a-6a430034bf43"
472 "uuid": "f5a277e7-68f9-44d3-a378-4b25ecb5df5c"
479 Creates a node group.
481 If the optional bool *dry-run* argument is provided, the job will not be
482 actually executed, only the pre-execution checks will be done.
484 Returns: a job ID that can be used later for polling.
488 .. opcode_params:: OP_GROUP_ADD
490 Earlier versions used a parameter named ``name`` which, while still
491 supported, has been renamed to ``group_name``.
495 .. opcode_result:: OP_GROUP_ADD
498 ``/2/groups/[group_name]``
499 ++++++++++++++++++++++++++
501 Returns information about a node group.
503 It supports the following commands: ``GET``, ``DELETE``.
508 Returns information about a node group, similar to the bulk output from
511 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.G_FIELDS))`.
516 Deletes a node group.
518 It supports the ``dry-run`` argument.
522 .. opcode_result:: OP_GROUP_REMOVE
525 ``/2/groups/[group_name]/modify``
526 +++++++++++++++++++++++++++++++++
528 Modifies the parameters of a node group.
530 Supports the following commands: ``PUT``.
539 .. opcode_params:: OP_GROUP_SET_PARAMS
544 .. opcode_result:: OP_GROUP_SET_PARAMS
547 ``/2/groups/[group_name]/rename``
548 +++++++++++++++++++++++++++++++++
550 Renames a node group.
552 Supports the following commands: ``PUT``.
561 .. opcode_params:: OP_GROUP_RENAME
566 .. opcode_result:: OP_GROUP_RENAME
569 ``/2/groups/[group_name]/assign-nodes``
570 +++++++++++++++++++++++++++++++++++++++
572 Assigns nodes to a group.
574 Supports the following commands: ``PUT``.
579 Returns a job ID. It supports the ``dry-run`` and ``force`` arguments.
583 .. opcode_params:: OP_GROUP_ASSIGN_NODES
584 :exclude: group_name, force, dry_run
588 .. opcode_result:: OP_GROUP_ASSIGN_NODES
591 ``/2/groups/[group_name]/tags``
592 +++++++++++++++++++++++++++++++
594 Manages per-nodegroup tags.
596 Supports the following commands: ``GET``, ``PUT``, ``DELETE``.
601 Returns a list of tags.
605 ["tag1", "tag2", "tag3"]
612 The request as a list of strings should be ``PUT`` to this URI. The
613 result will be a job id.
615 It supports the ``dry-run`` argument.
623 In order to delete a set of tags, the DELETE request should be addressed
626 /tags?tag=[tag]&tag=[tag]
628 It supports the ``dry-run`` argument.
631 ``/2/instances-multi-alloc``
632 ++++++++++++++++++++++++++++
634 Tries to allocate multiple instances.
636 It supports the following commands: ``POST``
643 .. opcode_params:: OP_INSTANCE_MULTI_ALLOC
647 .. opcode_result:: OP_INSTANCE_MULTI_ALLOC
653 The instances resource.
655 It supports the following commands: ``GET``, ``POST``.
660 Returns a list of all available instances.
666 "name": "web.example.com",
667 "uri": "\/instances\/web.example.com"
670 "name": "mail.example.com",
671 "uri": "\/instances\/mail.example.com"
675 If the optional bool *bulk* argument is provided and set to a true value
676 (i.e ``?bulk=1``), the output contains detailed information about
679 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.I_FIELDS))`.
690 "name": "web.example.com",
691 "tags": ["tag1", "tag2"],
699 "pnode": "node1.example.com",
700 "nic.macs": ["01:23:45:67:89:01"],
701 "snodes": ["node2.example.com"],
702 "disk_template": "drbd",
716 If the optional bool *dry-run* argument is provided, the job will not be
717 actually executed, only the pre-execution checks will be done. Query-ing
718 the job result will return, in both dry-run and normal case, the list of
719 nodes selected for the instance.
721 Returns: a job ID that can be used later for polling.
725 ``__version__`` (int, required)
726 Must be ``1`` (older Ganeti versions used a different format for
727 instance creation requests, version ``0``, but that format is no
730 .. opcode_params:: OP_INSTANCE_CREATE
732 Earlier versions used parameters named ``name`` and ``os``. These have
733 been replaced by ``instance_name`` and ``os_type`` to match the
734 underlying opcode. The old names can still be used.
738 .. opcode_result:: OP_INSTANCE_CREATE
741 ``/2/instances/[instance_name]``
742 ++++++++++++++++++++++++++++++++
744 Instance-specific resource.
746 It supports the following commands: ``GET``, ``DELETE``.
751 Returns information about an instance, similar to the bulk output from
754 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.I_FIELDS))`.
761 It supports the ``dry-run`` argument.
765 .. opcode_result:: OP_INSTANCE_REMOVE
768 ``/2/instances/[instance_name]/info``
769 +++++++++++++++++++++++++++++++++++++++
771 It supports the following commands: ``GET``.
776 Requests detailed information about the instance. An optional parameter,
777 ``static`` (bool), can be set to return only static information from the
778 configuration without querying the instance's nodes. The result will be
783 .. opcode_result:: OP_INSTANCE_QUERY_DATA
786 ``/2/instances/[instance_name]/reboot``
787 +++++++++++++++++++++++++++++++++++++++
789 Reboots URI for an instance.
791 It supports the following commands: ``POST``.
796 Reboots the instance.
798 The URI takes optional ``type=soft|hard|full`` and
799 ``ignore_secondaries=0|1`` parameters.
801 ``type`` defines the reboot type. ``soft`` is just a normal reboot,
802 without terminating the hypervisor. ``hard`` means full shutdown
803 (including terminating the hypervisor process) and startup again.
804 ``full`` is like ``hard`` but also recreates the configuration from
805 ground up as if you would have done a ``gnt-instance shutdown`` and
806 ``gnt-instance start`` on it.
808 ``ignore_secondaries`` is a bool argument indicating if we start the
809 instance even if secondary disks are failing.
811 It supports the ``dry-run`` argument.
815 .. opcode_result:: OP_INSTANCE_REBOOT
818 ``/2/instances/[instance_name]/shutdown``
819 +++++++++++++++++++++++++++++++++++++++++
821 Instance shutdown URI.
823 It supports the following commands: ``PUT``.
828 Shutdowns an instance.
830 It supports the ``dry-run`` argument.
832 .. opcode_params:: OP_INSTANCE_SHUTDOWN
833 :exclude: instance_name, dry_run
837 .. opcode_result:: OP_INSTANCE_SHUTDOWN
840 ``/2/instances/[instance_name]/startup``
841 ++++++++++++++++++++++++++++++++++++++++
843 Instance startup URI.
845 It supports the following commands: ``PUT``.
852 The URI takes an optional ``force=1|0`` parameter to start the
853 instance even if secondary disks are failing.
855 It supports the ``dry-run`` argument.
859 .. opcode_result:: OP_INSTANCE_STARTUP
862 ``/2/instances/[instance_name]/reinstall``
863 ++++++++++++++++++++++++++++++++++++++++++++++
865 Installs the operating system again.
867 It supports the following commands: ``POST``.
876 ``os`` (string, required)
877 Instance operating system.
878 ``start`` (bool, defaults to true)
879 Whether to start instance after reinstallation.
881 Dictionary with (temporary) OS parameters.
883 For backwards compatbility, this resource also takes the query
884 parameters ``os`` (OS template name) and ``nostartup`` (bool). New
885 clients should use the body parameters.
888 ``/2/instances/[instance_name]/replace-disks``
889 ++++++++++++++++++++++++++++++++++++++++++++++
891 Replaces disks on an instance.
893 It supports the following commands: ``POST``.
902 .. opcode_params:: OP_INSTANCE_REPLACE_DISKS
903 :exclude: instance_name
905 Ganeti 2.4 and below used query parameters. Those are deprecated and
906 should no longer be used.
910 .. opcode_result:: OP_INSTANCE_REPLACE_DISKS
913 ``/2/instances/[instance_name]/activate-disks``
914 +++++++++++++++++++++++++++++++++++++++++++++++
916 Activate disks on an instance.
918 It supports the following commands: ``PUT``.
923 Takes the bool parameter ``ignore_size``. When set ignore the recorded
924 size (useful for forcing activation when recorded size is wrong).
928 .. opcode_result:: OP_INSTANCE_ACTIVATE_DISKS
931 ``/2/instances/[instance_name]/deactivate-disks``
932 +++++++++++++++++++++++++++++++++++++++++++++++++
934 Deactivate disks on an instance.
936 It supports the following commands: ``PUT``.
945 .. opcode_result:: OP_INSTANCE_DEACTIVATE_DISKS
948 ``/2/instances/[instance_name]/recreate-disks``
949 +++++++++++++++++++++++++++++++++++++++++++++++++
951 Recreate disks of an instance. Supports the following commands:
961 .. opcode_params:: OP_INSTANCE_RECREATE_DISKS
962 :exclude: instance_name
966 .. opcode_result:: OP_INSTANCE_RECREATE_DISKS
969 ``/2/instances/[instance_name]/disk/[disk_index]/grow``
970 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
972 Grows one disk of an instance.
974 Supports the following commands: ``POST``.
983 .. opcode_params:: OP_INSTANCE_GROW_DISK
984 :exclude: instance_name, disk
988 .. opcode_result:: OP_INSTANCE_GROW_DISK
991 ``/2/instances/[instance_name]/prepare-export``
992 +++++++++++++++++++++++++++++++++++++++++++++++++
994 Prepares an export of an instance.
996 It supports the following commands: ``PUT``.
1001 Takes one parameter, ``mode``, for the export mode. Returns a job ID.
1005 .. opcode_result:: OP_BACKUP_PREPARE
1008 ``/2/instances/[instance_name]/export``
1009 +++++++++++++++++++++++++++++++++++++++++++++++++
1011 Exports an instance.
1013 It supports the following commands: ``PUT``.
1022 .. opcode_params:: OP_BACKUP_EXPORT
1023 :exclude: instance_name
1024 :alias: target_node=destination
1028 .. opcode_result:: OP_BACKUP_EXPORT
1031 ``/2/instances/[instance_name]/migrate``
1032 ++++++++++++++++++++++++++++++++++++++++
1034 Migrates an instance.
1036 Supports the following commands: ``PUT``.
1045 .. opcode_params:: OP_INSTANCE_MIGRATE
1046 :exclude: instance_name, live
1050 .. opcode_result:: OP_INSTANCE_MIGRATE
1053 ``/2/instances/[instance_name]/failover``
1054 +++++++++++++++++++++++++++++++++++++++++
1056 Does a failover of an instance.
1058 Supports the following commands: ``PUT``.
1067 .. opcode_params:: OP_INSTANCE_FAILOVER
1068 :exclude: instance_name
1072 .. opcode_result:: OP_INSTANCE_FAILOVER
1075 ``/2/instances/[instance_name]/rename``
1076 ++++++++++++++++++++++++++++++++++++++++
1078 Renames an instance.
1080 Supports the following commands: ``PUT``.
1089 .. opcode_params:: OP_INSTANCE_RENAME
1090 :exclude: instance_name
1094 .. opcode_result:: OP_INSTANCE_RENAME
1097 ``/2/instances/[instance_name]/modify``
1098 ++++++++++++++++++++++++++++++++++++++++
1100 Modifies an instance.
1102 Supports the following commands: ``PUT``.
1111 .. opcode_params:: OP_INSTANCE_SET_PARAMS
1112 :exclude: instance_name
1116 .. opcode_result:: OP_INSTANCE_SET_PARAMS
1119 ``/2/instances/[instance_name]/console``
1120 ++++++++++++++++++++++++++++++++++++++++
1122 Request information for connecting to instance's console.
1124 Supports the following commands: ``GET``.
1129 Returns a dictionary containing information about the instance's
1130 console. Contained keys:
1134 constants.CONS_ALL == frozenset([
1135 constants.CONS_MESSAGE,
1138 constants.CONS_SPICE,
1144 Console type, one of :pyeval:`constants.CONS_SSH`,
1145 :pyeval:`constants.CONS_VNC`, :pyeval:`constants.CONS_SPICE`
1146 or :pyeval:`constants.CONS_MESSAGE`
1148 Message to display (:pyeval:`constants.CONS_MESSAGE` type only)
1150 Host to connect to (:pyeval:`constants.CONS_SSH`,
1151 :pyeval:`constants.CONS_VNC` or :pyeval:`constants.CONS_SPICE` only)
1153 TCP port to connect to (:pyeval:`constants.CONS_VNC` or
1154 :pyeval:`constants.CONS_SPICE` only)
1156 Username to use (:pyeval:`constants.CONS_SSH` only)
1158 Command to execute on machine (:pyeval:`constants.CONS_SSH` only)
1160 VNC display number (:pyeval:`constants.CONS_VNC` only)
1163 ``/2/instances/[instance_name]/tags``
1164 +++++++++++++++++++++++++++++++++++++
1166 Manages per-instance tags.
1168 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1173 Returns a list of tags.
1177 ["tag1", "tag2", "tag3"]
1184 The request as a list of strings should be ``PUT`` to this URI. The
1185 result will be a job id.
1187 It supports the ``dry-run`` argument.
1195 In order to delete a set of tags, the DELETE request should be addressed
1198 /tags?tag=[tag]&tag=[tag]
1200 It supports the ``dry-run`` argument.
1206 The ``/2/jobs`` resource.
1208 It supports the following commands: ``GET``.
1213 Returns a dictionary of jobs.
1215 Returns: a dictionary with jobs id and uri.
1217 If the optional bool *bulk* argument is provided and set to a true value
1218 (i.e. ``?bulk=1``), the output contains detailed information about jobs
1221 Returned fields for bulk requests (unlike other bulk requests, these
1222 fields are not the same as for per-job requests):
1223 :pyeval:`utils.CommaJoin(sorted(rlib2.J_FIELDS_BULK))`.
1225 ``/2/jobs/[job_id]``
1226 ++++++++++++++++++++
1231 It supports the following commands: ``GET``, ``DELETE``.
1236 Returns a dictionary with job parameters, containing the fields
1237 :pyeval:`utils.CommaJoin(sorted(rlib2.J_FIELDS))`.
1239 The result includes:
1241 - id: job ID as a number
1242 - status: current job status as a string
1243 - ops: involved OpCodes as a list of dictionaries for each opcodes in
1245 - opstatus: OpCodes status as a list
1246 - opresult: OpCodes results as a list
1248 For a successful opcode, the ``opresult`` field corresponding to it will
1249 contain the raw result from its :term:`LogicalUnit`. In case an opcode
1250 has failed, its element in the opresult list will be a list of two
1253 - first element the error type (the Ganeti internal error name)
1254 - second element a list of either one or two elements:
1256 - the first element is the textual error description
1257 - the second element, if any, will hold an error classification
1259 The error classification is most useful for the ``OpPrereqError``
1260 error type - these errors happen before the OpCode has started
1261 executing, so it's possible to retry the OpCode without side
1262 effects. But whether it make sense to retry depends on the error
1267 errors.ECODE_ALL == set([errors.ECODE_RESOLVER, errors.ECODE_NORES,
1268 errors.ECODE_INVAL, errors.ECODE_STATE, errors.ECODE_NOENT,
1269 errors.ECODE_EXISTS, errors.ECODE_NOTUNIQUE, errors.ECODE_FAULT,
1270 errors.ECODE_ENVIRON])
1272 :pyeval:`errors.ECODE_RESOLVER`
1273 Resolver errors. This usually means that a name doesn't exist in DNS,
1274 so if it's a case of slow DNS propagation the operation can be retried
1277 :pyeval:`errors.ECODE_NORES`
1278 Not enough resources (iallocator failure, disk space, memory,
1279 etc.). If the resources on the cluster increase, the operation might
1282 :pyeval:`errors.ECODE_INVAL`
1283 Wrong arguments (at syntax level). The operation will not ever be
1284 accepted unless the arguments change.
1286 :pyeval:`errors.ECODE_STATE`
1287 Wrong entity state. For example, live migration has been requested for
1288 a down instance, or instance creation on an offline node. The
1289 operation can be retried once the resource has changed state.
1291 :pyeval:`errors.ECODE_NOENT`
1292 Entity not found. For example, information has been requested for an
1295 :pyeval:`errors.ECODE_EXISTS`
1296 Entity already exists. For example, instance creation has been
1297 requested for an already-existing instance.
1299 :pyeval:`errors.ECODE_NOTUNIQUE`
1300 Resource not unique (e.g. MAC or IP duplication).
1302 :pyeval:`errors.ECODE_FAULT`
1303 Internal cluster error. For example, a node is unreachable but not set
1304 offline, or the ganeti node daemons are not working, etc. A
1305 ``gnt-cluster verify`` should be run.
1307 :pyeval:`errors.ECODE_ENVIRON`
1308 Environment error (e.g. node disk error). A ``gnt-cluster verify``
1311 Note that in the above list, by entity we refer to a node or instance,
1312 while by a resource we refer to an instance's disk, or NIC, etc.
1318 Cancel a not-yet-started job.
1321 ``/2/jobs/[job_id]/wait``
1322 +++++++++++++++++++++++++
1327 Waits for changes on a job. Takes the following body parameters in a
1331 The job fields on which to watch for changes
1333 ``previous_job_info``
1334 Previously received field values or None if not yet available
1336 ``previous_log_serial``
1337 Highest log serial number received so far or None if not yet
1340 Returns None if no changes have been detected and a dict with two keys,
1341 ``job_info`` and ``log_entries`` otherwise.
1349 It supports the following commands: ``GET``.
1354 Returns a list of all nodes.
1360 "id": "node1.example.com",
1361 "uri": "\/nodes\/node1.example.com"
1364 "id": "node2.example.com",
1365 "uri": "\/nodes\/node2.example.com"
1369 If the optional bool *bulk* argument is provided and set to a true value
1370 (i.e ``?bulk=1``), the output contains detailed information about nodes
1373 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.N_FIELDS))`.
1382 "name": "www.example.com",
1393 ``/2/nodes/[node_name]``
1394 +++++++++++++++++++++++++++++++++
1396 Returns information about a node.
1398 It supports the following commands: ``GET``.
1400 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.N_FIELDS))`.
1402 ``/2/nodes/[node_name]/powercycle``
1403 +++++++++++++++++++++++++++++++++++
1405 Powercycles a node. Supports the following commands: ``POST``.
1414 .. opcode_result:: OP_NODE_POWERCYCLE
1417 ``/2/nodes/[node_name]/evacuate``
1418 +++++++++++++++++++++++++++++++++
1420 Evacuates instances off a node.
1422 It supports the following commands: ``POST``.
1427 Returns a job ID. The result of the job will contain the IDs of the
1428 individual jobs submitted to evacuate the node.
1432 .. opcode_params:: OP_NODE_EVACUATE
1435 Up to and including Ganeti 2.4 query arguments were used. Those are no
1436 longer supported. The new request can be detected by the presence of the
1437 :pyeval:`rlib2._NODE_EVAC_RES1` feature string.
1441 .. opcode_result:: OP_NODE_EVACUATE
1444 ``/2/nodes/[node_name]/migrate``
1445 +++++++++++++++++++++++++++++++++
1447 Migrates all primary instances from a node.
1449 It supports the following commands: ``POST``.
1454 If no mode is explicitly specified, each instances' hypervisor default
1455 migration mode will be used. Body parameters:
1457 .. opcode_params:: OP_NODE_MIGRATE
1460 The query arguments used up to and including Ganeti 2.4 are deprecated
1461 and should no longer be used. The new request format can be detected by
1462 the presence of the :pyeval:`rlib2._NODE_MIGRATE_REQV1` feature string.
1466 .. opcode_result:: OP_NODE_MIGRATE
1469 ``/2/nodes/[node_name]/role``
1470 +++++++++++++++++++++++++++++
1474 It supports the following commands: ``GET``, ``PUT``.
1476 The role is always one of the following:
1483 Note that the 'master' role is a special, and currently it can't be
1484 modified via RAPI, only via the command line (``gnt-cluster
1490 Returns the current node role.
1499 Change the node role.
1501 The request is a string which should be PUT to this URI. The result will
1504 It supports the bool ``force`` argument.
1508 .. opcode_result:: OP_NODE_SET_PARAMS
1511 ``/2/nodes/[node_name]/modify``
1512 +++++++++++++++++++++++++++++++
1514 Modifies the parameters of a node. Supports the following commands:
1524 .. opcode_params:: OP_NODE_SET_PARAMS
1529 .. opcode_result:: OP_NODE_SET_PARAMS
1532 ``/2/nodes/[node_name]/storage``
1533 ++++++++++++++++++++++++++++++++
1535 Manages storage units on the node.
1542 constants.VALID_STORAGE_TYPES == set([constants.ST_FILE,
1543 constants.ST_LVM_PV,
1544 constants.ST_LVM_VG])
1546 Requests a list of storage units on a node. Requires the parameters
1547 ``storage_type`` (one of :pyeval:`constants.ST_FILE`,
1548 :pyeval:`constants.ST_LVM_PV` or :pyeval:`constants.ST_LVM_VG`) and
1549 ``output_fields``. The result will be a job id, using which the result
1552 ``/2/nodes/[node_name]/storage/modify``
1553 +++++++++++++++++++++++++++++++++++++++
1555 Modifies storage units on the node.
1560 Modifies parameters of storage units on the node. Requires the
1561 parameters ``storage_type`` (one of :pyeval:`constants.ST_FILE`,
1562 :pyeval:`constants.ST_LVM_PV` or :pyeval:`constants.ST_LVM_VG`)
1563 and ``name`` (name of the storage unit). Parameters can be passed
1564 additionally. Currently only :pyeval:`constants.SF_ALLOCATABLE` (bool)
1565 is supported. The result will be a job id.
1569 .. opcode_result:: OP_NODE_MODIFY_STORAGE
1572 ``/2/nodes/[node_name]/storage/repair``
1573 +++++++++++++++++++++++++++++++++++++++
1575 Repairs a storage unit on the node.
1582 constants.VALID_STORAGE_OPERATIONS == {
1583 constants.ST_LVM_VG: set([constants.SO_FIX_CONSISTENCY]),
1586 Repairs a storage unit on the node. Requires the parameters
1587 ``storage_type`` (currently only :pyeval:`constants.ST_LVM_VG` can be
1588 repaired) and ``name`` (name of the storage unit). The result will be a
1593 .. opcode_result:: OP_REPAIR_NODE_STORAGE
1596 ``/2/nodes/[node_name]/tags``
1597 +++++++++++++++++++++++++++++
1599 Manages per-node tags.
1601 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1606 Returns a list of tags.
1610 ["tag1", "tag2", "tag3"]
1617 The request as a list of strings should be PUT to this URI. The result
1620 It supports the ``dry-run`` argument.
1627 In order to delete a set of tags, the DELETE request should be addressed
1630 /tags?tag=[tag]&tag=[tag]
1632 It supports the ``dry-run`` argument.
1635 ``/2/query/[resource]``
1636 +++++++++++++++++++++++
1638 Requests resource information. Available fields can be found in man
1639 pages and using ``/2/query/[resource]/fields``. The resource is one of
1640 :pyeval:`utils.CommaJoin(constants.QR_VIA_RAPI)`. See the :doc:`query2
1641 design document <design-query2>` for more details.
1643 Supports the following commands: ``GET``, ``PUT``.
1648 Returns list of included fields and actual data. Takes a query parameter
1649 named "fields", containing a comma-separated list of field names. Does
1650 not support filtering.
1655 Returns list of included fields and actual data. The list of requested
1656 fields can either be given as the query parameter "fields" or as a body
1657 parameter with the same name. The optional body parameter "filter" can
1658 be given and must be either ``null`` or a list containing filter
1662 ``/2/query/[resource]/fields``
1663 ++++++++++++++++++++++++++++++
1665 Request list of available fields for a resource. The resource is one of
1666 :pyeval:`utils.CommaJoin(constants.QR_VIA_RAPI)`. See the
1667 :doc:`query2 design document <design-query2>` for more details.
1669 Supports the following commands: ``GET``.
1674 Returns a list of field descriptions for available fields. Takes an
1675 optional query parameter named "fields", containing a comma-separated
1676 list of field names.
1684 It supports the following commands: ``GET``.
1689 Return a list of all OSes.
1691 Can return error 500 in case of a problem. Since this is a costly
1692 operation for Ganeti 2.0, it is not recommended to execute it too often.
1701 Manages cluster tags.
1703 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1708 Returns the cluster tags.
1712 ["tag1", "tag2", "tag3"]
1719 The request as a list of strings should be PUT to this URI. The result
1722 It supports the ``dry-run`` argument.
1730 In order to delete a set of tags, the DELETE request should be addressed
1733 /tags?tag=[tag]&tag=[tag]
1735 It supports the ``dry-run`` argument.
1741 The version resource.
1743 This resource should be used to determine the remote API version and to
1744 adapt clients accordingly.
1746 It supports the following commands: ``GET``.
1751 Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti 2.0
1754 .. vim: set textwidth=72 :