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, but useful for account the spindle usage on the residing
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.
634 The instances resource.
636 It supports the following commands: ``GET``, ``POST``.
641 Returns a list of all available instances.
647 "name": "web.example.com",
648 "uri": "\/instances\/web.example.com"
651 "name": "mail.example.com",
652 "uri": "\/instances\/mail.example.com"
656 If the optional bool *bulk* argument is provided and set to a true value
657 (i.e ``?bulk=1``), the output contains detailed information about
660 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.I_FIELDS))`
671 "name": "web.example.com",
672 "tags": ["tag1", "tag2"],
680 "pnode": "node1.example.com",
681 "nic.macs": ["01:23:45:67:89:01"],
682 "snodes": ["node2.example.com"],
683 "disk_template": "drbd",
697 If the optional bool *dry-run* argument is provided, the job will not be
698 actually executed, only the pre-execution checks will be done. Query-ing
699 the job result will return, in both dry-run and normal case, the list of
700 nodes selected for the instance.
702 Returns: a job ID that can be used later for polling.
706 ``__version__`` (int, required)
707 Must be ``1`` (older Ganeti versions used a different format for
708 instance creation requests, version ``0``, but that format is no
711 .. opcode_params:: OP_INSTANCE_CREATE
713 Earlier versions used parameters named ``name`` and ``os``. These have
714 been replaced by ``instance_name`` and ``os_type`` to match the
715 underlying opcode. The old names can still be used.
719 .. opcode_result:: OP_INSTANCE_CREATE
722 ``/2/instances/[instance_name]``
723 ++++++++++++++++++++++++++++++++
725 Instance-specific resource.
727 It supports the following commands: ``GET``, ``DELETE``.
732 Returns information about an instance, similar to the bulk output from
735 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.I_FIELDS))`
742 It supports the ``dry-run`` argument.
746 .. opcode_result:: OP_INSTANCE_REMOVE
749 ``/2/instances/[instance_name]/info``
750 +++++++++++++++++++++++++++++++++++++++
752 It supports the following commands: ``GET``.
757 Requests detailed information about the instance. An optional parameter,
758 ``static`` (bool), can be set to return only static information from the
759 configuration without querying the instance's nodes. The result will be
764 .. opcode_result:: OP_INSTANCE_QUERY_DATA
767 ``/2/instances/[instance_name]/reboot``
768 +++++++++++++++++++++++++++++++++++++++
770 Reboots URI for an instance.
772 It supports the following commands: ``POST``.
777 Reboots the instance.
779 The URI takes optional ``type=soft|hard|full`` and
780 ``ignore_secondaries=0|1`` parameters.
782 ``type`` defines the reboot type. ``soft`` is just a normal reboot,
783 without terminating the hypervisor. ``hard`` means full shutdown
784 (including terminating the hypervisor process) and startup again.
785 ``full`` is like ``hard`` but also recreates the configuration from
786 ground up as if you would have done a ``gnt-instance shutdown`` and
787 ``gnt-instance start`` on it.
789 ``ignore_secondaries`` is a bool argument indicating if we start the
790 instance even if secondary disks are failing.
792 It supports the ``dry-run`` argument.
796 .. opcode_result:: OP_INSTANCE_REBOOT
799 ``/2/instances/[instance_name]/shutdown``
800 +++++++++++++++++++++++++++++++++++++++++
802 Instance shutdown URI.
804 It supports the following commands: ``PUT``.
809 Shutdowns an instance.
811 It supports the ``dry-run`` argument.
813 .. opcode_params:: OP_INSTANCE_SHUTDOWN
814 :exclude: instance_name, dry_run
818 .. opcode_result:: OP_INSTANCE_SHUTDOWN
821 ``/2/instances/[instance_name]/startup``
822 ++++++++++++++++++++++++++++++++++++++++
824 Instance startup URI.
826 It supports the following commands: ``PUT``.
833 The URI takes an optional ``force=1|0`` parameter to start the
834 instance even if secondary disks are failing.
836 It supports the ``dry-run`` argument.
840 .. opcode_result:: OP_INSTANCE_STARTUP
843 ``/2/instances/[instance_name]/reinstall``
844 ++++++++++++++++++++++++++++++++++++++++++++++
846 Installs the operating system again.
848 It supports the following commands: ``POST``.
857 ``os`` (string, required)
858 Instance operating system.
859 ``start`` (bool, defaults to true)
860 Whether to start instance after reinstallation.
862 Dictionary with (temporary) OS parameters.
864 For backwards compatbility, this resource also takes the query
865 parameters ``os`` (OS template name) and ``nostartup`` (bool). New
866 clients should use the body parameters.
869 ``/2/instances/[instance_name]/replace-disks``
870 ++++++++++++++++++++++++++++++++++++++++++++++
872 Replaces disks on an instance.
874 It supports the following commands: ``POST``.
883 .. opcode_params:: OP_INSTANCE_REPLACE_DISKS
884 :exclude: instance_name
886 Ganeti 2.4 and below used query parameters. Those are deprecated and
887 should no longer be used.
891 .. opcode_result:: OP_INSTANCE_REPLACE_DISKS
894 ``/2/instances/[instance_name]/activate-disks``
895 +++++++++++++++++++++++++++++++++++++++++++++++
897 Activate disks on an instance.
899 It supports the following commands: ``PUT``.
904 Takes the bool parameter ``ignore_size``. When set ignore the recorded
905 size (useful for forcing activation when recorded size is wrong).
909 .. opcode_result:: OP_INSTANCE_ACTIVATE_DISKS
912 ``/2/instances/[instance_name]/deactivate-disks``
913 +++++++++++++++++++++++++++++++++++++++++++++++++
915 Deactivate disks on an instance.
917 It supports the following commands: ``PUT``.
926 .. opcode_result:: OP_INSTANCE_DEACTIVATE_DISKS
929 ``/2/instances/[instance_name]/recreate-disks``
930 +++++++++++++++++++++++++++++++++++++++++++++++++
932 Recreate disks of an instance. Supports the following commands:
942 .. opcode_params:: OP_INSTANCE_RECREATE_DISKS
943 :exclude: instance_name
947 .. opcode_result:: OP_INSTANCE_RECREATE_DISKS
950 ``/2/instances/[instance_name]/disk/[disk_index]/grow``
951 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
953 Grows one disk of an instance.
955 Supports the following commands: ``POST``.
964 .. opcode_params:: OP_INSTANCE_GROW_DISK
965 :exclude: instance_name, disk
969 .. opcode_result:: OP_INSTANCE_GROW_DISK
972 ``/2/instances/[instance_name]/prepare-export``
973 +++++++++++++++++++++++++++++++++++++++++++++++++
975 Prepares an export of an instance.
977 It supports the following commands: ``PUT``.
982 Takes one parameter, ``mode``, for the export mode. Returns a job ID.
986 .. opcode_result:: OP_BACKUP_PREPARE
989 ``/2/instances/[instance_name]/export``
990 +++++++++++++++++++++++++++++++++++++++++++++++++
994 It supports the following commands: ``PUT``.
1003 .. opcode_params:: OP_BACKUP_EXPORT
1004 :exclude: instance_name
1005 :alias: target_node=destination
1009 .. opcode_result:: OP_BACKUP_EXPORT
1012 ``/2/instances/[instance_name]/migrate``
1013 ++++++++++++++++++++++++++++++++++++++++
1015 Migrates an instance.
1017 Supports the following commands: ``PUT``.
1026 .. opcode_params:: OP_INSTANCE_MIGRATE
1027 :exclude: instance_name, live
1031 .. opcode_result:: OP_INSTANCE_MIGRATE
1034 ``/2/instances/[instance_name]/failover``
1035 +++++++++++++++++++++++++++++++++++++++++
1037 Does a failover of an instance.
1039 Supports the following commands: ``PUT``.
1048 .. opcode_params:: OP_INSTANCE_FAILOVER
1049 :exclude: instance_name
1053 .. opcode_result:: OP_INSTANCE_FAILOVER
1056 ``/2/instances/[instance_name]/rename``
1057 ++++++++++++++++++++++++++++++++++++++++
1059 Renames an instance.
1061 Supports the following commands: ``PUT``.
1070 .. opcode_params:: OP_INSTANCE_RENAME
1071 :exclude: instance_name
1075 .. opcode_result:: OP_INSTANCE_RENAME
1078 ``/2/instances/[instance_name]/modify``
1079 ++++++++++++++++++++++++++++++++++++++++
1081 Modifies an instance.
1083 Supports the following commands: ``PUT``.
1092 .. opcode_params:: OP_INSTANCE_SET_PARAMS
1093 :exclude: instance_name
1097 .. opcode_result:: OP_INSTANCE_SET_PARAMS
1100 ``/2/instances/[instance_name]/console``
1101 ++++++++++++++++++++++++++++++++++++++++
1103 Request information for connecting to instance's console.
1105 Supports the following commands: ``GET``.
1110 Returns a dictionary containing information about the instance's
1111 console. Contained keys:
1115 constants.CONS_ALL == frozenset([
1116 constants.CONS_MESSAGE,
1119 constants.CONS_SPICE,
1125 Console type, one of :pyeval:`constants.CONS_SSH`,
1126 :pyeval:`constants.CONS_VNC`, :pyeval:`constants.CONS_SPICE`
1127 or :pyeval:`constants.CONS_MESSAGE`.
1129 Message to display (:pyeval:`constants.CONS_MESSAGE` type only).
1131 Host to connect to (:pyeval:`constants.CONS_SSH`,
1132 :pyeval:`constants.CONS_VNC` or :pyeval:`constants.CONS_SPICE` only).
1134 TCP port to connect to (:pyeval:`constants.CONS_VNC` or
1135 :pyeval:`constants.CONS_SPICE` only).
1137 Username to use (:pyeval:`constants.CONS_SSH` only).
1139 Command to execute on machine (:pyeval:`constants.CONS_SSH` only)
1141 VNC display number (:pyeval:`constants.CONS_VNC` only).
1144 ``/2/instances/[instance_name]/tags``
1145 +++++++++++++++++++++++++++++++++++++
1147 Manages per-instance tags.
1149 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1154 Returns a list of tags.
1158 ["tag1", "tag2", "tag3"]
1165 The request as a list of strings should be ``PUT`` to this URI. The
1166 result will be a job id.
1168 It supports the ``dry-run`` argument.
1176 In order to delete a set of tags, the DELETE request should be addressed
1179 /tags?tag=[tag]&tag=[tag]
1181 It supports the ``dry-run`` argument.
1187 The ``/2/jobs`` resource.
1189 It supports the following commands: ``GET``.
1194 Returns a dictionary of jobs.
1196 Returns: a dictionary with jobs id and uri.
1198 If the optional bool *bulk* argument is provided and set to a true value
1199 (i.e. ``?bulk=1``), the output contains detailed information about jobs
1202 Returned fields for bulk requests (unlike other bulk requests, these
1203 fields are not the same as for per-job requests):
1204 :pyeval:`utils.CommaJoin(sorted(rlib2.J_FIELDS_BULK))`
1206 ``/2/jobs/[job_id]``
1207 ++++++++++++++++++++
1212 It supports the following commands: ``GET``, ``DELETE``.
1217 Returns a dictionary with job parameters, containing the fields
1218 :pyeval:`utils.CommaJoin(sorted(rlib2.J_FIELDS))`.
1220 The result includes:
1222 - id: job ID as a number
1223 - status: current job status as a string
1224 - ops: involved OpCodes as a list of dictionaries for each opcodes in
1226 - opstatus: OpCodes status as a list
1227 - opresult: OpCodes results as a list
1229 For a successful opcode, the ``opresult`` field corresponding to it will
1230 contain the raw result from its :term:`LogicalUnit`. In case an opcode
1231 has failed, its element in the opresult list will be a list of two
1234 - first element the error type (the Ganeti internal error name)
1235 - second element a list of either one or two elements:
1237 - the first element is the textual error description
1238 - the second element, if any, will hold an error classification
1240 The error classification is most useful for the ``OpPrereqError``
1241 error type - these errors happen before the OpCode has started
1242 executing, so it's possible to retry the OpCode without side
1243 effects. But whether it make sense to retry depends on the error
1248 errors.ECODE_ALL == set([errors.ECODE_RESOLVER, errors.ECODE_NORES,
1249 errors.ECODE_INVAL, errors.ECODE_STATE, errors.ECODE_NOENT,
1250 errors.ECODE_EXISTS, errors.ECODE_NOTUNIQUE, errors.ECODE_FAULT,
1251 errors.ECODE_ENVIRON])
1253 :pyeval:`errors.ECODE_RESOLVER`
1254 Resolver errors. This usually means that a name doesn't exist in DNS,
1255 so if it's a case of slow DNS propagation the operation can be retried
1258 :pyeval:`errors.ECODE_NORES`
1259 Not enough resources (iallocator failure, disk space, memory,
1260 etc.). If the resources on the cluster increase, the operation might
1263 :pyeval:`errors.ECODE_INVAL`
1264 Wrong arguments (at syntax level). The operation will not ever be
1265 accepted unless the arguments change.
1267 :pyeval:`errors.ECODE_STATE`
1268 Wrong entity state. For example, live migration has been requested for
1269 a down instance, or instance creation on an offline node. The
1270 operation can be retried once the resource has changed state.
1272 :pyeval:`errors.ECODE_NOENT`
1273 Entity not found. For example, information has been requested for an
1276 :pyeval:`errors.ECODE_EXISTS`
1277 Entity already exists. For example, instance creation has been
1278 requested for an already-existing instance.
1280 :pyeval:`errors.ECODE_NOTUNIQUE`
1281 Resource not unique (e.g. MAC or IP duplication).
1283 :pyeval:`errors.ECODE_FAULT`
1284 Internal cluster error. For example, a node is unreachable but not set
1285 offline, or the ganeti node daemons are not working, etc. A
1286 ``gnt-cluster verify`` should be run.
1288 :pyeval:`errors.ECODE_ENVIRON`
1289 Environment error (e.g. node disk error). A ``gnt-cluster verify``
1292 Note that in the above list, by entity we refer to a node or instance,
1293 while by a resource we refer to an instance's disk, or NIC, etc.
1299 Cancel a not-yet-started job.
1302 ``/2/jobs/[job_id]/wait``
1303 +++++++++++++++++++++++++
1308 Waits for changes on a job. Takes the following body parameters in a
1312 The job fields on which to watch for changes.
1314 ``previous_job_info``
1315 Previously received field values or None if not yet available.
1317 ``previous_log_serial``
1318 Highest log serial number received so far or None if not yet
1321 Returns None if no changes have been detected and a dict with two keys,
1322 ``job_info`` and ``log_entries`` otherwise.
1330 It supports the following commands: ``GET``.
1335 Returns a list of all nodes.
1341 "id": "node1.example.com",
1342 "uri": "\/nodes\/node1.example.com"
1345 "id": "node2.example.com",
1346 "uri": "\/nodes\/node2.example.com"
1350 If the optional bool *bulk* argument is provided and set to a true value
1351 (i.e ``?bulk=1``), the output contains detailed information about nodes
1354 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.N_FIELDS))`
1363 "name": "www.example.com",
1374 ``/2/nodes/[node_name]``
1375 +++++++++++++++++++++++++++++++++
1377 Returns information about a node.
1379 It supports the following commands: ``GET``.
1381 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.N_FIELDS))`
1383 ``/2/nodes/[node_name]/powercycle``
1384 +++++++++++++++++++++++++++++++++++
1386 Powercycles a node. Supports the following commands: ``POST``.
1395 .. opcode_result:: OP_NODE_POWERCYCLE
1398 ``/2/nodes/[node_name]/evacuate``
1399 +++++++++++++++++++++++++++++++++
1401 Evacuates instances off a node.
1403 It supports the following commands: ``POST``.
1408 Returns a job ID. The result of the job will contain the IDs of the
1409 individual jobs submitted to evacuate the node.
1413 .. opcode_params:: OP_NODE_EVACUATE
1416 Up to and including Ganeti 2.4 query arguments were used. Those are no
1417 longer supported. The new request can be detected by the presence of the
1418 :pyeval:`rlib2._NODE_EVAC_RES1` feature string.
1422 .. opcode_result:: OP_NODE_EVACUATE
1425 ``/2/nodes/[node_name]/migrate``
1426 +++++++++++++++++++++++++++++++++
1428 Migrates all primary instances from a node.
1430 It supports the following commands: ``POST``.
1435 If no mode is explicitly specified, each instances' hypervisor default
1436 migration mode will be used. Body parameters:
1438 .. opcode_params:: OP_NODE_MIGRATE
1441 The query arguments used up to and including Ganeti 2.4 are deprecated
1442 and should no longer be used. The new request format can be detected by
1443 the presence of the :pyeval:`rlib2._NODE_MIGRATE_REQV1` feature string.
1447 .. opcode_result:: OP_NODE_MIGRATE
1450 ``/2/nodes/[node_name]/role``
1451 +++++++++++++++++++++++++++++
1455 It supports the following commands: ``GET``, ``PUT``.
1457 The role is always one of the following:
1464 Note that the 'master' role is a special, and currently it can't be
1465 modified via RAPI, only via the command line (``gnt-cluster
1471 Returns the current node role.
1480 Change the node role.
1482 The request is a string which should be PUT to this URI. The result will
1485 It supports the bool ``force`` argument.
1489 .. opcode_result:: OP_NODE_SET_PARAMS
1492 ``/2/nodes/[node_name]/modify``
1493 +++++++++++++++++++++++++++++++
1495 Modifies the parameters of a node. Supports the following commands:
1505 .. opcode_params:: OP_NODE_SET_PARAMS
1510 .. opcode_result:: OP_NODE_SET_PARAMS
1513 ``/2/nodes/[node_name]/storage``
1514 ++++++++++++++++++++++++++++++++
1516 Manages storage units on the node.
1523 constants.VALID_STORAGE_TYPES == set([constants.ST_FILE,
1524 constants.ST_LVM_PV,
1525 constants.ST_LVM_VG])
1527 Requests a list of storage units on a node. Requires the parameters
1528 ``storage_type`` (one of :pyeval:`constants.ST_FILE`,
1529 :pyeval:`constants.ST_LVM_PV` or :pyeval:`constants.ST_LVM_VG`) and
1530 ``output_fields``. The result will be a job id, using which the result
1533 ``/2/nodes/[node_name]/storage/modify``
1534 +++++++++++++++++++++++++++++++++++++++
1536 Modifies storage units on the node.
1541 Modifies parameters of storage units on the node. Requires the
1542 parameters ``storage_type`` (one of :pyeval:`constants.ST_FILE`,
1543 :pyeval:`constants.ST_LVM_PV` or :pyeval:`constants.ST_LVM_VG`)
1544 and ``name`` (name of the storage unit). Parameters can be passed
1545 additionally. Currently only :pyeval:`constants.SF_ALLOCATABLE` (bool)
1546 is supported. The result will be a job id.
1550 .. opcode_result:: OP_NODE_MODIFY_STORAGE
1553 ``/2/nodes/[node_name]/storage/repair``
1554 +++++++++++++++++++++++++++++++++++++++
1556 Repairs a storage unit on the node.
1563 constants.VALID_STORAGE_OPERATIONS == {
1564 constants.ST_LVM_VG: set([constants.SO_FIX_CONSISTENCY]),
1567 Repairs a storage unit on the node. Requires the parameters
1568 ``storage_type`` (currently only :pyeval:`constants.ST_LVM_VG` can be
1569 repaired) and ``name`` (name of the storage unit). The result will be a
1574 .. opcode_result:: OP_REPAIR_NODE_STORAGE
1577 ``/2/nodes/[node_name]/tags``
1578 +++++++++++++++++++++++++++++
1580 Manages per-node tags.
1582 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1587 Returns a list of tags.
1591 ["tag1", "tag2", "tag3"]
1598 The request as a list of strings should be PUT to this URI. The result
1601 It supports the ``dry-run`` argument.
1608 In order to delete a set of tags, the DELETE request should be addressed
1611 /tags?tag=[tag]&tag=[tag]
1613 It supports the ``dry-run`` argument.
1616 ``/2/query/[resource]``
1617 +++++++++++++++++++++++
1619 Requests resource information. Available fields can be found in man
1620 pages and using ``/2/query/[resource]/fields``. The resource is one of
1621 :pyeval:`utils.CommaJoin(constants.QR_VIA_RAPI)`. See the :doc:`query2
1622 design document <design-query2>` for more details.
1624 Supports the following commands: ``GET``, ``PUT``.
1629 Returns list of included fields and actual data. Takes a query parameter
1630 named "fields", containing a comma-separated list of field names. Does
1631 not support filtering.
1636 Returns list of included fields and actual data. The list of requested
1637 fields can either be given as the query parameter "fields" or as a body
1638 parameter with the same name. The optional body parameter "filter" can
1639 be given and must be either ``null`` or a list containing filter
1643 ``/2/query/[resource]/fields``
1644 ++++++++++++++++++++++++++++++
1646 Request list of available fields for a resource. The resource is one of
1647 :pyeval:`utils.CommaJoin(constants.QR_VIA_RAPI)`. See the
1648 :doc:`query2 design document <design-query2>` for more details.
1650 Supports the following commands: ``GET``.
1655 Returns a list of field descriptions for available fields. Takes an
1656 optional query parameter named "fields", containing a comma-separated
1657 list of field names.
1665 It supports the following commands: ``GET``.
1670 Return a list of all OSes.
1672 Can return error 500 in case of a problem. Since this is a costly
1673 operation for Ganeti 2.0, it is not recommended to execute it too often.
1682 Manages cluster tags.
1684 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1689 Returns the cluster tags.
1693 ["tag1", "tag2", "tag3"]
1700 The request as a list of strings should be PUT to this URI. The result
1703 It supports the ``dry-run`` argument.
1711 In order to delete a set of tags, the DELETE request should be addressed
1714 /tags?tag=[tag]&tag=[tag]
1716 It supports the ``dry-run`` argument.
1722 The version resource.
1724 This resource should be used to determine the remote API version and to
1725 adapt clients accordingly.
1727 It supports the following commands: ``GET``.
1732 Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti 2.0
1735 .. vim: set textwidth=72 :