Revision c8e0a534 doc/rapi.rst

b/doc/rapi.rst
1 1
Ganeti remote API
2 2
=================
3 3

  
4
Documents Ganeti version 2.0
4
Documents Ganeti version |version|
5 5

  
6 6
.. contents::
7 7

  
......
34 34
Shell
35 35
+++++
36 36

  
37
.. highlight:: sh
38

  
37 39
Using wget::
38 40

  
39
  wget -q -O - https://CLUSTERNAME:5080/2/info
41
   wget -q -O - https://CLUSTERNAME:5080/2/info
40 42

  
41 43
or curl::
42 44

  
......
46 48
Python
47 49
++++++
48 50

  
49
::
51
.. highlight: python
50 52

  
51 53
  import urllib2
52 54
  f = urllib2.urlopen('https://CLUSTERNAME:5080/2/info')
......
61 63
  non-standard ports or different domain names. Fetching the data
62 64
  on the webserver is easier.
63 65

  
66
.. highlight:: javascript
67

  
64 68
::
65 69

  
66 70
  var url = 'https://CLUSTERNAME:5080/2/info';
......
82 86
Resources
83 87
---------
84 88

  
85
/
86
+
87

  
88
::
89

  
90
  / resource.
91

  
92
It supports the following commands: GET.
89
.. highlight:: javascript
93 90

  
94
GET
95
~~~
91
``/``
92
+++++
96 93

  
97
::
94
The root resource.
98 95

  
99
  Show the list of mapped resources.
96
It supports the following commands: ``GET``.
100 97

  
101
  Returns: a dictionary with 'name' and 'uri' keys for each of them.
98
``GET``
99
~~~~~~~
102 100

  
103
/2
104
++
101
Shows the list of mapped resources.
105 102

  
106
::
103
Returns: a dictionary with 'name' and 'uri' keys for each of them.
107 104

  
108
  /2 resource, the root of the version 2 API.
105
``/2``
106
++++++
109 107

  
110
It supports the following commands: GET.
108
The ``/2`` resource, the root of the version 2 API.
111 109

  
112
GET
113
~~~
110
It supports the following commands: ``GET``.
114 111

  
115
::
112
``GET``
113
~~~~~~~
116 114

  
117
  Show the list of mapped resources.
115
Show the list of mapped resources.
118 116

  
119
  Returns: a dictionary with 'name' and 'uri' keys for each of them.
117
Returns: a dictionary with ``name`` and ``uri`` keys for each of them.
120 118

  
121
/2/info
122
+++++++
119
``/2/info``
120
+++++++++++
123 121

  
124
::
122
Cluster information resource.
125 123

  
126
  Cluster info.
124
It supports the following commands: ``GET``.
127 125

  
128
It supports the following commands: GET.
126
``GET``
127
~~~~~~~
129 128

  
130
GET
131
~~~
129
Returns cluster information.
132 130

  
133
::
134

  
135
  Returns cluster information.
136

  
137
  Example::
131
Example::
138 132

  
139 133
  {
140 134
    "config_version": 2000000,
......
165 159
      }
166 160
    }
167 161

  
168
/2/instances
169
++++++++++++
170

  
171
::
162
``/2/instances``
163
++++++++++++++++
172 164

  
173
  /2/instances resource.
165
The instances resource.
174 166

  
175
It supports the following commands: GET, POST.
167
It supports the following commands: ``GET``, ``POST``.
176 168

  
177
GET
178
~~~
169
``GET``
170
~~~~~~~
179 171

  
180
::
172
Returns a list of all available instances.
181 173

  
182
  Returns a list of all available instances.
183 174

  
184

  
185
  Example::
175
Example::
186 176

  
187 177
    [
188 178
      {
......
195 185
      }
196 186
    ]
197 187

  
198
  If the optional 'bulk' argument is provided and set to 'true'
199
  value (i.e '?bulk=1'), the output contains detailed
200
  information about instances as a list.
188
If the optional *bulk* argument is provided and set to a true value
189
(i.e ``?bulk=1``), the output contains detailed information about
190
instances as a list.
201 191

  
202
  Example::
192
Example::
203 193

  
204 194
    [
205 195
      {
......
228 218
      ...
229 219
    ]
230 220

  
231
  Returns: a dictionary with 'name' and 'uri' keys for each of them.
232

  
233
POST
234
~~~~
235

  
236
::
237

  
238
  Create an instance.
239

  
240
  Returns: a job id
241

  
242
/2/instances/[instance_name]
243
++++++++++++++++++++++++++++
244

  
245
::
246

  
247
  /2/instances/[instance_name] resources.
248

  
249
It supports the following commands: GET, DELETE.
250

  
251
GET
252
~~~
253

  
254
::
255

  
256
  Send information about an instance.
257

  
258

  
259

  
260
DELETE
261
~~~~~~
262

  
263
::
264

  
265
  Delete an instance.
266

  
267

  
268

  
269
/2/instances/[instance_name]/reboot
270
+++++++++++++++++++++++++++++++++++
271

  
272
::
273

  
274
  /2/instances/[instance_name]/reboot resource.
275

  
276
  Implements an instance reboot.
277

  
278
It supports the following commands: POST.
279

  
280
POST
281
~~~~
282

  
283
::
284

  
285
  Reboot an instance.
286 221

  
287
  The URI takes type=[hard|soft|full] and
288
  ignore_secondaries=[False|True] parameters.
222
``POST``
223
~~~~~~~~
289 224

  
290
/2/instances/[instance_name]/shutdown
291
+++++++++++++++++++++++++++++++++++++
225
Creates an instance.
292 226

  
293
::
227
Returns: a job ID that can be used later for polling.
294 228

  
295
  /2/instances/[instance_name]/shutdown resource.
229
``/2/instances/[instance_name]``
230
++++++++++++++++++++++++++++++++
296 231

  
297
  Implements an instance shutdown.
232
Instance-specific resource.
298 233

  
299
It supports the following commands: PUT.
234
It supports the following commands: ``GET``, ``DELETE``.
300 235

  
301
PUT
302
~~~
236
``GET``
237
~~~~~~~
303 238

  
304
::
239
Returns information about an instance, similar to the bulk output from
240
the instance list.
305 241

  
306
  Shutdown an instance.
242
``DELETE``
243
~~~~~~~~~~
307 244

  
245
Deletes an instance.
308 246

  
309 247

  
310
/2/instances/[instance_name]/startup
311
++++++++++++++++++++++++++++++++++++
248
``/2/instances/[instance_name]/reboot``
249
+++++++++++++++++++++++++++++++++++++++
312 250

  
313
::
251
Reboots URI for an instance.
314 252

  
315
  /2/instances/[instance_name]/startup resource.
253
It supports the following commands: ``POST``.
316 254

  
317
  Implements an instance startup.
255
``POST``
256
~~~~~~~~
318 257

  
319
It supports the following commands: PUT.
258
Reboots the instance.
320 259

  
321
PUT
322
~~~
260
The URI takes optional ``type=hard|soft|full`` and
261
``ignore_secondaries=False|True`` parameters.
323 262

  
324
::
263
``/2/instances/[instance_name]/shutdown``
264
+++++++++++++++++++++++++++++++++++++++++
325 265

  
326
  Startup an instance.
266
Instance shutdown URI.
327 267

  
328
  The URI takes force=[False|True] parameter to start the instance
329
  if even if secondary disks are failing.
268
It supports the following commands: ``PUT``.
330 269

  
331
/2/instances/[instance_name]/tags
332
+++++++++++++++++++++++++++++++++
270
``PUT``
271
~~~~~~~
333 272

  
334
::
273
Shutdowns an instance.
335 274

  
336
  /2/instances/[instance_name]/tags resource.
337 275

  
338
  Manages per-instance tags.
276
``/2/instances/[instance_name]/startup``
277
++++++++++++++++++++++++++++++++++++++++
339 278

  
340
It supports the following commands: GET, PUT, DELETE.
279
Instance startup URI.
341 280

  
342
GET
343
~~~
281
It supports the following commands: ``PUT``.
344 282

  
345
::
283
``PUT``
284
~~~~~~~
346 285

  
347
  Returns a list of tags.
286
Startup an instance.
348 287

  
349
  Example: ["tag1", "tag2", "tag3"]
288
The URI takes an optional ``force=False|True`` parameter to start the
289
instance if even if secondary disks are failing.
350 290

  
351
PUT
352
~~~
291
``/2/instances/[instance_name]/tags``
292
+++++++++++++++++++++++++++++++++++++
353 293

  
354
::
294
Manages per-instance tags.
355 295

  
356
  Add a set of tags.
296
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
357 297

  
358
  The request as a list of strings should be PUT to this URI. And
359
  you'll have back a job id.
298
``GET``
299
~~~~~~~
360 300

  
361
DELETE
362
~~~~~~
301
Returns a list of tags.
363 302

  
364
::
303
Example::
365 304

  
366
  Delete a tag.
305
    ["tag1", "tag2", "tag3"]
367 306

  
368
  In order to delete a set of tags, the DELETE
369
  request should be addressed to URI like:
370
  /tags?tag=[tag]&tag=[tag]
307
``PUT``
308
~~~~~~~
371 309

  
372
/2/jobs
373
+++++++
310
Add a set of tags.
374 311

  
375
::
312
The request as a list of strings should be ``PUT`` to this URI. The
313
result willl be a job id.
376 314

  
377
  /2/jobs resource.
315
``DELETE``
316
~~~~~~~~~~
378 317

  
379
It supports the following commands: GET.
318
Delete a tag.
380 319

  
381
GET
382
~~~
320
In order to delete a set of tags, the DELETE request should be
321
addressed to URI like::
383 322

  
384
::
323
    /tags?tag=[tag]&tag=[tag]
385 324

  
386
  Returns a dictionary of jobs.
325
``/2/jobs``
326
+++++++++++
387 327

  
388
  Returns: a dictionary with jobs id and uri.
328
The ``/2/jobs`` resource.
389 329

  
390
/2/jobs/[job_id]
391
++++++++++++++++
330
It supports the following commands: ``GET``.
392 331

  
393
::
332
``GET``
333
~~~~~~~
394 334

  
395
  /2/jobs/[job_id] resource.
335
Returns a dictionary of jobs.
396 336

  
397
It supports the following commands: GET, DELETE.
337
Returns: a dictionary with jobs id and uri.
398 338

  
399
GET
400
~~~
339
``/2/jobs/[job_id]``
340
++++++++++++++++++++
401 341

  
402
::
403 342

  
404
  Returns a job status.
343
Individual job URI.
405 344

  
406
  Returns: a dictionary with job parameters.
407
      The result includes:
408
          - id: job ID as a number
409
          - status: current job status as a string
410
          - ops: involved OpCodes as a list of dictionaries for each
411
            opcodes in the job
412
          - opstatus: OpCodes status as a list
413
          - opresult: OpCodes results as a list of lists
345
It supports the following commands: ``GET``, ``DELETE``.
414 346

  
415
DELETE
416
~~~~~~
347
``GET``
348
~~~~~~~
417 349

  
418
::
350
Returns a job status.
419 351

  
420
  Cancel not-yet-started job.
352
Returns: a dictionary with job parameters.
421 353

  
354
The result includes:
422 355

  
356
- id: job ID as a number
357
- status: current job status as a string
358
- ops: involved OpCodes as a list of dictionaries for each
359
  opcodes in the job
360
- opstatus: OpCodes status as a list
361
- opresult: OpCodes results as a list of lists
423 362

  
424
/2/nodes
425
++++++++
363
``DELETE``
364
~~~~~~~~~~
426 365

  
427
::
366
Cancel a not-yet-started job.
428 367

  
429
  /2/nodes resource.
368
``/2/nodes``
369
++++++++++++
430 370

  
431
It supports the following commands: GET.
371
Nodes resource.
432 372

  
433
GET
434
~~~
373
It supports the following commands: ``GET``.
435 374

  
436
::
375
``GET``
376
~~~~~~~
437 377

  
438
  Returns a list of all nodes.
378
Returns a list of all nodes.
439 379

  
440
  Example::
380
Example::
441 381

  
442 382
    [
443 383
      {
......
450 390
      }
451 391
    ]
452 392

  
453
  If the optional 'bulk' argument is provided and set to 'true'
454
  value (i.e '?bulk=1'), the output contains detailed
455
  information about nodes as a list.
393
If the optional 'bulk' argument is provided and set to 'true' value
394
(i.e '?bulk=1'), the output contains detailed information about nodes
395
as a list.
456 396

  
457
  Example::
397
Example::
458 398

  
459 399
    [
460 400
      {
......
472 412
      ...
473 413
    ]
474 414

  
475
  Returns: a dictionary with 'name' and 'uri' keys for each of them
476

  
477
/2/nodes/[node_name]/tags
478
+++++++++++++++++++++++++
479

  
480
::
481

  
482
  /2/nodes/[node_name]/tags resource.
483

  
484
  Manages per-node tags.
485

  
486
It supports the following commands: GET, PUT, DELETE.
487

  
488
GET
489
~~~
490

  
491
::
492

  
493
  Returns a list of tags.
415
``/2/nodes/[node_name]/tags``
416
+++++++++++++++++++++++++++++
494 417

  
495
  Example: ["tag1", "tag2", "tag3"]
418
Manages per-node tags.
496 419

  
497
PUT
498
~~~
420
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
499 421

  
500
::
422
``GET``
423
~~~~~~~
501 424

  
502
  Add a set of tags.
425
Returns a list of tags.
503 426

  
504
  The request as a list of strings should be PUT to this URI. And
505
  you'll have back a job id.
427
Example::
506 428

  
507
DELETE
508
~~~~~~
429
    ["tag1", "tag2", "tag3"]
509 430

  
510
::
431
``PUT``
432
~~~~~~~
511 433

  
512
  Delete a tag.
513

  
514
  In order to delete a set of tags, the DELETE
515
  request should be addressed to URI like:
516
  /tags?tag=[tag]&tag=[tag]
517

  
518
/2/os
519
+++++
434
Add a set of tags.
520 435

  
521
::
436
The request as a list of strings should be PUT to this URI. The result
437
will be a job id.
522 438

  
523
  /2/os resource.
439
``DELETE``
440
~~~~~~~~~~
524 441

  
525
It supports the following commands: GET.
442
Deletes tags.
526 443

  
527
GET
528
~~~
444
In order to delete a set of tags, the DELETE request should be
445
addressed to URI like::
529 446

  
530
::
447
    /tags?tag=[tag]&tag=[tag]
531 448

  
532
  Return a list of all OSes.
449
``/2/os``
450
+++++++++
533 451

  
534
  Can return error 500 in case of a problem.
452
OS resource.
535 453

  
536
  Example: ["debian-etch"]
454
It supports the following commands: ``GET``.
537 455

  
538
/2/tags
539
+++++++
456
``GET``
457
~~~~~~~
540 458

  
541
::
459
Return a list of all OSes.
542 460

  
543
  /2/instances/tags resource.
461
Can return error 500 in case of a problem. Since this is a costly
462
operation for Ganeti 2.0, it is not recommended to execute it too
463
often.
544 464

  
545
  Manages cluster tags.
465
Example::
546 466

  
547
It supports the following commands: GET, PUT, DELETE.
467
    ["debian-etch"]
548 468

  
549
GET
550
~~~
469
``/2/tags``
470
+++++++++++
551 471

  
552
::
472
Manages cluster tags.
553 473

  
554
  Returns a list of tags.
474
It supports the following commands: ``GET``, ``PUT``, ``DELETE``.
555 475

  
556
  Example: ["tag1", "tag2", "tag3"]
476
``GET``
477
~~~~~~~
557 478

  
558
PUT
559
~~~
479
Returns the cluster tags.
560 480

  
561
::
481
Example::
562 482

  
563
  Add a set of tags.
483
    ["tag1", "tag2", "tag3"]
564 484

  
565
  The request as a list of strings should be PUT to this URI. And
566
  you'll have back a job id.
485
``PUT``
486
~~~~~~~
567 487

  
568
DELETE
569
~~~~~~
488
Adds a set of tags.
570 489

  
571
::
490
The request as a list of strings should be PUT to this URI. The result
491
will be a job id.
572 492

  
573
  Delete a tag.
493
``DELETE``
494
~~~~~~~~~~
574 495

  
575
  In order to delete a set of tags, the DELETE
576
  request should be addressed to URI like:
577
  /tags?tag=[tag]&tag=[tag]
496
Deletes tags.
578 497

  
579
/nodes/[node_name]
580
++++++++++++++++++
498
In order to delete a set of tags, the DELETE request should be
499
addressed to URI like::
581 500

  
582
::
501
    /tags?tag=[tag]&tag=[tag]
583 502

  
584
  /2/nodes/[node_name] resources.
585

  
586
It supports the following commands: GET.
587

  
588
GET
589
~~~
590

  
591
::
592

  
593
  Send information about a node.
594

  
595

  
596

  
597
/version
598
++++++++
599

  
600
::
601

  
602
  /version resource.
503
``/version``
504
++++++++++++
603 505

  
604
  This resource should be used to determine the remote API version and
605
  to adapt clients accordingly.
506
The version resource.
606 507

  
607
It supports the following commands: GET.
508
This resource should be used to determine the remote API version and
509
to adapt clients accordingly.
608 510

  
609
GET
610
~~~
511
It supports the following commands: ``GET``.
611 512

  
612
::
513
``GET``
514
~~~~~~~
613 515

  
614
  Returns the remote API version.
516
Returns the remote API version. Ganeti 1.2 returned ``1`` and Ganeti
517
2.0 returns ``2``.

Also available in: Unified diff