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 Lines starting with the hash sign (``#``) are treated as comments. Each
28 line consists of two or three fields separated by whitespace. The first
29 two fields are for username and password. The third field is optional
30 and can be used to specify per-user options (separated by comma without
31 spaces). Available options:
35 rapi.RAPI_ACCESS_ALL == set([
36 rapi.RAPI_ACCESS_WRITE,
37 rapi.RAPI_ACCESS_READ,
40 :pyeval:`rapi.RAPI_ACCESS_WRITE`
41 Enables the user to execute operations modifying the cluster. Implies
42 :pyeval:`rapi.RAPI_ACCESS_READ` access.
43 :pyeval:`rapi.RAPI_ACCESS_READ`
44 Allow access to operations querying for information.
46 Passwords can either be written in clear text or as a hash. Clear text
47 passwords may not start with an opening brace (``{``) or they must be
48 prefixed with ``{cleartext}``. To use the hashed form, get the MD5 hash
49 of the string ``$username:Ganeti Remote API:$password`` (e.g. ``echo -n
50 'jack:Ganeti Remote API:abc123' | openssl md5``) [#pwhash]_ and prefix
51 it with ``{ha1}``. Using the scheme prefix for all passwords is
52 recommended. Scheme prefixes are not case sensitive.
56 # Give Jack and Fred read-only access
58 fred {cleartext}foo555
60 # Give write access to an imaginary instance creation script
61 autocreator xyz789 write
63 # Hashed password for Jessica
64 jessica {HA1}7046452df2cbb530877058712cf17bd4 write
66 # Monitoring can query for values
67 monitoring {HA1}ec018ffe72b8e75bb4d508ed5b6d079c query
69 # A user who can query and write
70 superuser {HA1}ec018ffe72b8e75bb4d508ed5b6d079c query,write
73 .. [#pwhash] Using the MD5 hash of username, realm and password is
74 described in :rfc:`2617` ("HTTP Authentication"), sections 3.2.2.2
75 and 3.3. The reason for using it over another algorithm is forward
76 compatibility. If ``ganeti-rapi`` were to implement HTTP Digest
77 authentication in the future, the same hash could be used.
78 In the current version ``ganeti-rapi``'s realm, ``Ganeti Remote
79 API``, can only be changed by modifying the source code.
85 The protocol used is JSON_ over HTTP designed after the REST_ principle.
86 HTTP Basic authentication as per :rfc:`2617` is supported.
88 .. _JSON: http://www.json.org/
89 .. _REST: http://en.wikipedia.org/wiki/Representational_State_Transfer
91 HTTP requests with a body (e.g. ``PUT`` or ``POST``) require the request
92 header ``Content-type`` be set to ``application/json`` (see :rfc:`2616`
93 (HTTP/1.1), section 7.2.1).
96 A note on JSON as used by RAPI
97 ++++++++++++++++++++++++++++++
99 JSON_ as used by Ganeti RAPI does not conform to the specification in
100 :rfc:`4627`. Section 2 defines a JSON text to be either an object
101 (``{"key": "value", …}``) or an array (``[1, 2, 3, …]``). In violation
102 of this RAPI uses plain strings (``"master-candidate"``, ``"1234"``) for
103 some requests or responses. Changing this now would likely break
104 existing clients and cause a lot of trouble.
108 Unlike Python's `JSON encoder and decoder
109 <http://docs.python.org/library/json.html>`_, other programming
110 languages or libraries may only provide a strict implementation, not
111 allowing plain values. For those, responses can usually be wrapped in an
112 array whose first element is then used, e.g. the response ``"1234"``
113 becomes ``["1234"]``. This works equally well for more complex values.
118 # Insert code to get response here
119 response = "\"1234\""
121 decoded = JSON.parse("[#{response}]").first
123 Short of modifying the encoder to allow encoding to a less strict
124 format, requests will have to be formatted by hand. Newer RAPI requests
125 already use a dictionary as their input data and shouldn't cause any
132 According to :rfc:`2616` the main difference between PUT and POST is
133 that POST can create new resources but PUT can only create the resource
134 the URI was pointing to on the PUT request.
136 Unfortunately, due to historic reasons, the Ganeti RAPI library is not
137 consistent with this usage, so just use the methods as documented below
140 For more details have a look in the source code at
141 ``lib/rapi/rlib2.py``.
144 Generic parameter types
145 -----------------------
147 A few generic refered parameter types and the values they allow.
152 A boolean option will accept ``1`` or ``0`` as numbers but not
153 i.e. ``True`` or ``False``.
158 A few parameter mean the same thing across all resources which implement
164 Bulk-mode means that for the resources which usually return just a list
165 of child resources (e.g. ``/2/instances`` which returns just instance
166 names), the output will instead contain detailed data for all these
167 subresources. This is more efficient than query-ing the sub-resources
173 The boolean *dry-run* argument, if provided and set, signals to Ganeti
174 that the job should not be executed, only the pre-execution checks will
177 This is useful in trying to determine (without guarantees though, as in
178 the meantime the cluster state could have changed) if the operation is
179 likely to succeed or at least start executing.
184 Force operation to continue even if it will cause the cluster to become
185 inconsistent (e.g. because there are not enough master candidates).
190 Some parameters are not straight forward, so we describe them in details
198 The instance policy specification is a dict with the following fields:
202 constants.IPOLICY_ALL_KEYS == set([constants.ISPECS_MIN,
203 constants.ISPECS_MAX,
204 constants.ISPECS_STD,
205 constants.IPOLICY_DTS,
206 constants.IPOLICY_VCPU_RATIO,
207 constants.IPOLICY_SPINDLE_RATIO])
212 (set(constants.ISPECS_PARAMETER_TYPES.keys()) ==
213 set([constants.ISPEC_MEM_SIZE,
214 constants.ISPEC_DISK_SIZE,
215 constants.ISPEC_DISK_COUNT,
216 constants.ISPEC_CPU_COUNT,
217 constants.ISPEC_NIC_COUNT,
218 constants.ISPEC_SPINDLE_USE]))
220 .. |ispec-min| replace:: :pyeval:`constants.ISPECS_MIN`
221 .. |ispec-max| replace:: :pyeval:`constants.ISPECS_MAX`
222 .. |ispec-std| replace:: :pyeval:`constants.ISPECS_STD`
225 |ispec-min|, |ispec-max|, |ispec-std|
226 A sub- `dict` with the following fields, which sets the limit and standard
227 values of the instances:
229 :pyeval:`constants.ISPEC_MEM_SIZE`
230 The size in MiB of the memory used
231 :pyeval:`constants.ISPEC_DISK_SIZE`
232 The size in MiB of the disk used
233 :pyeval:`constants.ISPEC_DISK_COUNT`
234 The numbers of disks used
235 :pyeval:`constants.ISPEC_CPU_COUNT`
236 The numbers of cpus used
237 :pyeval:`constants.ISPEC_NIC_COUNT`
238 The numbers of nics used
239 :pyeval:`constants.ISPEC_SPINDLE_USE`
240 The numbers of virtual disk spindles used by this instance. They are
241 not real in the sense of actual HDD spindles, but useful for
242 accounting the spindle usage on the residing node
243 :pyeval:`constants.IPOLICY_DTS`
244 A `list` of disk templates allowed for instances using this policy
245 :pyeval:`constants.IPOLICY_VCPU_RATIO`
246 Maximum ratio of virtual to physical CPUs (`float`)
247 :pyeval:`constants.IPOLICY_SPINDLE_RATIO`
248 Maximum ratio of instances to their node's ``spindle_count`` (`float`)
253 You can access the API using your favorite programming language as long
254 as it supports network connections.
259 Ganeti includes a standalone RAPI client, ``lib/rapi/client.py``.
264 .. highlight:: shell-example
268 $ wget -q -O - https://%CLUSTERNAME%:5080/2/info
272 $ curl https://%CLUSTERNAME%:5080/2/info
278 .. highlight:: python
283 f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info')
290 .. warning:: While it's possible to use JavaScript, it poses several
291 potential problems, including browser blocking request due to
292 non-standard ports or different domain names. Fetching the data on
293 the webserver is easier.
295 .. highlight:: javascript
299 var url = 'https://CLUSTERNAME:5080/2/info';
301 var xmlreq = new XMLHttpRequest();
302 xmlreq.onreadystatechange = function () {
303 if (xmlreq.readyState != 4) return;
304 if (xmlreq.status == 200) {
305 info = eval("(" + xmlreq.responseText + ")");
308 alert('Error fetching cluster info');
312 xmlreq.open('GET', url, true);
318 .. highlight:: javascript
323 The root resource. Has no function, but for legacy reasons the ``GET``
329 Has no function, but for legacy reasons the ``GET`` method is supported.
334 Cluster information resource.
336 It supports the following commands: ``GET``.
341 Returns cluster information.
346 "config_version": 2000000,
348 "software_version": "2.0.0~beta2",
349 "os_api_version": 10,
351 "candidate_pool_size": 10,
352 "enabled_hypervisors": [
358 "default_hypervisor": "fake",
359 "master": "node1.example.com",
364 "protocol_version": 20,
367 "auto_balance": true,
376 ``/2/redistribute-config``
377 ++++++++++++++++++++++++++
379 Redistribute configuration to all nodes.
381 It supports the following commands: ``PUT``.
386 Redistribute configuration to all nodes. The result will be a job id.
390 .. opcode_result:: OP_CLUSTER_REDIST_CONF
399 Returns a list of features supported by the RAPI server. Available
404 rlib2.ALL_FEATURES == set([rlib2._INST_CREATE_REQV1,
405 rlib2._INST_REINSTALL_REQV1,
406 rlib2._NODE_MIGRATE_REQV1,
407 rlib2._NODE_EVAC_RES1])
409 :pyeval:`rlib2._INST_CREATE_REQV1`
410 Instance creation request data version 1 supported
411 :pyeval:`rlib2._INST_REINSTALL_REQV1`
412 Instance reinstall supports body parameters
413 :pyeval:`rlib2._NODE_MIGRATE_REQV1`
414 Whether migrating a node (``/2/nodes/[node_name]/migrate``) supports
415 request body parameters
416 :pyeval:`rlib2._NODE_EVAC_RES1`
417 Whether evacuating a node (``/2/nodes/[node_name]/evacuate``) returns
418 a new-style result (see resource description)
422 ++++++++++++++++++++++++++++++++++++++++
424 Modifies cluster parameters.
426 Supports the following commands: ``PUT``.
435 .. opcode_params:: OP_CLUSTER_SET_PARAMS
439 .. opcode_result:: OP_CLUSTER_SET_PARAMS
447 It supports the following commands: ``GET``, ``POST``.
452 Returns a list of all existing node groups.
459 "uri": "\/2\/groups\/group1"
463 "uri": "\/2\/groups\/group2"
467 If the optional bool *bulk* argument is provided and set to a true value
468 (i.e ``?bulk=1``), the output contains detailed information about node
471 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.G_FIELDS))`.
483 "uuid": "0d7d407c-262e-49af-881a-6a430034bf43",
492 "uuid": "f5a277e7-68f9-44d3-a378-4b25ecb5df5c",
501 Creates a node group.
503 If the optional bool *dry-run* argument is provided, the job will not be
504 actually executed, only the pre-execution checks will be done.
506 Returns: a job ID that can be used later for polling.
510 .. opcode_params:: OP_GROUP_ADD
512 Earlier versions used a parameter named ``name`` which, while still
513 supported, has been renamed to ``group_name``.
517 .. opcode_result:: OP_GROUP_ADD
520 ``/2/groups/[group_name]``
521 ++++++++++++++++++++++++++
523 Returns information about a node group.
525 It supports the following commands: ``GET``, ``DELETE``.
530 Returns information about a node group, similar to the bulk output from
533 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.G_FIELDS))`.
538 Deletes a node group.
540 It supports the ``dry-run`` argument.
544 .. opcode_result:: OP_GROUP_REMOVE
547 ``/2/groups/[group_name]/modify``
548 +++++++++++++++++++++++++++++++++
550 Modifies the parameters of a node group.
552 Supports the following commands: ``PUT``.
561 .. opcode_params:: OP_GROUP_SET_PARAMS
566 .. opcode_result:: OP_GROUP_SET_PARAMS
569 ``/2/groups/[group_name]/rename``
570 +++++++++++++++++++++++++++++++++
572 Renames a node group.
574 Supports the following commands: ``PUT``.
583 .. opcode_params:: OP_GROUP_RENAME
588 .. opcode_result:: OP_GROUP_RENAME
591 ``/2/groups/[group_name]/assign-nodes``
592 +++++++++++++++++++++++++++++++++++++++
594 Assigns nodes to a group.
596 Supports the following commands: ``PUT``.
601 Returns a job ID. It supports the ``dry-run`` and ``force`` arguments.
605 .. opcode_params:: OP_GROUP_ASSIGN_NODES
606 :exclude: group_name, force, dry_run
610 .. opcode_result:: OP_GROUP_ASSIGN_NODES
613 ``/2/groups/[group_name]/tags``
614 +++++++++++++++++++++++++++++++
616 Manages per-nodegroup tags.
618 Supports the following commands: ``GET``, ``PUT``, ``DELETE``.
623 Returns a list of tags.
627 ["tag1", "tag2", "tag3"]
634 The request as a list of strings should be ``PUT`` to this URI. The
635 result will be a job id.
637 It supports the ``dry-run`` argument.
645 In order to delete a set of tags, the DELETE request should be addressed
648 /tags?tag=[tag]&tag=[tag]
650 It supports the ``dry-run`` argument.
656 The networks resource.
658 It supports the following commands: ``GET``, ``POST``.
663 Returns a list of all existing networks.
670 "uri": "\/2\/networks\/network1"
674 "uri": "\/2\/networks\/network2"
678 If the optional bool *bulk* argument is provided and set to a true value
679 (i.e ``?bulk=1``), the output contains detailed information about networks
682 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.NET_FIELDS))`.
688 'external_reservations': '10.0.0.0, 10.0.0.1, 10.0.0.15',
690 'gateway': '10.0.0.1',
692 'group_list': ['default(bridged, prv0)'],
695 'map': 'XX.............X',
697 'network': '10.0.0.0/28',
699 'network_type': 'private',
712 If the optional bool *dry-run* argument is provided, the job will not be
713 actually executed, only the pre-execution checks will be done.
715 Returns: a job ID that can be used later for polling.
719 .. opcode_params:: OP_NETWORK_ADD
723 .. opcode_result:: OP_NETWORK_ADD
726 ``/2/networks/[network_name]``
727 ++++++++++++++++++++++++++++++
729 Returns information about a network.
731 It supports the following commands: ``GET``, ``DELETE``.
736 Returns information about a network, similar to the bulk output from
739 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.NET_FIELDS))`.
746 It supports the ``dry-run`` argument.
750 .. opcode_result:: OP_NETWORK_REMOVE
753 ``/2/networks/[network_name]/modify``
754 +++++++++++++++++++++++++++++++++++++
756 Modifies the parameters of a network.
758 Supports the following commands: ``PUT``.
767 .. opcode_params:: OP_NETWORK_SET_PARAMS
771 .. opcode_result:: OP_NETWORK_SET_PARAMS
774 ``/2/networks/[network_name]/connect``
775 ++++++++++++++++++++++++++++++++++++++
777 Connects a network to a nodegroup.
779 Supports the following commands: ``PUT``.
784 Returns a job ID. It supports the ``dry-run`` arguments.
788 .. opcode_params:: OP_NETWORK_CONNECT
792 .. opcode_result:: OP_NETWORK_CONNECT
795 ``/2/networks/[network_name]/disconnect``
796 +++++++++++++++++++++++++++++++++++++++++
798 Disonnects a network from a nodegroup.
800 Supports the following commands: ``PUT``.
805 Returns a job ID. It supports the ``dry-run`` arguments.
809 .. opcode_params:: OP_NETWORK_DISCONNECT
813 .. opcode_result:: OP_NETWORK_DISCONNECT
816 ``/2/networks/[network_name]/tags``
817 +++++++++++++++++++++++++++++++++++
819 Manages per-network tags.
821 Supports the following commands: ``GET``, ``PUT``, ``DELETE``.
826 Returns a list of tags.
830 ["tag1", "tag2", "tag3"]
837 The request as a list of strings should be ``PUT`` to this URI. The
838 result will be a job id.
840 It supports the ``dry-run`` argument.
848 In order to delete a set of tags, the DELETE request should be addressed
851 /tags?tag=[tag]&tag=[tag]
853 It supports the ``dry-run`` argument.
856 ``/2/instances-multi-alloc``
857 ++++++++++++++++++++++++++++
859 Tries to allocate multiple instances.
861 It supports the following commands: ``POST``
868 .. opcode_params:: OP_INSTANCE_MULTI_ALLOC
872 .. opcode_result:: OP_INSTANCE_MULTI_ALLOC
878 The instances resource.
880 It supports the following commands: ``GET``, ``POST``.
885 Returns a list of all available instances.
891 "name": "web.example.com",
892 "uri": "\/instances\/web.example.com"
895 "name": "mail.example.com",
896 "uri": "\/instances\/mail.example.com"
900 If the optional bool *bulk* argument is provided and set to a true value
901 (i.e ``?bulk=1``), the output contains detailed information about
904 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.I_FIELDS))`.
915 "name": "web.example.com",
916 "tags": ["tag1", "tag2"],
924 "pnode": "node1.example.com",
925 "nic.macs": ["01:23:45:67:89:01"],
926 "snodes": ["node2.example.com"],
927 "disk_template": "drbd",
942 If the optional bool *dry-run* argument is provided, the job will not be
943 actually executed, only the pre-execution checks will be done. Query-ing
944 the job result will return, in both dry-run and normal case, the list of
945 nodes selected for the instance.
947 Returns: a job ID that can be used later for polling.
951 ``__version__`` (int, required)
952 Must be ``1`` (older Ganeti versions used a different format for
953 instance creation requests, version ``0``, but that format is no
956 .. opcode_params:: OP_INSTANCE_CREATE
958 Earlier versions used parameters named ``name`` and ``os``. These have
959 been replaced by ``instance_name`` and ``os_type`` to match the
960 underlying opcode. The old names can still be used.
964 .. opcode_result:: OP_INSTANCE_CREATE
967 ``/2/instances/[instance_name]``
968 ++++++++++++++++++++++++++++++++
970 Instance-specific resource.
972 It supports the following commands: ``GET``, ``DELETE``.
977 Returns information about an instance, similar to the bulk output from
980 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.I_FIELDS))`.
987 It supports the ``dry-run`` argument.
991 .. opcode_result:: OP_INSTANCE_REMOVE
994 ``/2/instances/[instance_name]/info``
995 +++++++++++++++++++++++++++++++++++++++
997 It supports the following commands: ``GET``.
1002 Requests detailed information about the instance. An optional parameter,
1003 ``static`` (bool), can be set to return only static information from the
1004 configuration without querying the instance's nodes. The result will be
1009 .. opcode_result:: OP_INSTANCE_QUERY_DATA
1012 ``/2/instances/[instance_name]/reboot``
1013 +++++++++++++++++++++++++++++++++++++++
1015 Reboots URI for an instance.
1017 It supports the following commands: ``POST``.
1022 Reboots the instance.
1024 The URI takes optional ``type=soft|hard|full`` and
1025 ``ignore_secondaries=0|1`` parameters.
1027 ``type`` defines the reboot type. ``soft`` is just a normal reboot,
1028 without terminating the hypervisor. ``hard`` means full shutdown
1029 (including terminating the hypervisor process) and startup again.
1030 ``full`` is like ``hard`` but also recreates the configuration from
1031 ground up as if you would have done a ``gnt-instance shutdown`` and
1032 ``gnt-instance start`` on it.
1034 ``ignore_secondaries`` is a bool argument indicating if we start the
1035 instance even if secondary disks are failing.
1037 It supports the ``dry-run`` argument.
1041 .. opcode_result:: OP_INSTANCE_REBOOT
1044 ``/2/instances/[instance_name]/shutdown``
1045 +++++++++++++++++++++++++++++++++++++++++
1047 Instance shutdown URI.
1049 It supports the following commands: ``PUT``.
1054 Shutdowns an instance.
1056 It supports the ``dry-run`` argument.
1058 .. opcode_params:: OP_INSTANCE_SHUTDOWN
1059 :exclude: instance_name, dry_run
1063 .. opcode_result:: OP_INSTANCE_SHUTDOWN
1066 ``/2/instances/[instance_name]/startup``
1067 ++++++++++++++++++++++++++++++++++++++++
1069 Instance startup URI.
1071 It supports the following commands: ``PUT``.
1076 Startup an instance.
1078 The URI takes an optional ``force=1|0`` parameter to start the
1079 instance even if secondary disks are failing.
1081 It supports the ``dry-run`` argument.
1085 .. opcode_result:: OP_INSTANCE_STARTUP
1088 ``/2/instances/[instance_name]/reinstall``
1089 ++++++++++++++++++++++++++++++++++++++++++++++
1091 Installs the operating system again.
1093 It supports the following commands: ``POST``.
1102 ``os`` (string, required)
1103 Instance operating system.
1104 ``start`` (bool, defaults to true)
1105 Whether to start instance after reinstallation.
1107 Dictionary with (temporary) OS parameters.
1109 For backwards compatbility, this resource also takes the query
1110 parameters ``os`` (OS template name) and ``nostartup`` (bool). New
1111 clients should use the body parameters.
1114 ``/2/instances/[instance_name]/replace-disks``
1115 ++++++++++++++++++++++++++++++++++++++++++++++
1117 Replaces disks on an instance.
1119 It supports the following commands: ``POST``.
1128 .. opcode_params:: OP_INSTANCE_REPLACE_DISKS
1129 :exclude: instance_name
1131 Ganeti 2.4 and below used query parameters. Those are deprecated and
1132 should no longer be used.
1136 .. opcode_result:: OP_INSTANCE_REPLACE_DISKS
1139 ``/2/instances/[instance_name]/activate-disks``
1140 +++++++++++++++++++++++++++++++++++++++++++++++
1142 Activate disks on an instance.
1144 It supports the following commands: ``PUT``.
1149 Takes the bool parameter ``ignore_size``. When set ignore the recorded
1150 size (useful for forcing activation when recorded size is wrong).
1154 .. opcode_result:: OP_INSTANCE_ACTIVATE_DISKS
1157 ``/2/instances/[instance_name]/deactivate-disks``
1158 +++++++++++++++++++++++++++++++++++++++++++++++++
1160 Deactivate disks on an instance.
1162 It supports the following commands: ``PUT``.
1167 Takes no parameters.
1171 .. opcode_result:: OP_INSTANCE_DEACTIVATE_DISKS
1174 ``/2/instances/[instance_name]/recreate-disks``
1175 +++++++++++++++++++++++++++++++++++++++++++++++++
1177 Recreate disks of an instance. Supports the following commands:
1187 .. opcode_params:: OP_INSTANCE_RECREATE_DISKS
1188 :exclude: instance_name
1192 .. opcode_result:: OP_INSTANCE_RECREATE_DISKS
1195 ``/2/instances/[instance_name]/disk/[disk_index]/grow``
1196 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1198 Grows one disk of an instance.
1200 Supports the following commands: ``POST``.
1209 .. opcode_params:: OP_INSTANCE_GROW_DISK
1210 :exclude: instance_name, disk
1214 .. opcode_result:: OP_INSTANCE_GROW_DISK
1217 ``/2/instances/[instance_name]/prepare-export``
1218 +++++++++++++++++++++++++++++++++++++++++++++++++
1220 Prepares an export of an instance.
1222 It supports the following commands: ``PUT``.
1227 Takes one parameter, ``mode``, for the export mode. Returns a job ID.
1231 .. opcode_result:: OP_BACKUP_PREPARE
1234 ``/2/instances/[instance_name]/export``
1235 +++++++++++++++++++++++++++++++++++++++++++++++++
1237 Exports an instance.
1239 It supports the following commands: ``PUT``.
1248 .. opcode_params:: OP_BACKUP_EXPORT
1249 :exclude: instance_name
1250 :alias: target_node=destination
1254 .. opcode_result:: OP_BACKUP_EXPORT
1257 ``/2/instances/[instance_name]/migrate``
1258 ++++++++++++++++++++++++++++++++++++++++
1260 Migrates an instance.
1262 Supports the following commands: ``PUT``.
1271 .. opcode_params:: OP_INSTANCE_MIGRATE
1272 :exclude: instance_name, live
1276 .. opcode_result:: OP_INSTANCE_MIGRATE
1279 ``/2/instances/[instance_name]/failover``
1280 +++++++++++++++++++++++++++++++++++++++++
1282 Does a failover of an instance.
1284 Supports the following commands: ``PUT``.
1293 .. opcode_params:: OP_INSTANCE_FAILOVER
1294 :exclude: instance_name
1298 .. opcode_result:: OP_INSTANCE_FAILOVER
1301 ``/2/instances/[instance_name]/rename``
1302 ++++++++++++++++++++++++++++++++++++++++
1304 Renames an instance.
1306 Supports the following commands: ``PUT``.
1315 .. opcode_params:: OP_INSTANCE_RENAME
1316 :exclude: instance_name
1320 .. opcode_result:: OP_INSTANCE_RENAME
1323 ``/2/instances/[instance_name]/modify``
1324 ++++++++++++++++++++++++++++++++++++++++
1326 Modifies an instance.
1328 Supports the following commands: ``PUT``.
1337 .. opcode_params:: OP_INSTANCE_SET_PARAMS
1338 :exclude: instance_name
1342 .. opcode_result:: OP_INSTANCE_SET_PARAMS
1345 ``/2/instances/[instance_name]/console``
1346 ++++++++++++++++++++++++++++++++++++++++
1348 Request information for connecting to instance's console.
1352 not (hasattr(rlib2.R_2_instances_name_console, "PUT") or
1353 hasattr(rlib2.R_2_instances_name_console, "POST") or
1354 hasattr(rlib2.R_2_instances_name_console, "DELETE"))
1356 Supports the following commands: ``GET``. Requires authentication with
1357 one of the following options:
1358 :pyeval:`utils.CommaJoin(rlib2.R_2_instances_name_console.GET_ACCESS)`.
1363 Returns a dictionary containing information about the instance's
1364 console. Contained keys:
1368 constants.CONS_ALL == frozenset([
1369 constants.CONS_MESSAGE,
1372 constants.CONS_SPICE,
1378 Console type, one of :pyeval:`constants.CONS_SSH`,
1379 :pyeval:`constants.CONS_VNC`, :pyeval:`constants.CONS_SPICE`
1380 or :pyeval:`constants.CONS_MESSAGE`
1382 Message to display (:pyeval:`constants.CONS_MESSAGE` type only)
1384 Host to connect to (:pyeval:`constants.CONS_SSH`,
1385 :pyeval:`constants.CONS_VNC` or :pyeval:`constants.CONS_SPICE` only)
1387 TCP port to connect to (:pyeval:`constants.CONS_VNC` or
1388 :pyeval:`constants.CONS_SPICE` only)
1390 Username to use (:pyeval:`constants.CONS_SSH` only)
1392 Command to execute on machine (:pyeval:`constants.CONS_SSH` only)
1394 VNC display number (:pyeval:`constants.CONS_VNC` only)
1397 ``/2/instances/[instance_name]/tags``
1398 +++++++++++++++++++++++++++++++++++++
1400 Manages per-instance tags.
1402 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1407 Returns a list of tags.
1411 ["tag1", "tag2", "tag3"]
1418 The request as a list of strings should be ``PUT`` to this URI. The
1419 result will be a job id.
1421 It supports the ``dry-run`` argument.
1429 In order to delete a set of tags, the DELETE request should be addressed
1432 /tags?tag=[tag]&tag=[tag]
1434 It supports the ``dry-run`` argument.
1440 The ``/2/jobs`` resource.
1442 It supports the following commands: ``GET``.
1447 Returns a dictionary of jobs.
1449 Returns: a dictionary with jobs id and uri.
1451 If the optional bool *bulk* argument is provided and set to a true value
1452 (i.e. ``?bulk=1``), the output contains detailed information about jobs
1455 Returned fields for bulk requests (unlike other bulk requests, these
1456 fields are not the same as for per-job requests):
1457 :pyeval:`utils.CommaJoin(sorted(rlib2.J_FIELDS_BULK))`.
1459 ``/2/jobs/[job_id]``
1460 ++++++++++++++++++++
1465 It supports the following commands: ``GET``, ``DELETE``.
1470 Returns a dictionary with job parameters, containing the fields
1471 :pyeval:`utils.CommaJoin(sorted(rlib2.J_FIELDS))`.
1473 The result includes:
1475 - id: job ID as a number
1476 - status: current job status as a string
1477 - ops: involved OpCodes as a list of dictionaries for each opcodes in
1479 - opstatus: OpCodes status as a list
1480 - opresult: OpCodes results as a list
1482 For a successful opcode, the ``opresult`` field corresponding to it will
1483 contain the raw result from its :term:`LogicalUnit`. In case an opcode
1484 has failed, its element in the opresult list will be a list of two
1487 - first element the error type (the Ganeti internal error name)
1488 - second element a list of either one or two elements:
1490 - the first element is the textual error description
1491 - the second element, if any, will hold an error classification
1493 The error classification is most useful for the ``OpPrereqError``
1494 error type - these errors happen before the OpCode has started
1495 executing, so it's possible to retry the OpCode without side
1496 effects. But whether it make sense to retry depends on the error
1501 errors.ECODE_ALL == set([errors.ECODE_RESOLVER, errors.ECODE_NORES,
1502 errors.ECODE_INVAL, errors.ECODE_STATE, errors.ECODE_NOENT,
1503 errors.ECODE_EXISTS, errors.ECODE_NOTUNIQUE, errors.ECODE_FAULT,
1504 errors.ECODE_ENVIRON])
1506 :pyeval:`errors.ECODE_RESOLVER`
1507 Resolver errors. This usually means that a name doesn't exist in DNS,
1508 so if it's a case of slow DNS propagation the operation can be retried
1511 :pyeval:`errors.ECODE_NORES`
1512 Not enough resources (iallocator failure, disk space, memory,
1513 etc.). If the resources on the cluster increase, the operation might
1516 :pyeval:`errors.ECODE_INVAL`
1517 Wrong arguments (at syntax level). The operation will not ever be
1518 accepted unless the arguments change.
1520 :pyeval:`errors.ECODE_STATE`
1521 Wrong entity state. For example, live migration has been requested for
1522 a down instance, or instance creation on an offline node. The
1523 operation can be retried once the resource has changed state.
1525 :pyeval:`errors.ECODE_NOENT`
1526 Entity not found. For example, information has been requested for an
1529 :pyeval:`errors.ECODE_EXISTS`
1530 Entity already exists. For example, instance creation has been
1531 requested for an already-existing instance.
1533 :pyeval:`errors.ECODE_NOTUNIQUE`
1534 Resource not unique (e.g. MAC or IP duplication).
1536 :pyeval:`errors.ECODE_FAULT`
1537 Internal cluster error. For example, a node is unreachable but not set
1538 offline, or the ganeti node daemons are not working, etc. A
1539 ``gnt-cluster verify`` should be run.
1541 :pyeval:`errors.ECODE_ENVIRON`
1542 Environment error (e.g. node disk error). A ``gnt-cluster verify``
1545 Note that in the above list, by entity we refer to a node or instance,
1546 while by a resource we refer to an instance's disk, or NIC, etc.
1552 Cancel a not-yet-started job.
1555 ``/2/jobs/[job_id]/wait``
1556 +++++++++++++++++++++++++
1561 Waits for changes on a job. Takes the following body parameters in a
1565 The job fields on which to watch for changes
1567 ``previous_job_info``
1568 Previously received field values or None if not yet available
1570 ``previous_log_serial``
1571 Highest log serial number received so far or None if not yet
1574 Returns None if no changes have been detected and a dict with two keys,
1575 ``job_info`` and ``log_entries`` otherwise.
1583 It supports the following commands: ``GET``.
1588 Returns a list of all nodes.
1594 "id": "node1.example.com",
1595 "uri": "\/nodes\/node1.example.com"
1598 "id": "node2.example.com",
1599 "uri": "\/nodes\/node2.example.com"
1603 If the optional bool *bulk* argument is provided and set to a true value
1604 (i.e ``?bulk=1``), the output contains detailed information about nodes
1607 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.N_FIELDS))`.
1616 "name": "www.example.com",
1628 ``/2/nodes/[node_name]``
1629 +++++++++++++++++++++++++++++++++
1631 Returns information about a node.
1633 It supports the following commands: ``GET``.
1635 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.N_FIELDS))`.
1637 ``/2/nodes/[node_name]/powercycle``
1638 +++++++++++++++++++++++++++++++++++
1640 Powercycles a node. Supports the following commands: ``POST``.
1649 .. opcode_result:: OP_NODE_POWERCYCLE
1652 ``/2/nodes/[node_name]/evacuate``
1653 +++++++++++++++++++++++++++++++++
1655 Evacuates instances off a node.
1657 It supports the following commands: ``POST``.
1662 Returns a job ID. The result of the job will contain the IDs of the
1663 individual jobs submitted to evacuate the node.
1667 .. opcode_params:: OP_NODE_EVACUATE
1670 Up to and including Ganeti 2.4 query arguments were used. Those are no
1671 longer supported. The new request can be detected by the presence of the
1672 :pyeval:`rlib2._NODE_EVAC_RES1` feature string.
1676 .. opcode_result:: OP_NODE_EVACUATE
1679 ``/2/nodes/[node_name]/migrate``
1680 +++++++++++++++++++++++++++++++++
1682 Migrates all primary instances from a node.
1684 It supports the following commands: ``POST``.
1689 If no mode is explicitly specified, each instances' hypervisor default
1690 migration mode will be used. Body parameters:
1692 .. opcode_params:: OP_NODE_MIGRATE
1695 The query arguments used up to and including Ganeti 2.4 are deprecated
1696 and should no longer be used. The new request format can be detected by
1697 the presence of the :pyeval:`rlib2._NODE_MIGRATE_REQV1` feature string.
1701 .. opcode_result:: OP_NODE_MIGRATE
1704 ``/2/nodes/[node_name]/role``
1705 +++++++++++++++++++++++++++++
1709 It supports the following commands: ``GET``, ``PUT``.
1711 The role is always one of the following:
1718 Note that the 'master' role is a special, and currently it can't be
1719 modified via RAPI, only via the command line (``gnt-cluster
1725 Returns the current node role.
1734 Change the node role.
1736 The request is a string which should be PUT to this URI. The result will
1739 It supports the bool ``force`` argument.
1743 .. opcode_result:: OP_NODE_SET_PARAMS
1746 ``/2/nodes/[node_name]/modify``
1747 +++++++++++++++++++++++++++++++
1749 Modifies the parameters of a node. Supports the following commands:
1759 .. opcode_params:: OP_NODE_SET_PARAMS
1764 .. opcode_result:: OP_NODE_SET_PARAMS
1767 ``/2/nodes/[node_name]/storage``
1768 ++++++++++++++++++++++++++++++++
1770 Manages storage units on the node.
1777 constants.VALID_STORAGE_TYPES == set([constants.ST_FILE,
1778 constants.ST_LVM_PV,
1779 constants.ST_LVM_VG])
1781 Requests a list of storage units on a node. Requires the parameters
1782 ``storage_type`` (one of :pyeval:`constants.ST_FILE`,
1783 :pyeval:`constants.ST_LVM_PV` or :pyeval:`constants.ST_LVM_VG`) and
1784 ``output_fields``. The result will be a job id, using which the result
1787 ``/2/nodes/[node_name]/storage/modify``
1788 +++++++++++++++++++++++++++++++++++++++
1790 Modifies storage units on the node.
1795 Modifies parameters of storage units on the node. Requires the
1796 parameters ``storage_type`` (one of :pyeval:`constants.ST_FILE`,
1797 :pyeval:`constants.ST_LVM_PV` or :pyeval:`constants.ST_LVM_VG`)
1798 and ``name`` (name of the storage unit). Parameters can be passed
1799 additionally. Currently only :pyeval:`constants.SF_ALLOCATABLE` (bool)
1800 is supported. The result will be a job id.
1804 .. opcode_result:: OP_NODE_MODIFY_STORAGE
1807 ``/2/nodes/[node_name]/storage/repair``
1808 +++++++++++++++++++++++++++++++++++++++
1810 Repairs a storage unit on the node.
1817 constants.VALID_STORAGE_OPERATIONS == {
1818 constants.ST_LVM_VG: set([constants.SO_FIX_CONSISTENCY]),
1821 Repairs a storage unit on the node. Requires the parameters
1822 ``storage_type`` (currently only :pyeval:`constants.ST_LVM_VG` can be
1823 repaired) and ``name`` (name of the storage unit). The result will be a
1828 .. opcode_result:: OP_REPAIR_NODE_STORAGE
1831 ``/2/nodes/[node_name]/tags``
1832 +++++++++++++++++++++++++++++
1834 Manages per-node tags.
1836 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1841 Returns a list of tags.
1845 ["tag1", "tag2", "tag3"]
1852 The request as a list of strings should be PUT to this URI. The result
1855 It supports the ``dry-run`` argument.
1862 In order to delete a set of tags, the DELETE request should be addressed
1865 /tags?tag=[tag]&tag=[tag]
1867 It supports the ``dry-run`` argument.
1870 ``/2/query/[resource]``
1871 +++++++++++++++++++++++
1873 Requests resource information. Available fields can be found in man
1874 pages and using ``/2/query/[resource]/fields``. The resource is one of
1875 :pyeval:`utils.CommaJoin(constants.QR_VIA_RAPI)`. See the :doc:`query2
1876 design document <design-query2>` for more details.
1880 (rlib2.R_2_query.GET_ACCESS == rlib2.R_2_query.PUT_ACCESS and
1881 not (hasattr(rlib2.R_2_query, "POST") or
1882 hasattr(rlib2.R_2_query, "DELETE")))
1884 Supports the following commands: ``GET``, ``PUT``. Requires
1885 authentication with one of the following options:
1886 :pyeval:`utils.CommaJoin(rlib2.R_2_query.GET_ACCESS)`.
1891 Returns list of included fields and actual data. Takes a query parameter
1892 named "fields", containing a comma-separated list of field names. Does
1893 not support filtering.
1898 Returns list of included fields and actual data. The list of requested
1899 fields can either be given as the query parameter "fields" or as a body
1900 parameter with the same name. The optional body parameter "filter" can
1901 be given and must be either ``null`` or a list containing filter
1905 ``/2/query/[resource]/fields``
1906 ++++++++++++++++++++++++++++++
1908 Request list of available fields for a resource. The resource is one of
1909 :pyeval:`utils.CommaJoin(constants.QR_VIA_RAPI)`. See the
1910 :doc:`query2 design document <design-query2>` for more details.
1912 Supports the following commands: ``GET``.
1917 Returns a list of field descriptions for available fields. Takes an
1918 optional query parameter named "fields", containing a comma-separated
1919 list of field names.
1927 It supports the following commands: ``GET``.
1932 Return a list of all OSes.
1934 Can return error 500 in case of a problem. Since this is a costly
1935 operation for Ganeti 2.0, it is not recommended to execute it too often.
1944 Manages cluster tags.
1946 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1951 Returns the cluster tags.
1955 ["tag1", "tag2", "tag3"]
1962 The request as a list of strings should be PUT to this URI. The result
1965 It supports the ``dry-run`` argument.
1973 In order to delete a set of tags, the DELETE request should be addressed
1976 /tags?tag=[tag]&tag=[tag]
1978 It supports the ``dry-run`` argument.
1984 The version resource.
1986 This resource should be used to determine the remote API version and to
1987 adapt clients accordingly.
1989 It supports the following commands: ``GET``.
1994 Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti 2.0
1997 .. vim: set textwidth=72 :