root / doc / rapi.rst @ c744425f
History | View | Annotate | Download (27.9 kB)
1 |
Ganeti remote API |
---|---|
2 |
================= |
3 |
|
4 |
Documents Ganeti version |version| |
5 |
|
6 |
.. contents:: |
7 |
|
8 |
Introduction |
9 |
------------ |
10 |
|
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 |
17 |
parameters. |
18 |
|
19 |
|
20 |
Users and passwords |
21 |
------------------- |
22 |
|
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 |
25 |
read automatically. |
26 |
|
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. |
33 |
|
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. |
41 |
|
42 |
Example:: |
43 |
|
44 |
# Give Jack and Fred read-only access |
45 |
jack abc123 |
46 |
fred {cleartext}foo555 |
47 |
|
48 |
# Give write access to an imaginary instance creation script |
49 |
autocreator xyz789 write |
50 |
|
51 |
# Hashed password for Jessica |
52 |
jessica {HA1}7046452df2cbb530877058712cf17bd4 write |
53 |
|
54 |
|
55 |
.. [#pwhash] Using the MD5 hash of username, realm and password is |
56 |
described in :rfc:`2617` ("HTTP Authentication"), sections 3.2.2.2 and |
57 |
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. |
62 |
|
63 |
|
64 |
Protocol |
65 |
-------- |
66 |
|
67 |
The protocol used is JSON_ over HTTP designed after the REST_ principle. |
68 |
HTTP Basic authentication as per :rfc:`2617` is supported. |
69 |
|
70 |
.. _JSON: http://www.json.org/ |
71 |
.. _REST: http://en.wikipedia.org/wiki/Representational_State_Transfer |
72 |
|
73 |
|
74 |
A note on JSON as used by RAPI |
75 |
++++++++++++++++++++++++++++++ |
76 |
|
77 |
JSON_ as used by Ganeti RAPI does not conform to the specification in |
78 |
:rfc:`4627`. Section 2 defines a JSON text to be either an object |
79 |
(``{"key": "value", …}``) or an array (``[1, 2, 3, …]``). In violation |
80 |
of this RAPI uses plain strings (``"master-candidate"``, ``"1234"``) for |
81 |
some requests or responses. Changing this now would likely break |
82 |
existing clients and cause a lot of trouble. |
83 |
|
84 |
.. highlight:: ruby |
85 |
|
86 |
Unlike Python's `JSON encoder and decoder |
87 |
<http://docs.python.org/library/json.html>`_, other programming |
88 |
languages or libraries may only provide a strict implementation, not |
89 |
allowing plain values. For those, responses can usually be wrapped in an |
90 |
array whose first element is then used, e.g. the response ``"1234"`` |
91 |
becomes ``["1234"]``. This works equally well for more complex values. |
92 |
Example in Ruby:: |
93 |
|
94 |
require "json" |
95 |
|
96 |
# Insert code to get response here |
97 |
response = "\"1234\"" |
98 |
|
99 |
decoded = JSON.parse("[#{response}]").first |
100 |
|
101 |
Short of modifying the encoder to allow encoding to a less strict |
102 |
format, requests will have to be formatted by hand. Newer RAPI requests |
103 |
already use a dictionary as their input data and shouldn't cause any |
104 |
problems. |
105 |
|
106 |
|
107 |
PUT or POST? |
108 |
------------ |
109 |
|
110 |
According to :rfc:`2616` the main difference between PUT and POST is |
111 |
that POST can create new resources but PUT can only create the resource |
112 |
the URI was pointing to on the PUT request. |
113 |
|
114 |
Unfortunately, due to historic reasons, the Ganeti RAPI library is not |
115 |
consistent with this usage, so just use the methods as documented below |
116 |
for each resource. |
117 |
|
118 |
For more details have a look in the source code at |
119 |
``lib/rapi/rlib2.py``. |
120 |
|
121 |
|
122 |
Generic parameter types |
123 |
----------------------- |
124 |
|
125 |
A few generic refered parameter types and the values they allow. |
126 |
|
127 |
``bool`` |
128 |
++++++++ |
129 |
|
130 |
A boolean option will accept ``1`` or ``0`` as numbers but not |
131 |
i.e. ``True`` or ``False``. |
132 |
|
133 |
Generic parameters |
134 |
------------------ |
135 |
|
136 |
A few parameter mean the same thing across all resources which implement |
137 |
it. |
138 |
|
139 |
``bulk`` |
140 |
++++++++ |
141 |
|
142 |
Bulk-mode means that for the resources which usually return just a list |
143 |
of child resources (e.g. ``/2/instances`` which returns just instance |
144 |
names), the output will instead contain detailed data for all these |
145 |
subresources. This is more efficient than query-ing the sub-resources |
146 |
themselves. |
147 |
|
148 |
``dry-run`` |
149 |
+++++++++++ |
150 |
|
151 |
The boolean *dry-run* argument, if provided and set, signals to Ganeti |
152 |
that the job should not be executed, only the pre-execution checks will |
153 |
be done. |
154 |
|
155 |
This is useful in trying to determine (without guarantees though, as in |
156 |
the meantime the cluster state could have changed) if the operation is |
157 |
likely to succeed or at least start executing. |
158 |
|
159 |
``force`` |
160 |
+++++++++++ |
161 |
|
162 |
Force operation to continue even if it will cause the cluster to become |
163 |
inconsistent (e.g. because there are not enough master candidates). |
164 |
|
165 |
Usage examples |
166 |
-------------- |
167 |
|
168 |
You can access the API using your favorite programming language as long |
169 |
as it supports network connections. |
170 |
|
171 |
Ganeti RAPI client |
172 |
++++++++++++++++++ |
173 |
|
174 |
Ganeti includes a standalone RAPI client, ``lib/rapi/client.py``. |
175 |
|
176 |
Shell |
177 |
+++++ |
178 |
|
179 |
.. highlight:: sh |
180 |
|
181 |
Using wget:: |
182 |
|
183 |
wget -q -O - https://CLUSTERNAME:5080/2/info |
184 |
|
185 |
or curl:: |
186 |
|
187 |
curl https://CLUSTERNAME:5080/2/info |
188 |
|
189 |
|
190 |
Python |
191 |
++++++ |
192 |
|
193 |
.. highlight:: python |
194 |
|
195 |
:: |
196 |
|
197 |
import urllib2 |
198 |
f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info') |
199 |
print f.read() |
200 |
|
201 |
|
202 |
JavaScript |
203 |
++++++++++ |
204 |
|
205 |
.. warning:: While it's possible to use JavaScript, it poses several |
206 |
potential problems, including browser blocking request due to |
207 |
non-standard ports or different domain names. Fetching the data on |
208 |
the webserver is easier. |
209 |
|
210 |
.. highlight:: javascript |
211 |
|
212 |
:: |
213 |
|
214 |
var url = 'https://CLUSTERNAME:5080/2/info'; |
215 |
var info; |
216 |
var xmlreq = new XMLHttpRequest(); |
217 |
xmlreq.onreadystatechange = function () { |
218 |
if (xmlreq.readyState != 4) return; |
219 |
if (xmlreq.status == 200) { |
220 |
info = eval("(" + xmlreq.responseText + ")"); |
221 |
alert(info); |
222 |
} else { |
223 |
alert('Error fetching cluster info'); |
224 |
} |
225 |
xmlreq = null; |
226 |
}; |
227 |
xmlreq.open('GET', url, true); |
228 |
xmlreq.send(null); |
229 |
|
230 |
Resources |
231 |
--------- |
232 |
|
233 |
.. highlight:: javascript |
234 |
|
235 |
``/`` |
236 |
+++++ |
237 |
|
238 |
The root resource. |
239 |
|
240 |
It supports the following commands: ``GET``. |
241 |
|
242 |
``GET`` |
243 |
~~~~~~~ |
244 |
|
245 |
Shows the list of mapped resources. |
246 |
|
247 |
Returns: a dictionary with 'name' and 'uri' keys for each of them. |
248 |
|
249 |
``/2`` |
250 |
++++++ |
251 |
|
252 |
The ``/2`` resource, the root of the version 2 API. |
253 |
|
254 |
It supports the following commands: ``GET``. |
255 |
|
256 |
``GET`` |
257 |
~~~~~~~ |
258 |
|
259 |
Show the list of mapped resources. |
260 |
|
261 |
Returns: a dictionary with ``name`` and ``uri`` keys for each of them. |
262 |
|
263 |
``/2/info`` |
264 |
+++++++++++ |
265 |
|
266 |
Cluster information resource. |
267 |
|
268 |
It supports the following commands: ``GET``. |
269 |
|
270 |
``GET`` |
271 |
~~~~~~~ |
272 |
|
273 |
Returns cluster information. |
274 |
|
275 |
Example:: |
276 |
|
277 |
{ |
278 |
"config_version": 2000000, |
279 |
"name": "cluster", |
280 |
"software_version": "2.0.0~beta2", |
281 |
"os_api_version": 10, |
282 |
"export_version": 0, |
283 |
"candidate_pool_size": 10, |
284 |
"enabled_hypervisors": [ |
285 |
"fake" |
286 |
], |
287 |
"hvparams": { |
288 |
"fake": {} |
289 |
}, |
290 |
"default_hypervisor": "fake", |
291 |
"master": "node1.example.com", |
292 |
"architecture": [ |
293 |
"64bit", |
294 |
"x86_64" |
295 |
], |
296 |
"protocol_version": 20, |
297 |
"beparams": { |
298 |
"default": { |
299 |
"auto_balance": true, |
300 |
"vcpus": 1, |
301 |
"memory": 128 |
302 |
} |
303 |
} |
304 |
} |
305 |
|
306 |
|
307 |
``/2/redistribute-config`` |
308 |
++++++++++++++++++++++++++ |
309 |
|
310 |
Redistribute configuration to all nodes. |
311 |
|
312 |
It supports the following commands: ``PUT``. |
313 |
|
314 |
``PUT`` |
315 |
~~~~~~~ |
316 |
|
317 |
Redistribute configuration to all nodes. The result will be a job id. |
318 |
|
319 |
|
320 |
``/2/features`` |
321 |
+++++++++++++++ |
322 |
|
323 |
``GET`` |
324 |
~~~~~~~ |
325 |
|
326 |
Returns a list of features supported by the RAPI server. Available |
327 |
features: |
328 |
|
329 |
``instance-create-reqv1`` |
330 |
Instance creation request data version 1 supported. |
331 |
``instance-reinstall-reqv1`` |
332 |
Instance reinstall supports body parameters. |
333 |
|
334 |
|
335 |
``/2/instances`` |
336 |
++++++++++++++++ |
337 |
|
338 |
The instances resource. |
339 |
|
340 |
It supports the following commands: ``GET``, ``POST``. |
341 |
|
342 |
``GET`` |
343 |
~~~~~~~ |
344 |
|
345 |
Returns a list of all available instances. |
346 |
|
347 |
Example:: |
348 |
|
349 |
[ |
350 |
{ |
351 |
"name": "web.example.com", |
352 |
"uri": "\/instances\/web.example.com" |
353 |
}, |
354 |
{ |
355 |
"name": "mail.example.com", |
356 |
"uri": "\/instances\/mail.example.com" |
357 |
} |
358 |
] |
359 |
|
360 |
If the optional bool *bulk* argument is provided and set to a true value |
361 |
(i.e ``?bulk=1``), the output contains detailed information about |
362 |
instances as a list. |
363 |
|
364 |
Example:: |
365 |
|
366 |
[ |
367 |
{ |
368 |
"status": "running", |
369 |
"disk_usage": 20480, |
370 |
"nic.bridges": [ |
371 |
"xen-br0" |
372 |
], |
373 |
"name": "web.example.com", |
374 |
"tags": ["tag1", "tag2"], |
375 |
"beparams": { |
376 |
"vcpus": 2, |
377 |
"memory": 512 |
378 |
}, |
379 |
"disk.sizes": [ |
380 |
20480 |
381 |
], |
382 |
"pnode": "node1.example.com", |
383 |
"nic.macs": ["01:23:45:67:89:01"], |
384 |
"snodes": ["node2.example.com"], |
385 |
"disk_template": "drbd", |
386 |
"admin_state": true, |
387 |
"os": "debian-etch", |
388 |
"oper_state": true |
389 |
}, |
390 |
... |
391 |
] |
392 |
|
393 |
|
394 |
``POST`` |
395 |
~~~~~~~~ |
396 |
|
397 |
Creates an instance. |
398 |
|
399 |
If the optional bool *dry-run* argument is provided, the job will not be |
400 |
actually executed, only the pre-execution checks will be done. Query-ing |
401 |
the job result will return, in both dry-run and normal case, the list of |
402 |
nodes selected for the instance. |
403 |
|
404 |
Returns: a job ID that can be used later for polling. |
405 |
|
406 |
Body parameters: |
407 |
|
408 |
``__version__`` (int, required) |
409 |
Must be ``1`` (older Ganeti versions used a different format for |
410 |
instance creation requests, version ``0``, but that format is not |
411 |
documented). |
412 |
``mode`` (string, required) |
413 |
Instance creation mode. |
414 |
``name`` (string, required) |
415 |
Instance name. |
416 |
``disk_template`` (string, required) |
417 |
Disk template for instance. |
418 |
``disks`` (list, required) |
419 |
List of disk definitions. Example: ``[{"size": 100}, {"size": 5}]``. |
420 |
Each disk definition must contain a ``size`` value and can contain an |
421 |
optional ``mode`` value denoting the disk access mode (``ro`` or |
422 |
``rw``). |
423 |
``nics`` (list, required) |
424 |
List of NIC (network interface) definitions. Example: ``[{}, {}, |
425 |
{"ip": "198.51.100.4"}]``. Each NIC definition can contain the |
426 |
optional values ``ip``, ``mode``, ``link`` and ``bridge``. |
427 |
``os`` (string, required) |
428 |
Instance operating system. |
429 |
``osparams`` (dictionary) |
430 |
Dictionary with OS parameters. If not valid for the given OS, the job |
431 |
will fail. |
432 |
``force_variant`` (bool) |
433 |
Whether to force an unknown variant. |
434 |
``no_install`` (bool) |
435 |
Do not install the OS (will enable no-start) |
436 |
``pnode`` (string) |
437 |
Primary node. |
438 |
``snode`` (string) |
439 |
Secondary node. |
440 |
``src_node`` (string) |
441 |
Source node for import. |
442 |
``src_path`` (string) |
443 |
Source directory for import. |
444 |
``start`` (bool) |
445 |
Whether to start instance after creation. |
446 |
``ip_check`` (bool) |
447 |
Whether to ensure instance's IP address is inactive. |
448 |
``name_check`` (bool) |
449 |
Whether to ensure instance's name is resolvable. |
450 |
``file_storage_dir`` (string) |
451 |
File storage directory. |
452 |
``file_driver`` (string) |
453 |
File storage driver. |
454 |
``iallocator`` (string) |
455 |
Instance allocator name. |
456 |
``source_handshake`` (list) |
457 |
Signed handshake from source (remote import only). |
458 |
``source_x509_ca`` (string) |
459 |
Source X509 CA in PEM format (remote import only). |
460 |
``source_instance_name`` (string) |
461 |
Source instance name (remote import only). |
462 |
``hypervisor`` (string) |
463 |
Hypervisor name. |
464 |
``hvparams`` (dict) |
465 |
Hypervisor parameters, hypervisor-dependent. |
466 |
``beparams`` (dict) |
467 |
Backend parameters. |
468 |
|
469 |
|
470 |
``/2/instances/[instance_name]`` |
471 |
++++++++++++++++++++++++++++++++ |
472 |
|
473 |
Instance-specific resource. |
474 |
|
475 |
It supports the following commands: ``GET``, ``DELETE``. |
476 |
|
477 |
``GET`` |
478 |
~~~~~~~ |
479 |
|
480 |
Returns information about an instance, similar to the bulk output from |
481 |
the instance list. |
482 |
|
483 |
``DELETE`` |
484 |
~~~~~~~~~~ |
485 |
|
486 |
Deletes an instance. |
487 |
|
488 |
It supports the ``dry-run`` argument. |
489 |
|
490 |
|
491 |
``/2/instances/[instance_name]/info`` |
492 |
+++++++++++++++++++++++++++++++++++++++ |
493 |
|
494 |
It supports the following commands: ``GET``. |
495 |
|
496 |
``GET`` |
497 |
~~~~~~~ |
498 |
|
499 |
Requests detailed information about the instance. An optional parameter, |
500 |
``static`` (bool), can be set to return only static information from the |
501 |
configuration without querying the instance's nodes. The result will be |
502 |
a job id. |
503 |
|
504 |
|
505 |
``/2/instances/[instance_name]/reboot`` |
506 |
+++++++++++++++++++++++++++++++++++++++ |
507 |
|
508 |
Reboots URI for an instance. |
509 |
|
510 |
It supports the following commands: ``POST``. |
511 |
|
512 |
``POST`` |
513 |
~~~~~~~~ |
514 |
|
515 |
Reboots the instance. |
516 |
|
517 |
The URI takes optional ``type=soft|hard|full`` and |
518 |
``ignore_secondaries=0|1`` parameters. |
519 |
|
520 |
``type`` defines the reboot type. ``soft`` is just a normal reboot, |
521 |
without terminating the hypervisor. ``hard`` means full shutdown |
522 |
(including terminating the hypervisor process) and startup again. |
523 |
``full`` is like ``hard`` but also recreates the configuration from |
524 |
ground up as if you would have done a ``gnt-instance shutdown`` and |
525 |
``gnt-instance start`` on it. |
526 |
|
527 |
``ignore_secondaries`` is a bool argument indicating if we start the |
528 |
instance even if secondary disks are failing. |
529 |
|
530 |
It supports the ``dry-run`` argument. |
531 |
|
532 |
|
533 |
``/2/instances/[instance_name]/shutdown`` |
534 |
+++++++++++++++++++++++++++++++++++++++++ |
535 |
|
536 |
Instance shutdown URI. |
537 |
|
538 |
It supports the following commands: ``PUT``. |
539 |
|
540 |
``PUT`` |
541 |
~~~~~~~ |
542 |
|
543 |
Shutdowns an instance. |
544 |
|
545 |
It supports the ``dry-run`` argument. |
546 |
|
547 |
|
548 |
``/2/instances/[instance_name]/startup`` |
549 |
++++++++++++++++++++++++++++++++++++++++ |
550 |
|
551 |
Instance startup URI. |
552 |
|
553 |
It supports the following commands: ``PUT``. |
554 |
|
555 |
``PUT`` |
556 |
~~~~~~~ |
557 |
|
558 |
Startup an instance. |
559 |
|
560 |
The URI takes an optional ``force=1|0`` parameter to start the |
561 |
instance even if secondary disks are failing. |
562 |
|
563 |
It supports the ``dry-run`` argument. |
564 |
|
565 |
``/2/instances/[instance_name]/reinstall`` |
566 |
++++++++++++++++++++++++++++++++++++++++++++++ |
567 |
|
568 |
Installs the operating system again. |
569 |
|
570 |
It supports the following commands: ``POST``. |
571 |
|
572 |
``POST`` |
573 |
~~~~~~~~ |
574 |
|
575 |
Returns a job ID. |
576 |
|
577 |
Body parameters: |
578 |
|
579 |
``os`` (string, required) |
580 |
Instance operating system. |
581 |
``start`` (bool, defaults to true) |
582 |
Whether to start instance after reinstallation. |
583 |
``osparams`` (dict) |
584 |
Dictionary with (temporary) OS parameters. |
585 |
|
586 |
For backwards compatbility, this resource also takes the query |
587 |
parameters ``os`` (OS template name) and ``nostartup`` (bool). New |
588 |
clients should use the body parameters. |
589 |
|
590 |
|
591 |
``/2/instances/[instance_name]/replace-disks`` |
592 |
++++++++++++++++++++++++++++++++++++++++++++++ |
593 |
|
594 |
Replaces disks on an instance. |
595 |
|
596 |
It supports the following commands: ``POST``. |
597 |
|
598 |
``POST`` |
599 |
~~~~~~~~ |
600 |
|
601 |
Takes the parameters ``mode`` (one of ``replace_on_primary``, |
602 |
``replace_on_secondary``, ``replace_new_secondary`` or |
603 |
``replace_auto``), ``disks`` (comma separated list of disk indexes), |
604 |
``remote_node`` and ``iallocator``. |
605 |
|
606 |
Either ``remote_node`` or ``iallocator`` needs to be defined when using |
607 |
``mode=replace_new_secondary``. |
608 |
|
609 |
``mode`` is a mandatory parameter. ``replace_auto`` tries to determine |
610 |
the broken disk(s) on its own and replacing it. |
611 |
|
612 |
|
613 |
``/2/instances/[instance_name]/activate-disks`` |
614 |
+++++++++++++++++++++++++++++++++++++++++++++++ |
615 |
|
616 |
Activate disks on an instance. |
617 |
|
618 |
It supports the following commands: ``PUT``. |
619 |
|
620 |
``PUT`` |
621 |
~~~~~~~ |
622 |
|
623 |
Takes the bool parameter ``ignore_size``. When set ignore the recorded |
624 |
size (useful for forcing activation when recorded size is wrong). |
625 |
|
626 |
|
627 |
``/2/instances/[instance_name]/deactivate-disks`` |
628 |
+++++++++++++++++++++++++++++++++++++++++++++++++ |
629 |
|
630 |
Deactivate disks on an instance. |
631 |
|
632 |
It supports the following commands: ``PUT``. |
633 |
|
634 |
``PUT`` |
635 |
~~~~~~~ |
636 |
|
637 |
Takes no parameters. |
638 |
|
639 |
|
640 |
``/2/instances/[instance_name]/prepare-export`` |
641 |
+++++++++++++++++++++++++++++++++++++++++++++++++ |
642 |
|
643 |
Prepares an export of an instance. |
644 |
|
645 |
It supports the following commands: ``PUT``. |
646 |
|
647 |
``PUT`` |
648 |
~~~~~~~ |
649 |
|
650 |
Takes one parameter, ``mode``, for the export mode. Returns a job ID. |
651 |
|
652 |
|
653 |
``/2/instances/[instance_name]/export`` |
654 |
+++++++++++++++++++++++++++++++++++++++++++++++++ |
655 |
|
656 |
Exports an instance. |
657 |
|
658 |
It supports the following commands: ``PUT``. |
659 |
|
660 |
``PUT`` |
661 |
~~~~~~~ |
662 |
|
663 |
Returns a job ID. |
664 |
|
665 |
Body parameters: |
666 |
|
667 |
``mode`` (string) |
668 |
Export mode. |
669 |
``destination`` (required) |
670 |
Destination information, depends on export mode. |
671 |
``shutdown`` (bool, required) |
672 |
Whether to shutdown instance before export. |
673 |
``remove_instance`` (bool) |
674 |
Whether to remove instance after export. |
675 |
``x509_key_name`` |
676 |
Name of X509 key (remote export only). |
677 |
``destination_x509_ca`` |
678 |
Destination X509 CA (remote export only). |
679 |
|
680 |
|
681 |
``/2/instances/[instance_name]/migrate`` |
682 |
++++++++++++++++++++++++++++++++++++++++ |
683 |
|
684 |
Migrates an instance. |
685 |
|
686 |
Supports the following commands: ``PUT``. |
687 |
|
688 |
``PUT`` |
689 |
~~~~~~~ |
690 |
|
691 |
Returns a job ID. |
692 |
|
693 |
Body parameters: |
694 |
|
695 |
``mode`` (string) |
696 |
Migration mode. |
697 |
``cleanup`` (bool) |
698 |
Whether a previously failed migration should be cleaned up. |
699 |
|
700 |
|
701 |
``/2/instances/[instance_name]/rename`` |
702 |
++++++++++++++++++++++++++++++++++++++++ |
703 |
|
704 |
Renames an instance. |
705 |
|
706 |
Supports the following commands: ``PUT``. |
707 |
|
708 |
``PUT`` |
709 |
~~~~~~~ |
710 |
|
711 |
Returns a job ID. |
712 |
|
713 |
Body parameters: |
714 |
|
715 |
``new_name`` (string, required) |
716 |
New instance name. |
717 |
``ip_check`` (bool) |
718 |
Whether to ensure instance's IP address is inactive. |
719 |
``name_check`` (bool) |
720 |
Whether to ensure instance's name is resolvable. |
721 |
|
722 |
|
723 |
``/2/instances/[instance_name]/modify`` |
724 |
++++++++++++++++++++++++++++++++++++++++ |
725 |
|
726 |
Modifies an instance. |
727 |
|
728 |
Supports the following commands: ``PUT``. |
729 |
|
730 |
``PUT`` |
731 |
~~~~~~~ |
732 |
|
733 |
Returns a job ID. |
734 |
|
735 |
Body parameters: |
736 |
|
737 |
``osparams`` (dict) |
738 |
Dictionary with OS parameters. |
739 |
``hvparams`` (dict) |
740 |
Hypervisor parameters, hypervisor-dependent. |
741 |
``beparams`` (dict) |
742 |
Backend parameters. |
743 |
``force`` (bool) |
744 |
Whether to force the operation. |
745 |
``nics`` (list) |
746 |
List of NIC changes. Each item is of the form ``(op, settings)``. |
747 |
``op`` can be ``add`` to add a new NIC with the specified settings, |
748 |
``remove`` to remove the last NIC or a number to modify the settings |
749 |
of the NIC with that index. |
750 |
``disks`` (list) |
751 |
List of disk changes. See ``nics``. |
752 |
``disk_template`` (string) |
753 |
Disk template for instance. |
754 |
``remote_node`` (string) |
755 |
Secondary node (used when changing disk template). |
756 |
``os_name`` (string) |
757 |
Change instance's OS name. Does not reinstall the instance. |
758 |
``force_variant`` (bool) |
759 |
Whether to force an unknown variant. |
760 |
|
761 |
|
762 |
``/2/instances/[instance_name]/tags`` |
763 |
+++++++++++++++++++++++++++++++++++++ |
764 |
|
765 |
Manages per-instance tags. |
766 |
|
767 |
It supports the following commands: ``GET``, ``PUT``, ``DELETE``. |
768 |
|
769 |
``GET`` |
770 |
~~~~~~~ |
771 |
|
772 |
Returns a list of tags. |
773 |
|
774 |
Example:: |
775 |
|
776 |
["tag1", "tag2", "tag3"] |
777 |
|
778 |
``PUT`` |
779 |
~~~~~~~ |
780 |
|
781 |
Add a set of tags. |
782 |
|
783 |
The request as a list of strings should be ``PUT`` to this URI. The |
784 |
result will be a job id. |
785 |
|
786 |
It supports the ``dry-run`` argument. |
787 |
|
788 |
|
789 |
``DELETE`` |
790 |
~~~~~~~~~~ |
791 |
|
792 |
Delete a tag. |
793 |
|
794 |
In order to delete a set of tags, the DELETE request should be addressed |
795 |
to URI like:: |
796 |
|
797 |
/tags?tag=[tag]&tag=[tag] |
798 |
|
799 |
It supports the ``dry-run`` argument. |
800 |
|
801 |
|
802 |
``/2/jobs`` |
803 |
+++++++++++ |
804 |
|
805 |
The ``/2/jobs`` resource. |
806 |
|
807 |
It supports the following commands: ``GET``. |
808 |
|
809 |
``GET`` |
810 |
~~~~~~~ |
811 |
|
812 |
Returns a dictionary of jobs. |
813 |
|
814 |
Returns: a dictionary with jobs id and uri. |
815 |
|
816 |
``/2/jobs/[job_id]`` |
817 |
++++++++++++++++++++ |
818 |
|
819 |
|
820 |
Individual job URI. |
821 |
|
822 |
It supports the following commands: ``GET``, ``DELETE``. |
823 |
|
824 |
``GET`` |
825 |
~~~~~~~ |
826 |
|
827 |
Returns a job status. |
828 |
|
829 |
Returns: a dictionary with job parameters. |
830 |
|
831 |
The result includes: |
832 |
|
833 |
- id: job ID as a number |
834 |
- status: current job status as a string |
835 |
- ops: involved OpCodes as a list of dictionaries for each opcodes in |
836 |
the job |
837 |
- opstatus: OpCodes status as a list |
838 |
- opresult: OpCodes results as a list |
839 |
|
840 |
For a successful opcode, the ``opresult`` field corresponding to it will |
841 |
contain the raw result from its :term:`LogicalUnit`. In case an opcode |
842 |
has failed, its element in the opresult list will be a list of two |
843 |
elements: |
844 |
|
845 |
- first element the error type (the Ganeti internal error name) |
846 |
- second element a list of either one or two elements: |
847 |
|
848 |
- the first element is the textual error description |
849 |
- the second element, if any, will hold an error classification |
850 |
|
851 |
The error classification is most useful for the ``OpPrereqError`` |
852 |
error type - these errors happen before the OpCode has started |
853 |
executing, so it's possible to retry the OpCode without side |
854 |
effects. But whether it make sense to retry depends on the error |
855 |
classification: |
856 |
|
857 |
``resolver_error`` |
858 |
Resolver errors. This usually means that a name doesn't exist in DNS, |
859 |
so if it's a case of slow DNS propagation the operation can be retried |
860 |
later. |
861 |
|
862 |
``insufficient_resources`` |
863 |
Not enough resources (iallocator failure, disk space, memory, |
864 |
etc.). If the resources on the cluster increase, the operation might |
865 |
succeed. |
866 |
|
867 |
``wrong_input`` |
868 |
Wrong arguments (at syntax level). The operation will not ever be |
869 |
accepted unless the arguments change. |
870 |
|
871 |
``wrong_state`` |
872 |
Wrong entity state. For example, live migration has been requested for |
873 |
a down instance, or instance creation on an offline node. The |
874 |
operation can be retried once the resource has changed state. |
875 |
|
876 |
``unknown_entity`` |
877 |
Entity not found. For example, information has been requested for an |
878 |
unknown instance. |
879 |
|
880 |
``already_exists`` |
881 |
Entity already exists. For example, instance creation has been |
882 |
requested for an already-existing instance. |
883 |
|
884 |
``resource_not_unique`` |
885 |
Resource not unique (e.g. MAC or IP duplication). |
886 |
|
887 |
``internal_error`` |
888 |
Internal cluster error. For example, a node is unreachable but not set |
889 |
offline, or the ganeti node daemons are not working, etc. A |
890 |
``gnt-cluster verify`` should be run. |
891 |
|
892 |
``environment_error`` |
893 |
Environment error (e.g. node disk error). A ``gnt-cluster verify`` |
894 |
should be run. |
895 |
|
896 |
Note that in the above list, by entity we refer to a node or instance, |
897 |
while by a resource we refer to an instance's disk, or NIC, etc. |
898 |
|
899 |
|
900 |
``DELETE`` |
901 |
~~~~~~~~~~ |
902 |
|
903 |
Cancel a not-yet-started job. |
904 |
|
905 |
|
906 |
``/2/jobs/[job_id]/wait`` |
907 |
+++++++++++++++++++++++++ |
908 |
|
909 |
``GET`` |
910 |
~~~~~~~ |
911 |
|
912 |
Waits for changes on a job. Takes the following body parameters in a |
913 |
dict: |
914 |
|
915 |
``fields`` |
916 |
The job fields on which to watch for changes. |
917 |
|
918 |
``previous_job_info`` |
919 |
Previously received field values or None if not yet available. |
920 |
|
921 |
``previous_log_serial`` |
922 |
Highest log serial number received so far or None if not yet |
923 |
available. |
924 |
|
925 |
Returns None if no changes have been detected and a dict with two keys, |
926 |
``job_info`` and ``log_entries`` otherwise. |
927 |
|
928 |
|
929 |
``/2/nodes`` |
930 |
++++++++++++ |
931 |
|
932 |
Nodes resource. |
933 |
|
934 |
It supports the following commands: ``GET``. |
935 |
|
936 |
``GET`` |
937 |
~~~~~~~ |
938 |
|
939 |
Returns a list of all nodes. |
940 |
|
941 |
Example:: |
942 |
|
943 |
[ |
944 |
{ |
945 |
"id": "node1.example.com", |
946 |
"uri": "\/nodes\/node1.example.com" |
947 |
}, |
948 |
{ |
949 |
"id": "node2.example.com", |
950 |
"uri": "\/nodes\/node2.example.com" |
951 |
} |
952 |
] |
953 |
|
954 |
If the optional 'bulk' argument is provided and set to 'true' value (i.e |
955 |
'?bulk=1'), the output contains detailed information about nodes as a |
956 |
list. |
957 |
|
958 |
Example:: |
959 |
|
960 |
[ |
961 |
{ |
962 |
"pinst_cnt": 1, |
963 |
"mfree": 31280, |
964 |
"mtotal": 32763, |
965 |
"name": "www.example.com", |
966 |
"tags": [], |
967 |
"mnode": 512, |
968 |
"dtotal": 5246208, |
969 |
"sinst_cnt": 2, |
970 |
"dfree": 5171712, |
971 |
"offline": false |
972 |
}, |
973 |
... |
974 |
] |
975 |
|
976 |
``/2/nodes/[node_name]`` |
977 |
+++++++++++++++++++++++++++++++++ |
978 |
|
979 |
Returns information about a node. |
980 |
|
981 |
It supports the following commands: ``GET``. |
982 |
|
983 |
``/2/nodes/[node_name]/evacuate`` |
984 |
+++++++++++++++++++++++++++++++++ |
985 |
|
986 |
Evacuates all secondary instances off a node. |
987 |
|
988 |
It supports the following commands: ``POST``. |
989 |
|
990 |
``POST`` |
991 |
~~~~~~~~ |
992 |
|
993 |
To evacuate a node, either one of the ``iallocator`` or ``remote_node`` |
994 |
parameters must be passed:: |
995 |
|
996 |
evacuate?iallocator=[iallocator] |
997 |
evacuate?remote_node=[nodeX.example.com] |
998 |
|
999 |
The result value will be a list, each element being a triple of the job |
1000 |
id (for this specific evacuation), the instance which is being evacuated |
1001 |
by this job, and the node to which it is being relocated. In case the |
1002 |
node is already empty, the result will be an empty list (without any |
1003 |
jobs being submitted). |
1004 |
|
1005 |
And additional parameter ``early_release`` signifies whether to try to |
1006 |
parallelize the evacuations, at the risk of increasing I/O contention |
1007 |
and increasing the chances of data loss, if the primary node of any of |
1008 |
the instances being evacuated is not fully healthy. |
1009 |
|
1010 |
If the dry-run parameter was specified, then the evacuation jobs were |
1011 |
not actually submitted, and the job IDs will be null. |
1012 |
|
1013 |
|
1014 |
``/2/nodes/[node_name]/migrate`` |
1015 |
+++++++++++++++++++++++++++++++++ |
1016 |
|
1017 |
Migrates all primary instances from a node. |
1018 |
|
1019 |
It supports the following commands: ``POST``. |
1020 |
|
1021 |
``POST`` |
1022 |
~~~~~~~~ |
1023 |
|
1024 |
If no mode is explicitly specified, each instances' hypervisor default |
1025 |
migration mode will be used. Query parameters: |
1026 |
|
1027 |
``live`` (bool) |
1028 |
If set, use live migration if available. |
1029 |
``mode`` (string) |
1030 |
Sets migration mode, ``live`` for live migration and ``non-live`` for |
1031 |
non-live migration. Supported by Ganeti 2.2 and above. |
1032 |
|
1033 |
|
1034 |
``/2/nodes/[node_name]/role`` |
1035 |
+++++++++++++++++++++++++++++ |
1036 |
|
1037 |
Manages node role. |
1038 |
|
1039 |
It supports the following commands: ``GET``, ``PUT``. |
1040 |
|
1041 |
The role is always one of the following: |
1042 |
|
1043 |
- drained |
1044 |
- master |
1045 |
- master-candidate |
1046 |
- offline |
1047 |
- regular |
1048 |
|
1049 |
``GET`` |
1050 |
~~~~~~~ |
1051 |
|
1052 |
Returns the current node role. |
1053 |
|
1054 |
Example:: |
1055 |
|
1056 |
"master-candidate" |
1057 |
|
1058 |
``PUT`` |
1059 |
~~~~~~~ |
1060 |
|
1061 |
Change the node role. |
1062 |
|
1063 |
The request is a string which should be PUT to this URI. The result will |
1064 |
be a job id. |
1065 |
|
1066 |
It supports the bool ``force`` argument. |
1067 |
|
1068 |
``/2/nodes/[node_name]/storage`` |
1069 |
++++++++++++++++++++++++++++++++ |
1070 |
|
1071 |
Manages storage units on the node. |
1072 |
|
1073 |
``GET`` |
1074 |
~~~~~~~ |
1075 |
|
1076 |
Requests a list of storage units on a node. Requires the parameters |
1077 |
``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) and |
1078 |
``output_fields``. The result will be a job id, using which the result |
1079 |
can be retrieved. |
1080 |
|
1081 |
``/2/nodes/[node_name]/storage/modify`` |
1082 |
+++++++++++++++++++++++++++++++++++++++ |
1083 |
|
1084 |
Modifies storage units on the node. |
1085 |
|
1086 |
``PUT`` |
1087 |
~~~~~~~ |
1088 |
|
1089 |
Modifies parameters of storage units on the node. Requires the |
1090 |
parameters ``storage_type`` (one of ``file``, ``lvm-pv`` or ``lvm-vg``) |
1091 |
and ``name`` (name of the storage unit). Parameters can be passed |
1092 |
additionally. Currently only ``allocatable`` (bool) is supported. The |
1093 |
result will be a job id. |
1094 |
|
1095 |
``/2/nodes/[node_name]/storage/repair`` |
1096 |
+++++++++++++++++++++++++++++++++++++++ |
1097 |
|
1098 |
Repairs a storage unit on the node. |
1099 |
|
1100 |
``PUT`` |
1101 |
~~~~~~~ |
1102 |
|
1103 |
Repairs a storage unit on the node. Requires the parameters |
1104 |
``storage_type`` (currently only ``lvm-vg`` can be repaired) and |
1105 |
``name`` (name of the storage unit). The result will be a job id. |
1106 |
|
1107 |
``/2/nodes/[node_name]/tags`` |
1108 |
+++++++++++++++++++++++++++++ |
1109 |
|
1110 |
Manages per-node tags. |
1111 |
|
1112 |
It supports the following commands: ``GET``, ``PUT``, ``DELETE``. |
1113 |
|
1114 |
``GET`` |
1115 |
~~~~~~~ |
1116 |
|
1117 |
Returns a list of tags. |
1118 |
|
1119 |
Example:: |
1120 |
|
1121 |
["tag1", "tag2", "tag3"] |
1122 |
|
1123 |
``PUT`` |
1124 |
~~~~~~~ |
1125 |
|
1126 |
Add a set of tags. |
1127 |
|
1128 |
The request as a list of strings should be PUT to this URI. The result |
1129 |
will be a job id. |
1130 |
|
1131 |
It supports the ``dry-run`` argument. |
1132 |
|
1133 |
``DELETE`` |
1134 |
~~~~~~~~~~ |
1135 |
|
1136 |
Deletes tags. |
1137 |
|
1138 |
In order to delete a set of tags, the DELETE request should be addressed |
1139 |
to URI like:: |
1140 |
|
1141 |
/tags?tag=[tag]&tag=[tag] |
1142 |
|
1143 |
It supports the ``dry-run`` argument. |
1144 |
|
1145 |
|
1146 |
``/2/os`` |
1147 |
+++++++++ |
1148 |
|
1149 |
OS resource. |
1150 |
|
1151 |
It supports the following commands: ``GET``. |
1152 |
|
1153 |
``GET`` |
1154 |
~~~~~~~ |
1155 |
|
1156 |
Return a list of all OSes. |
1157 |
|
1158 |
Can return error 500 in case of a problem. Since this is a costly |
1159 |
operation for Ganeti 2.0, it is not recommended to execute it too often. |
1160 |
|
1161 |
Example:: |
1162 |
|
1163 |
["debian-etch"] |
1164 |
|
1165 |
``/2/tags`` |
1166 |
+++++++++++ |
1167 |
|
1168 |
Manages cluster tags. |
1169 |
|
1170 |
It supports the following commands: ``GET``, ``PUT``, ``DELETE``. |
1171 |
|
1172 |
``GET`` |
1173 |
~~~~~~~ |
1174 |
|
1175 |
Returns the cluster tags. |
1176 |
|
1177 |
Example:: |
1178 |
|
1179 |
["tag1", "tag2", "tag3"] |
1180 |
|
1181 |
``PUT`` |
1182 |
~~~~~~~ |
1183 |
|
1184 |
Adds a set of tags. |
1185 |
|
1186 |
The request as a list of strings should be PUT to this URI. The result |
1187 |
will be a job id. |
1188 |
|
1189 |
It supports the ``dry-run`` argument. |
1190 |
|
1191 |
|
1192 |
``DELETE`` |
1193 |
~~~~~~~~~~ |
1194 |
|
1195 |
Deletes tags. |
1196 |
|
1197 |
In order to delete a set of tags, the DELETE request should be addressed |
1198 |
to URI like:: |
1199 |
|
1200 |
/tags?tag=[tag]&tag=[tag] |
1201 |
|
1202 |
It supports the ``dry-run`` argument. |
1203 |
|
1204 |
|
1205 |
``/version`` |
1206 |
++++++++++++ |
1207 |
|
1208 |
The version resource. |
1209 |
|
1210 |
This resource should be used to determine the remote API version and to |
1211 |
adapt clients accordingly. |
1212 |
|
1213 |
It supports the following commands: ``GET``. |
1214 |
|
1215 |
``GET`` |
1216 |
~~~~~~~ |
1217 |
|
1218 |
Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti 2.0 |
1219 |
returns ``2``. |
1220 |
|
1221 |
.. vim: set textwidth=72 : |
1222 |
.. Local Variables: |
1223 |
.. mode: rst |
1224 |
.. fill-column: 72 |
1225 |
.. End: |