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
24 ``ganeti-rapi`` reads users and passwords from a file (usually
25 ``/var/lib/ganeti/rapi/users``) on startup. Changes to the file will be
28 Lines starting with the hash sign (``#``) are treated as comments. Each
29 line consists of two or three fields separated by whitespace. The first
30 two fields are for username and password. The third field is optional
31 and can be used to specify per-user options (separated by comma without
32 spaces). Available options:
36 rapi.RAPI_ACCESS_ALL == set([
37 rapi.RAPI_ACCESS_WRITE,
38 rapi.RAPI_ACCESS_READ,
41 :pyeval:`rapi.RAPI_ACCESS_WRITE`
42 Enables the user to execute operations modifying the cluster. Implies
43 :pyeval:`rapi.RAPI_ACCESS_READ` access.
44 :pyeval:`rapi.RAPI_ACCESS_READ`
45 Allow access to operations querying for information.
47 Passwords can either be written in clear text or as a hash. Clear text
48 passwords may not start with an opening brace (``{``) or they must be
49 prefixed with ``{cleartext}``. To use the hashed form, get the MD5 hash
50 of the string ``$username:Ganeti Remote API:$password`` (e.g. ``echo -n
51 'jack:Ganeti Remote API:abc123' | openssl md5``) [#pwhash]_ and prefix
52 it with ``{ha1}``. Using the scheme prefix for all passwords is
53 recommended. Scheme prefixes are not case sensitive.
57 # Give Jack and Fred read-only access
59 fred {cleartext}foo555
61 # Give write access to an imaginary instance creation script
62 autocreator xyz789 write
64 # Hashed password for Jessica
65 jessica {HA1}7046452df2cbb530877058712cf17bd4 write
67 # Monitoring can query for values
68 monitoring {HA1}ec018ffe72b8e75bb4d508ed5b6d079c read
70 # A user who can read and write (the former is implied by granting
72 superuser {HA1}ec018ffe72b8e75bb4d508ed5b6d079c read,write
74 When using the RAPI, username and password can be sent to the server
75 by using the standard HTTP basic access authentication. This means that
76 for accessing the protected URL ``https://cluster.example.com/resource``,
77 the address ``https://username:password@cluster.example.com/resource`` should
78 be used instead. Alternatively, the appropriate parameter of your HTTP client
79 (such as ``-u`` for ``curl``) can be used.
81 .. [#pwhash] Using the MD5 hash of username, realm and password is
82 described in :rfc:`2617` ("HTTP Authentication"), sections 3.2.2.2
83 and 3.3. The reason for using it over another algorithm is forward
84 compatibility. If ``ganeti-rapi`` were to implement HTTP Digest
85 authentication in the future, the same hash could be used.
86 In the current version ``ganeti-rapi``'s realm, ``Ganeti Remote
87 API``, can only be changed by modifying the source code.
93 The protocol used is JSON_ over HTTP designed after the REST_ principle.
94 HTTP Basic authentication as per :rfc:`2617` is supported.
96 .. _JSON: http://www.json.org/
97 .. _REST: http://en.wikipedia.org/wiki/Representational_State_Transfer
99 HTTP requests with a body (e.g. ``PUT`` or ``POST``) require the request
100 header ``Content-type`` be set to ``application/json`` (see :rfc:`2616`
101 (HTTP/1.1), section 7.2.1).
104 A note on JSON as used by RAPI
105 ++++++++++++++++++++++++++++++
107 JSON_ as used by Ganeti RAPI does not conform to the specification in
108 :rfc:`4627`. Section 2 defines a JSON text to be either an object
109 (``{"key": "value", …}``) or an array (``[1, 2, 3, …]``). In violation
110 of this RAPI uses plain strings (``"master-candidate"``, ``"1234"``) for
111 some requests or responses. Changing this now would likely break
112 existing clients and cause a lot of trouble.
116 Unlike Python's `JSON encoder and decoder
117 <http://docs.python.org/library/json.html>`_, other programming
118 languages or libraries may only provide a strict implementation, not
119 allowing plain values. For those, responses can usually be wrapped in an
120 array whose first element is then used, e.g. the response ``"1234"``
121 becomes ``["1234"]``. This works equally well for more complex values.
126 # Insert code to get response here
127 response = "\"1234\""
129 decoded = JSON.parse("[#{response}]").first
131 Short of modifying the encoder to allow encoding to a less strict
132 format, requests will have to be formatted by hand. Newer RAPI requests
133 already use a dictionary as their input data and shouldn't cause any
140 According to :rfc:`2616` the main difference between PUT and POST is
141 that POST can create new resources but PUT can only create the resource
142 the URI was pointing to on the PUT request.
144 Unfortunately, due to historic reasons, the Ganeti RAPI library is not
145 consistent with this usage, so just use the methods as documented below
148 For more details have a look in the source code at
149 ``lib/rapi/rlib2.py``.
152 Generic parameter types
153 -----------------------
155 A few generic refered parameter types and the values they allow.
160 A boolean option will accept ``1`` or ``0`` as numbers but not
161 i.e. ``True`` or ``False``.
166 A few parameter mean the same thing across all resources which implement
172 Bulk-mode means that for the resources which usually return just a list
173 of child resources (e.g. ``/2/instances`` which returns just instance
174 names), the output will instead contain detailed data for all these
175 subresources. This is more efficient than query-ing the sub-resources
181 The boolean *dry-run* argument, if provided and set, signals to Ganeti
182 that the job should not be executed, only the pre-execution checks will
185 This is useful in trying to determine (without guarantees though, as in
186 the meantime the cluster state could have changed) if the operation is
187 likely to succeed or at least start executing.
192 Force operation to continue even if it will cause the cluster to become
193 inconsistent (e.g. because there are not enough master candidates).
198 Some parameters are not straight forward, so we describe them in details
206 The instance policy specification is a dict with the following fields:
210 constants.IPOLICY_ALL_KEYS == set([constants.ISPECS_MIN,
211 constants.ISPECS_MAX,
212 constants.ISPECS_STD,
213 constants.IPOLICY_DTS,
214 constants.IPOLICY_VCPU_RATIO,
215 constants.IPOLICY_SPINDLE_RATIO])
220 (set(constants.ISPECS_PARAMETER_TYPES.keys()) ==
221 set([constants.ISPEC_MEM_SIZE,
222 constants.ISPEC_DISK_SIZE,
223 constants.ISPEC_DISK_COUNT,
224 constants.ISPEC_CPU_COUNT,
225 constants.ISPEC_NIC_COUNT,
226 constants.ISPEC_SPINDLE_USE]))
228 .. |ispec-min| replace:: :pyeval:`constants.ISPECS_MIN`
229 .. |ispec-max| replace:: :pyeval:`constants.ISPECS_MAX`
230 .. |ispec-std| replace:: :pyeval:`constants.ISPECS_STD`
233 |ispec-min|, |ispec-max|, |ispec-std|
234 A sub- `dict` with the following fields, which sets the limit and standard
235 values of the instances:
237 :pyeval:`constants.ISPEC_MEM_SIZE`
238 The size in MiB of the memory used
239 :pyeval:`constants.ISPEC_DISK_SIZE`
240 The size in MiB of the disk used
241 :pyeval:`constants.ISPEC_DISK_COUNT`
242 The numbers of disks used
243 :pyeval:`constants.ISPEC_CPU_COUNT`
244 The numbers of cpus used
245 :pyeval:`constants.ISPEC_NIC_COUNT`
246 The numbers of nics used
247 :pyeval:`constants.ISPEC_SPINDLE_USE`
248 The numbers of virtual disk spindles used by this instance. They are
249 not real in the sense of actual HDD spindles, but useful for
250 accounting the spindle usage on the residing node
251 :pyeval:`constants.IPOLICY_DTS`
252 A `list` of disk templates allowed for instances using this policy
253 :pyeval:`constants.IPOLICY_VCPU_RATIO`
254 Maximum ratio of virtual to physical CPUs (`float`)
255 :pyeval:`constants.IPOLICY_SPINDLE_RATIO`
256 Maximum ratio of instances to their node's ``spindle_count`` (`float`)
261 You can access the API using your favorite programming language as long
262 as it supports network connections.
267 Ganeti includes a standalone RAPI client, ``lib/rapi/client.py``.
272 .. highlight:: shell-example
276 $ wget -q -O - https://%CLUSTERNAME%:5080/2/info
280 $ curl https://%CLUSTERNAME%:5080/2/info
282 Note: with ``curl``, the request method (GET, POST, PUT) can be specified
283 using the ``-X`` command line option, and the username/password can be
284 specified with the ``-u`` option. In case of POST requests with a body, the
285 Content-Type can be set to JSON (as per the Protocol_ section) using the
286 parameter ``-H "Content-Type: application/json"``.
291 .. highlight:: python
296 f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info')
303 .. warning:: While it's possible to use JavaScript, it poses several
304 potential problems, including browser blocking request due to
305 non-standard ports or different domain names. Fetching the data on
306 the webserver is easier.
308 .. highlight:: javascript
312 var url = 'https://CLUSTERNAME:5080/2/info';
314 var xmlreq = new XMLHttpRequest();
315 xmlreq.onreadystatechange = function () {
316 if (xmlreq.readyState != 4) return;
317 if (xmlreq.status == 200) {
318 info = eval("(" + xmlreq.responseText + ")");
321 alert('Error fetching cluster info');
325 xmlreq.open('GET', url, true);
331 .. highlight:: javascript
336 The root resource. Has no function, but for legacy reasons the ``GET``
342 Has no function, but for legacy reasons the ``GET`` method is supported.
347 Cluster information resource.
349 It supports the following commands: ``GET``.
354 Returns cluster information.
359 "config_version": 2000000,
361 "software_version": "2.0.0~beta2",
362 "os_api_version": 10,
364 "candidate_pool_size": 10,
365 "enabled_hypervisors": [
371 "default_hypervisor": "fake",
372 "master": "node1.example.com",
377 "protocol_version": 20,
380 "auto_balance": true,
389 ``/2/redistribute-config``
390 ++++++++++++++++++++++++++
392 Redistribute configuration to all nodes.
394 It supports the following commands: ``PUT``.
399 Redistribute configuration to all nodes. The result will be a job id.
403 .. opcode_result:: OP_CLUSTER_REDIST_CONF
412 Returns a list of features supported by the RAPI server. Available
417 rlib2.ALL_FEATURES == set([rlib2._INST_CREATE_REQV1,
418 rlib2._INST_REINSTALL_REQV1,
419 rlib2._NODE_MIGRATE_REQV1,
420 rlib2._NODE_EVAC_RES1])
422 :pyeval:`rlib2._INST_CREATE_REQV1`
423 Instance creation request data version 1 supported
424 :pyeval:`rlib2._INST_REINSTALL_REQV1`
425 Instance reinstall supports body parameters
426 :pyeval:`rlib2._NODE_MIGRATE_REQV1`
427 Whether migrating a node (``/2/nodes/[node_name]/migrate``) supports
428 request body parameters
429 :pyeval:`rlib2._NODE_EVAC_RES1`
430 Whether evacuating a node (``/2/nodes/[node_name]/evacuate``) returns
431 a new-style result (see resource description)
435 ++++++++++++++++++++++++++++++++++++++++
437 Modifies cluster parameters.
439 Supports the following commands: ``PUT``.
448 .. opcode_params:: OP_CLUSTER_SET_PARAMS
452 .. opcode_result:: OP_CLUSTER_SET_PARAMS
460 It supports the following commands: ``GET``, ``POST``.
465 Returns a list of all existing node groups.
472 "uri": "\/2\/groups\/group1"
476 "uri": "\/2\/groups\/group2"
480 If the optional bool *bulk* argument is provided and set to a true value
481 (i.e ``?bulk=1``), the output contains detailed information about node
484 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.G_FIELDS))`.
496 "uuid": "0d7d407c-262e-49af-881a-6a430034bf43",
505 "uuid": "f5a277e7-68f9-44d3-a378-4b25ecb5df5c",
514 Creates a node group.
516 If the optional bool *dry-run* argument is provided, the job will not be
517 actually executed, only the pre-execution checks will be done.
519 Returns: a job ID that can be used later for polling.
523 .. opcode_params:: OP_GROUP_ADD
525 Earlier versions used a parameter named ``name`` which, while still
526 supported, has been renamed to ``group_name``.
530 .. opcode_result:: OP_GROUP_ADD
533 ``/2/groups/[group_name]``
534 ++++++++++++++++++++++++++
536 Returns information about a node group.
538 It supports the following commands: ``GET``, ``DELETE``.
543 Returns information about a node group, similar to the bulk output from
546 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.G_FIELDS))`.
551 Deletes a node group.
553 It supports the ``dry-run`` argument.
557 .. opcode_result:: OP_GROUP_REMOVE
560 ``/2/groups/[group_name]/modify``
561 +++++++++++++++++++++++++++++++++
563 Modifies the parameters of a node group.
565 Supports the following commands: ``PUT``.
574 .. opcode_params:: OP_GROUP_SET_PARAMS
579 .. opcode_result:: OP_GROUP_SET_PARAMS
582 ``/2/groups/[group_name]/rename``
583 +++++++++++++++++++++++++++++++++
585 Renames a node group.
587 Supports the following commands: ``PUT``.
596 .. opcode_params:: OP_GROUP_RENAME
601 .. opcode_result:: OP_GROUP_RENAME
604 ``/2/groups/[group_name]/assign-nodes``
605 +++++++++++++++++++++++++++++++++++++++
607 Assigns nodes to a group.
609 Supports the following commands: ``PUT``.
614 Returns a job ID. It supports the ``dry-run`` and ``force`` arguments.
618 .. opcode_params:: OP_GROUP_ASSIGN_NODES
619 :exclude: group_name, force, dry_run
623 .. opcode_result:: OP_GROUP_ASSIGN_NODES
626 ``/2/groups/[group_name]/tags``
627 +++++++++++++++++++++++++++++++
629 Manages per-nodegroup tags.
631 Supports the following commands: ``GET``, ``PUT``, ``DELETE``.
636 Returns a list of tags.
640 ["tag1", "tag2", "tag3"]
647 The request as a list of strings should be ``PUT`` to this URI. The
648 result will be a job id.
650 It supports the ``dry-run`` argument.
658 In order to delete a set of tags, the DELETE request should be addressed
661 /tags?tag=[tag]&tag=[tag]
663 It supports the ``dry-run`` argument.
669 The networks resource.
671 It supports the following commands: ``GET``, ``POST``.
676 Returns a list of all existing networks.
683 "uri": "\/2\/networks\/network1"
687 "uri": "\/2\/networks\/network2"
691 If the optional bool *bulk* argument is provided and set to a true value
692 (i.e ``?bulk=1``), the output contains detailed information about networks
695 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.NET_FIELDS))`.
701 'external_reservations': '10.0.0.0, 10.0.0.1, 10.0.0.15',
703 'gateway': '10.0.0.1',
705 'group_list': ['default(bridged, prv0)'],
708 'map': 'XX.............X',
710 'network': '10.0.0.0/28',
724 If the optional bool *dry-run* argument is provided, the job will not be
725 actually executed, only the pre-execution checks will be done.
727 Returns: a job ID that can be used later for polling.
731 .. opcode_params:: OP_NETWORK_ADD
735 .. opcode_result:: OP_NETWORK_ADD
738 ``/2/networks/[network_name]``
739 ++++++++++++++++++++++++++++++
741 Returns information about a network.
743 It supports the following commands: ``GET``, ``DELETE``.
748 Returns information about a network, similar to the bulk output from
751 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.NET_FIELDS))`.
758 It supports the ``dry-run`` argument.
762 .. opcode_result:: OP_NETWORK_REMOVE
765 ``/2/networks/[network_name]/modify``
766 +++++++++++++++++++++++++++++++++++++
768 Modifies the parameters of a network.
770 Supports the following commands: ``PUT``.
779 .. opcode_params:: OP_NETWORK_SET_PARAMS
783 .. opcode_result:: OP_NETWORK_SET_PARAMS
786 ``/2/networks/[network_name]/connect``
787 ++++++++++++++++++++++++++++++++++++++
789 Connects a network to a nodegroup.
791 Supports the following commands: ``PUT``.
796 Returns a job ID. It supports the ``dry-run`` arguments.
800 .. opcode_params:: OP_NETWORK_CONNECT
804 .. opcode_result:: OP_NETWORK_CONNECT
807 ``/2/networks/[network_name]/disconnect``
808 +++++++++++++++++++++++++++++++++++++++++
810 Disonnects a network from a nodegroup.
812 Supports the following commands: ``PUT``.
817 Returns a job ID. It supports the ``dry-run`` arguments.
821 .. opcode_params:: OP_NETWORK_DISCONNECT
825 .. opcode_result:: OP_NETWORK_DISCONNECT
828 ``/2/networks/[network_name]/tags``
829 +++++++++++++++++++++++++++++++++++
831 Manages per-network tags.
833 Supports the following commands: ``GET``, ``PUT``, ``DELETE``.
838 Returns a list of tags.
842 ["tag1", "tag2", "tag3"]
849 The request as a list of strings should be ``PUT`` to this URI. The
850 result will be a job id.
852 It supports the ``dry-run`` argument.
860 In order to delete a set of tags, the DELETE request should be addressed
863 /tags?tag=[tag]&tag=[tag]
865 It supports the ``dry-run`` argument.
868 ``/2/instances-multi-alloc``
869 ++++++++++++++++++++++++++++
871 Tries to allocate multiple instances.
873 It supports the following commands: ``POST``
880 .. opcode_params:: OP_INSTANCE_MULTI_ALLOC
884 .. opcode_result:: OP_INSTANCE_MULTI_ALLOC
890 The instances resource.
892 It supports the following commands: ``GET``, ``POST``.
897 Returns a list of all available instances.
903 "name": "web.example.com",
904 "uri": "\/instances\/web.example.com"
907 "name": "mail.example.com",
908 "uri": "\/instances\/mail.example.com"
912 If the optional bool *bulk* argument is provided and set to a true value
913 (i.e ``?bulk=1``), the output contains detailed information about
916 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.I_FIELDS))`.
927 "name": "web.example.com",
928 "tags": ["tag1", "tag2"],
936 "pnode": "node1.example.com",
937 "nic.macs": ["01:23:45:67:89:01"],
938 "snodes": ["node2.example.com"],
939 "disk_template": "drbd",
954 If the optional bool *dry-run* argument is provided, the job will not be
955 actually executed, only the pre-execution checks will be done. Query-ing
956 the job result will return, in both dry-run and normal case, the list of
957 nodes selected for the instance.
959 Returns: a job ID that can be used later for polling.
963 ``__version__`` (int, required)
964 Must be ``1`` (older Ganeti versions used a different format for
965 instance creation requests, version ``0``, but that format is no
968 .. opcode_params:: OP_INSTANCE_CREATE
970 Earlier versions used parameters named ``name`` and ``os``. These have
971 been replaced by ``instance_name`` and ``os_type`` to match the
972 underlying opcode. The old names can still be used.
976 .. opcode_result:: OP_INSTANCE_CREATE
979 ``/2/instances/[instance_name]``
980 ++++++++++++++++++++++++++++++++
982 Instance-specific resource.
984 It supports the following commands: ``GET``, ``DELETE``.
989 Returns information about an instance, similar to the bulk output from
992 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.I_FIELDS))`.
999 It supports the ``dry-run`` argument.
1003 .. opcode_result:: OP_INSTANCE_REMOVE
1006 ``/2/instances/[instance_name]/info``
1007 +++++++++++++++++++++++++++++++++++++++
1009 It supports the following commands: ``GET``.
1014 Requests detailed information about the instance. An optional parameter,
1015 ``static`` (bool), can be set to return only static information from the
1016 configuration without querying the instance's nodes. The result will be
1021 .. opcode_result:: OP_INSTANCE_QUERY_DATA
1024 ``/2/instances/[instance_name]/reboot``
1025 +++++++++++++++++++++++++++++++++++++++
1027 Reboots URI for an instance.
1029 It supports the following commands: ``POST``.
1034 Reboots the instance.
1036 The URI takes optional ``type=soft|hard|full`` and
1037 ``ignore_secondaries=0|1`` parameters.
1039 ``type`` defines the reboot type. ``soft`` is just a normal reboot,
1040 without terminating the hypervisor. ``hard`` means full shutdown
1041 (including terminating the hypervisor process) and startup again.
1042 ``full`` is like ``hard`` but also recreates the configuration from
1043 ground up as if you would have done a ``gnt-instance shutdown`` and
1044 ``gnt-instance start`` on it.
1046 ``ignore_secondaries`` is a bool argument indicating if we start the
1047 instance even if secondary disks are failing.
1049 It supports the ``dry-run`` argument.
1053 .. opcode_result:: OP_INSTANCE_REBOOT
1056 ``/2/instances/[instance_name]/shutdown``
1057 +++++++++++++++++++++++++++++++++++++++++
1059 Instance shutdown URI.
1061 It supports the following commands: ``PUT``.
1066 Shutdowns an instance.
1068 It supports the ``dry-run`` argument.
1070 .. opcode_params:: OP_INSTANCE_SHUTDOWN
1071 :exclude: instance_name, dry_run
1075 .. opcode_result:: OP_INSTANCE_SHUTDOWN
1078 ``/2/instances/[instance_name]/startup``
1079 ++++++++++++++++++++++++++++++++++++++++
1081 Instance startup URI.
1083 It supports the following commands: ``PUT``.
1088 Startup an instance.
1090 The URI takes an optional ``force=1|0`` parameter to start the
1091 instance even if secondary disks are failing.
1093 It supports the ``dry-run`` argument.
1097 .. opcode_result:: OP_INSTANCE_STARTUP
1100 ``/2/instances/[instance_name]/reinstall``
1101 ++++++++++++++++++++++++++++++++++++++++++++++
1103 Installs the operating system again.
1105 It supports the following commands: ``POST``.
1114 ``os`` (string, required)
1115 Instance operating system.
1116 ``start`` (bool, defaults to true)
1117 Whether to start instance after reinstallation.
1119 Dictionary with (temporary) OS parameters.
1121 For backwards compatbility, this resource also takes the query
1122 parameters ``os`` (OS template name) and ``nostartup`` (bool). New
1123 clients should use the body parameters.
1126 ``/2/instances/[instance_name]/replace-disks``
1127 ++++++++++++++++++++++++++++++++++++++++++++++
1129 Replaces disks on an instance.
1131 It supports the following commands: ``POST``.
1140 .. opcode_params:: OP_INSTANCE_REPLACE_DISKS
1141 :exclude: instance_name
1143 Ganeti 2.4 and below used query parameters. Those are deprecated and
1144 should no longer be used.
1148 .. opcode_result:: OP_INSTANCE_REPLACE_DISKS
1151 ``/2/instances/[instance_name]/activate-disks``
1152 +++++++++++++++++++++++++++++++++++++++++++++++
1154 Activate disks on an instance.
1156 It supports the following commands: ``PUT``.
1161 Takes the bool parameter ``ignore_size``. When set ignore the recorded
1162 size (useful for forcing activation when recorded size is wrong).
1166 .. opcode_result:: OP_INSTANCE_ACTIVATE_DISKS
1169 ``/2/instances/[instance_name]/deactivate-disks``
1170 +++++++++++++++++++++++++++++++++++++++++++++++++
1172 Deactivate disks on an instance.
1174 It supports the following commands: ``PUT``.
1179 Takes no parameters.
1183 .. opcode_result:: OP_INSTANCE_DEACTIVATE_DISKS
1186 ``/2/instances/[instance_name]/recreate-disks``
1187 +++++++++++++++++++++++++++++++++++++++++++++++++
1189 Recreate disks of an instance. Supports the following commands:
1199 .. opcode_params:: OP_INSTANCE_RECREATE_DISKS
1200 :exclude: instance_name
1204 .. opcode_result:: OP_INSTANCE_RECREATE_DISKS
1207 ``/2/instances/[instance_name]/disk/[disk_index]/grow``
1208 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1210 Grows one disk of an instance.
1212 Supports the following commands: ``POST``.
1221 .. opcode_params:: OP_INSTANCE_GROW_DISK
1222 :exclude: instance_name, disk
1226 .. opcode_result:: OP_INSTANCE_GROW_DISK
1229 ``/2/instances/[instance_name]/prepare-export``
1230 +++++++++++++++++++++++++++++++++++++++++++++++++
1232 Prepares an export of an instance.
1234 It supports the following commands: ``PUT``.
1239 Takes one parameter, ``mode``, for the export mode. Returns a job ID.
1243 .. opcode_result:: OP_BACKUP_PREPARE
1246 ``/2/instances/[instance_name]/export``
1247 +++++++++++++++++++++++++++++++++++++++++++++++++
1249 Exports an instance.
1251 It supports the following commands: ``PUT``.
1260 .. opcode_params:: OP_BACKUP_EXPORT
1261 :exclude: instance_name
1262 :alias: target_node=destination
1266 .. opcode_result:: OP_BACKUP_EXPORT
1269 ``/2/instances/[instance_name]/migrate``
1270 ++++++++++++++++++++++++++++++++++++++++
1272 Migrates an instance.
1274 Supports the following commands: ``PUT``.
1283 .. opcode_params:: OP_INSTANCE_MIGRATE
1284 :exclude: instance_name, live
1288 .. opcode_result:: OP_INSTANCE_MIGRATE
1291 ``/2/instances/[instance_name]/failover``
1292 +++++++++++++++++++++++++++++++++++++++++
1294 Does a failover of an instance.
1296 Supports the following commands: ``PUT``.
1305 .. opcode_params:: OP_INSTANCE_FAILOVER
1306 :exclude: instance_name
1310 .. opcode_result:: OP_INSTANCE_FAILOVER
1313 ``/2/instances/[instance_name]/rename``
1314 ++++++++++++++++++++++++++++++++++++++++
1316 Renames an instance.
1318 Supports the following commands: ``PUT``.
1327 .. opcode_params:: OP_INSTANCE_RENAME
1328 :exclude: instance_name
1332 .. opcode_result:: OP_INSTANCE_RENAME
1335 ``/2/instances/[instance_name]/modify``
1336 ++++++++++++++++++++++++++++++++++++++++
1338 Modifies an instance.
1340 Supports the following commands: ``PUT``.
1349 .. opcode_params:: OP_INSTANCE_SET_PARAMS
1350 :exclude: instance_name
1354 .. opcode_result:: OP_INSTANCE_SET_PARAMS
1357 ``/2/instances/[instance_name]/console``
1358 ++++++++++++++++++++++++++++++++++++++++
1360 Request information for connecting to instance's console.
1364 not (hasattr(rlib2.R_2_instances_name_console, "PUT") or
1365 hasattr(rlib2.R_2_instances_name_console, "POST") or
1366 hasattr(rlib2.R_2_instances_name_console, "DELETE"))
1368 Supports the following commands: ``GET``. Requires authentication with
1369 one of the following options:
1370 :pyeval:`utils.CommaJoin(rlib2.R_2_instances_name_console.GET_ACCESS)`.
1375 Returns a dictionary containing information about the instance's
1376 console. Contained keys:
1380 constants.CONS_ALL == frozenset([
1381 constants.CONS_MESSAGE,
1384 constants.CONS_SPICE,
1390 Console type, one of :pyeval:`constants.CONS_SSH`,
1391 :pyeval:`constants.CONS_VNC`, :pyeval:`constants.CONS_SPICE`
1392 or :pyeval:`constants.CONS_MESSAGE`
1394 Message to display (:pyeval:`constants.CONS_MESSAGE` type only)
1396 Host to connect to (:pyeval:`constants.CONS_SSH`,
1397 :pyeval:`constants.CONS_VNC` or :pyeval:`constants.CONS_SPICE` only)
1399 TCP port to connect to (:pyeval:`constants.CONS_VNC` or
1400 :pyeval:`constants.CONS_SPICE` only)
1402 Username to use (:pyeval:`constants.CONS_SSH` only)
1404 Command to execute on machine (:pyeval:`constants.CONS_SSH` only)
1406 VNC display number (:pyeval:`constants.CONS_VNC` only)
1409 ``/2/instances/[instance_name]/tags``
1410 +++++++++++++++++++++++++++++++++++++
1412 Manages per-instance tags.
1414 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1419 Returns a list of tags.
1423 ["tag1", "tag2", "tag3"]
1430 The request as a list of strings should be ``PUT`` to this URI. The
1431 result will be a job id.
1433 It supports the ``dry-run`` argument.
1441 In order to delete a set of tags, the DELETE request should be addressed
1444 /tags?tag=[tag]&tag=[tag]
1446 It supports the ``dry-run`` argument.
1452 The ``/2/jobs`` resource.
1454 It supports the following commands: ``GET``.
1459 Returns a dictionary of jobs.
1461 Returns: a dictionary with jobs id and uri.
1463 If the optional bool *bulk* argument is provided and set to a true value
1464 (i.e. ``?bulk=1``), the output contains detailed information about jobs
1467 Returned fields for bulk requests (unlike other bulk requests, these
1468 fields are not the same as for per-job requests):
1469 :pyeval:`utils.CommaJoin(sorted(rlib2.J_FIELDS_BULK))`.
1471 ``/2/jobs/[job_id]``
1472 ++++++++++++++++++++
1477 It supports the following commands: ``GET``, ``DELETE``.
1482 Returns a dictionary with job parameters, containing the fields
1483 :pyeval:`utils.CommaJoin(sorted(rlib2.J_FIELDS))`.
1485 The result includes:
1487 - id: job ID as a number
1488 - status: current job status as a string
1489 - ops: involved OpCodes as a list of dictionaries for each opcodes in
1491 - opstatus: OpCodes status as a list
1492 - opresult: OpCodes results as a list
1494 For a successful opcode, the ``opresult`` field corresponding to it will
1495 contain the raw result from its :term:`LogicalUnit`. In case an opcode
1496 has failed, its element in the opresult list will be a list of two
1499 - first element the error type (the Ganeti internal error name)
1500 - second element a list of either one or two elements:
1502 - the first element is the textual error description
1503 - the second element, if any, will hold an error classification
1505 The error classification is most useful for the ``OpPrereqError``
1506 error type - these errors happen before the OpCode has started
1507 executing, so it's possible to retry the OpCode without side
1508 effects. But whether it make sense to retry depends on the error
1513 errors.ECODE_ALL == set([errors.ECODE_RESOLVER, errors.ECODE_NORES,
1514 errors.ECODE_INVAL, errors.ECODE_STATE, errors.ECODE_NOENT,
1515 errors.ECODE_EXISTS, errors.ECODE_NOTUNIQUE, errors.ECODE_FAULT,
1516 errors.ECODE_ENVIRON, errors.ECODE_TEMP_NORES])
1518 :pyeval:`errors.ECODE_RESOLVER`
1519 Resolver errors. This usually means that a name doesn't exist in DNS,
1520 so if it's a case of slow DNS propagation the operation can be retried
1523 :pyeval:`errors.ECODE_NORES`
1524 Not enough resources (iallocator failure, disk space, memory,
1525 etc.). If the resources on the cluster increase, the operation might
1528 :pyeval:`errors.ECODE_TEMP_NORES`
1529 Simliar to :pyeval:`errors.ECODE_NORES`, but indicating the operation
1530 should be attempted again after some time.
1532 :pyeval:`errors.ECODE_INVAL`
1533 Wrong arguments (at syntax level). The operation will not ever be
1534 accepted unless the arguments change.
1536 :pyeval:`errors.ECODE_STATE`
1537 Wrong entity state. For example, live migration has been requested for
1538 a down instance, or instance creation on an offline node. The
1539 operation can be retried once the resource has changed state.
1541 :pyeval:`errors.ECODE_NOENT`
1542 Entity not found. For example, information has been requested for an
1545 :pyeval:`errors.ECODE_EXISTS`
1546 Entity already exists. For example, instance creation has been
1547 requested for an already-existing instance.
1549 :pyeval:`errors.ECODE_NOTUNIQUE`
1550 Resource not unique (e.g. MAC or IP duplication).
1552 :pyeval:`errors.ECODE_FAULT`
1553 Internal cluster error. For example, a node is unreachable but not set
1554 offline, or the ganeti node daemons are not working, etc. A
1555 ``gnt-cluster verify`` should be run.
1557 :pyeval:`errors.ECODE_ENVIRON`
1558 Environment error (e.g. node disk error). A ``gnt-cluster verify``
1561 Note that in the above list, by entity we refer to a node or instance,
1562 while by a resource we refer to an instance's disk, or NIC, etc.
1568 Cancel a not-yet-started job.
1571 ``/2/jobs/[job_id]/wait``
1572 +++++++++++++++++++++++++
1577 Waits for changes on a job. Takes the following body parameters in a
1581 The job fields on which to watch for changes
1583 ``previous_job_info``
1584 Previously received field values or None if not yet available
1586 ``previous_log_serial``
1587 Highest log serial number received so far or None if not yet
1590 Returns None if no changes have been detected and a dict with two keys,
1591 ``job_info`` and ``log_entries`` otherwise.
1599 It supports the following commands: ``GET``.
1604 Returns a list of all nodes.
1610 "id": "node1.example.com",
1611 "uri": "\/nodes\/node1.example.com"
1614 "id": "node2.example.com",
1615 "uri": "\/nodes\/node2.example.com"
1619 If the optional bool *bulk* argument is provided and set to a true value
1620 (i.e ``?bulk=1``), the output contains detailed information about nodes
1623 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.N_FIELDS))`.
1632 "name": "www.example.com",
1644 ``/2/nodes/[node_name]``
1645 +++++++++++++++++++++++++++++++++
1647 Returns information about a node.
1649 It supports the following commands: ``GET``.
1651 Returned fields: :pyeval:`utils.CommaJoin(sorted(rlib2.N_FIELDS))`.
1653 ``/2/nodes/[node_name]/powercycle``
1654 +++++++++++++++++++++++++++++++++++
1656 Powercycles a node. Supports the following commands: ``POST``.
1665 .. opcode_result:: OP_NODE_POWERCYCLE
1668 ``/2/nodes/[node_name]/evacuate``
1669 +++++++++++++++++++++++++++++++++
1671 Evacuates instances off a node.
1673 It supports the following commands: ``POST``.
1678 Returns a job ID. The result of the job will contain the IDs of the
1679 individual jobs submitted to evacuate the node.
1683 .. opcode_params:: OP_NODE_EVACUATE
1686 Up to and including Ganeti 2.4 query arguments were used. Those are no
1687 longer supported. The new request can be detected by the presence of the
1688 :pyeval:`rlib2._NODE_EVAC_RES1` feature string.
1692 .. opcode_result:: OP_NODE_EVACUATE
1695 ``/2/nodes/[node_name]/migrate``
1696 +++++++++++++++++++++++++++++++++
1698 Migrates all primary instances from a node.
1700 It supports the following commands: ``POST``.
1705 If no mode is explicitly specified, each instances' hypervisor default
1706 migration mode will be used. Body parameters:
1708 .. opcode_params:: OP_NODE_MIGRATE
1711 The query arguments used up to and including Ganeti 2.4 are deprecated
1712 and should no longer be used. The new request format can be detected by
1713 the presence of the :pyeval:`rlib2._NODE_MIGRATE_REQV1` feature string.
1717 .. opcode_result:: OP_NODE_MIGRATE
1720 ``/2/nodes/[node_name]/role``
1721 +++++++++++++++++++++++++++++
1725 It supports the following commands: ``GET``, ``PUT``.
1727 The role is always one of the following:
1734 Note that the 'master' role is a special, and currently it can't be
1735 modified via RAPI, only via the command line (``gnt-cluster
1741 Returns the current node role.
1750 Change the node role.
1752 The request is a string which should be PUT to this URI. The result will
1755 It supports the bool ``force`` argument.
1759 .. opcode_result:: OP_NODE_SET_PARAMS
1762 ``/2/nodes/[node_name]/modify``
1763 +++++++++++++++++++++++++++++++
1765 Modifies the parameters of a node. Supports the following commands:
1775 .. opcode_params:: OP_NODE_SET_PARAMS
1780 .. opcode_result:: OP_NODE_SET_PARAMS
1783 ``/2/nodes/[node_name]/storage``
1784 ++++++++++++++++++++++++++++++++
1786 Manages storage units on the node.
1793 constants.VALID_STORAGE_TYPES == set([constants.ST_FILE,
1794 constants.ST_LVM_PV,
1795 constants.ST_LVM_VG])
1797 Requests a list of storage units on a node. Requires the parameters
1798 ``storage_type`` (one of :pyeval:`constants.ST_FILE`,
1799 :pyeval:`constants.ST_LVM_PV` or :pyeval:`constants.ST_LVM_VG`) and
1800 ``output_fields``. The result will be a job id, using which the result
1803 ``/2/nodes/[node_name]/storage/modify``
1804 +++++++++++++++++++++++++++++++++++++++
1806 Modifies storage units on the node.
1811 Modifies parameters of storage units on the node. Requires the
1812 parameters ``storage_type`` (one of :pyeval:`constants.ST_FILE`,
1813 :pyeval:`constants.ST_LVM_PV` or :pyeval:`constants.ST_LVM_VG`)
1814 and ``name`` (name of the storage unit). Parameters can be passed
1815 additionally. Currently only :pyeval:`constants.SF_ALLOCATABLE` (bool)
1816 is supported. The result will be a job id.
1820 .. opcode_result:: OP_NODE_MODIFY_STORAGE
1823 ``/2/nodes/[node_name]/storage/repair``
1824 +++++++++++++++++++++++++++++++++++++++
1826 Repairs a storage unit on the node.
1833 constants.VALID_STORAGE_OPERATIONS == {
1834 constants.ST_LVM_VG: set([constants.SO_FIX_CONSISTENCY]),
1837 Repairs a storage unit on the node. Requires the parameters
1838 ``storage_type`` (currently only :pyeval:`constants.ST_LVM_VG` can be
1839 repaired) and ``name`` (name of the storage unit). The result will be a
1844 .. opcode_result:: OP_REPAIR_NODE_STORAGE
1847 ``/2/nodes/[node_name]/tags``
1848 +++++++++++++++++++++++++++++
1850 Manages per-node tags.
1852 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1857 Returns a list of tags.
1861 ["tag1", "tag2", "tag3"]
1868 The request as a list of strings should be PUT to this URI. The result
1871 It supports the ``dry-run`` argument.
1878 In order to delete a set of tags, the DELETE request should be addressed
1881 /tags?tag=[tag]&tag=[tag]
1883 It supports the ``dry-run`` argument.
1886 ``/2/query/[resource]``
1887 +++++++++++++++++++++++
1889 Requests resource information. Available fields can be found in man
1890 pages and using ``/2/query/[resource]/fields``. The resource is one of
1891 :pyeval:`utils.CommaJoin(constants.QR_VIA_RAPI)`. See the :doc:`query2
1892 design document <design-query2>` for more details.
1896 (rlib2.R_2_query.GET_ACCESS == rlib2.R_2_query.PUT_ACCESS and
1897 not (hasattr(rlib2.R_2_query, "POST") or
1898 hasattr(rlib2.R_2_query, "DELETE")))
1900 Supports the following commands: ``GET``, ``PUT``. Requires
1901 authentication with one of the following options:
1902 :pyeval:`utils.CommaJoin(rlib2.R_2_query.GET_ACCESS)`.
1907 Returns list of included fields and actual data. Takes a query parameter
1908 named "fields", containing a comma-separated list of field names. Does
1909 not support filtering.
1914 Returns list of included fields and actual data. The list of requested
1915 fields can either be given as the query parameter "fields" or as a body
1916 parameter with the same name. The optional body parameter "filter" can
1917 be given and must be either ``null`` or a list containing filter
1921 ``/2/query/[resource]/fields``
1922 ++++++++++++++++++++++++++++++
1924 Request list of available fields for a resource. The resource is one of
1925 :pyeval:`utils.CommaJoin(constants.QR_VIA_RAPI)`. See the
1926 :doc:`query2 design document <design-query2>` for more details.
1928 Supports the following commands: ``GET``.
1933 Returns a list of field descriptions for available fields. Takes an
1934 optional query parameter named "fields", containing a comma-separated
1935 list of field names.
1943 It supports the following commands: ``GET``.
1948 Return a list of all OSes.
1950 Can return error 500 in case of a problem. Since this is a costly
1951 operation for Ganeti 2.0, it is not recommended to execute it too often.
1960 Manages cluster tags.
1962 It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
1967 Returns the cluster tags.
1971 ["tag1", "tag2", "tag3"]
1978 The request as a list of strings should be PUT to this URI. The result
1981 It supports the ``dry-run`` argument.
1989 In order to delete a set of tags, the DELETE request should be addressed
1992 /tags?tag=[tag]&tag=[tag]
1994 It supports the ``dry-run`` argument.
2000 The version resource.
2002 This resource should be used to determine the remote API version and to
2003 adapt clients accordingly.
2005 It supports the following commands: ``GET``.
2010 Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti 2.0
2013 .. vim: set textwidth=72 :