compute-api-guide.rst 114 KB
Newer Older
1
.. _compute-api-guide:
2

3 4 5
API Guide
*********

6 7 8 9
`Cyclades <cyclades.html>`_ is the Compute Service of `Synnefo
<http://www.synnefo.org>`_. The Cyclades API tries to be as close to the
`OpenStack Compute API v2
<http://docs.openstack.org/api/openstack-compute/2/content>`_ as possible.
10

11
This document's goals are:
12

13 14
* Define the Cyclades/Compute REST API
* Clarify the differences between Cyclades and OpenStack/Compute
15

16
Users and developers who wish to access Cyclades through its REST API are
17
advised to use the `kamaki <http://www.synnefo.org/docs/kamaki/latest/index.html>`_ command-line
18
client and associated python library, instead of making direct calls.
19 20 21 22

Overview
========

23 24 25 26
* OpenStack does not define if requests for invalid URLs should return 404 or a
* Fault. We return a BadRequest Fault.
* OpenStack does not define if requests with a wrong HTTP method should return
* 405 or a Fault. We return a BadRequest Fault.
27 28 29 30 31 32 33

General API Information
=======================

Authentication
--------------

34 35 36
All requests use the same authentication method: an ``X-Auth-Token`` header is
passed to the servive, which is used to authenticate the user and retrieve user
related information. No other user details are passed through HTTP.
37 38 39 40

Efficient Polling with the Changes-Since Parameter
--------------------------------------------------

41
* Effectively limit support of the changes-since parameter in **List Servers**
42 43
  and **List Images**.

44
* Assume that garbage collection of deleted servers will only affect servers
45 46 47
  deleted ``POLL_TIME`` seconds (default: 3600) in the past or earlier. Else
  loose the information of a server getting deleted.

48
* Images do not support a deleted state, so deletions cannot be tracked.
49

50 51
Limitations
-----------
52

53
* Version MIME type and vesionless requests are not currently supported.
54

55 56
* Cyclades only supports JSON Requests and JSON/XML Responses. XML Requests are
  currently not supported.
57

58
* Optional content compression support is currently not supported.
59

60 61
* To prevent abuse, HTTP sessions have a timeout of 20 seconds before being
  closed.
62

63
* Full URI references and ``self`` and ``bookmark`` links are not supported.
64

65
* Pagination is currently not supported.
66

67 68 69 70 71
* Cached responses are currently not supported.

* Limits are currently not supported.

* Extensions are currently not supported.
72 73 74 75 76 77 78 79


API Operations
==============

Servers
-------

80 81 82 83 84 85 86 87 88 89 90 91 92
=================================================== ========================================= ====== ======== ==========
Description                                         URI                                       Method Cyclades OS/Compute
=================================================== ========================================= ====== ======== ==========
`List <#list-servers>`_                             ``/servers``                              GET    ✔        ✔
\                                                   ``/servers/detail``                       GET    ✔        ✔
`Create <#create-server>`_                          ``/servers``                              POST   ✔        ✔
`Get Stats <#get-server-stats>`_                    ``/servers/<server-id>/stats``            GET    ✔        **✘**
`Get Diagnostics <#get-server-diagnostics>`_        ``/servers/<server-id>/diagnostics``      GET    ✔        **✘**
`Get Details <#get-server-details>`_                ``/servers/<server id>``                  GET    ✔        ✔
`Rename <#rename-server>`_                          ``/servers/<server id>``                  PUT    ✔        ✔
`Delete <#delete-server>`_                          ``/servers/<server id>``                  DELETE ✔        ✔
`List Addresses <#list-server-addresses>`_          ``/servers/<server id>/ips``              GET    ✔        ✔
`Get NICs by Net <#get-server-nics-by-network>`_    ``/servers/<server id>/ips/<network id>`` GET    ✔        ✔
93 94 95 96 97 98
`List Metadata <#list-server-metadata>`_            ``/servers/<server-id>/metadata``         GET    ✔        ✔
`Update Metadata <#set-update-server-metadata>`_    ``/servers/<server-id>/metadata``         PUT    **✘**    ✔
\                                                   ``/servers/<server-id>/metadata``         POST   ✔        ✔
`Get Meta Item <#get-server-metadata-item>`_        ``/servers/<server-id>/metadata/<key>``   GET    ✔        ✔
`Update Meta Item <#update-server-metadatum-item>`_ ``/servers/<server-id>/metadata/<key>``   PUT    ✔        ✔
`Delete Meta Item <#delete-server-metadatum>`_      ``/servers/<server-id>/metadata/<key>``   DELETE ✔        ✔
99 100
=================================================== ========================================= ====== ======== ==========

101 102 103
List Servers
............

104 105 106 107
List all virtual servers owned by the user.

.. rubric:: Request

108
=================== ====== ======== ==========
109
URI                 Method Cyclades OS/Compute
110 111
=================== ====== ======== ==========
``/servers``        GET    ✔        ✔
Stavros Sachtouris's avatar
Stavros Sachtouris committed
112
``/servers/detail`` GET    ✔        ✔
113 114
=================== ====== ======== ==========

115 116 117
* Both requests return a list of servers. The first returns just ``id``,
  ``name`` and ``links``, while the second returns the full collections of
  server attributes.
118

119 120 121
|

==============  ========================= ======== ==========
122
Request Header  Value                     Cyclades OS/Compute
123 124 125 126 127 128
==============  ========================= ======== ==========
X-Auth-Token    User authentication token required required
==============  ========================= ======== ==========

|

129
================= =================================== ======== ==========
130
Request Parameter Value                               Cyclades OS/Compute
131
================= =================================== ======== ==========
132 133
json              Respond in json                     default  **✘**
xml               Respond in xml                      ✔        **✘**
134 135 136 137 138 139 140 141 142
changes-since     Servers delete since that timestamp ✔        ✔
image             Image reference                     **✘**    ✔
flavor            VM flavor reference                 **✘**    ✔
server            Server flavor reference             **✘**    ✔
status            Server status                       **✘**    ✔
marker            Last list last ID                   **✘**    ✔
limit             Page size                           **✘**    ✔
================= =================================== ======== ==========

143 144
* **json** and **xml** parameters are mutually exclusive. If none supported,
the response will be formated in json.
145

146 147
* **status** refers to the `server status <#status-ref>`_

148 149
* **changes-since** must be an ISO8601 date string

150
.. note:: Request body should be empty
151

152
.. rubric:: Response
153 154 155 156 157 158 159 160

=========================== =====================
Return Code                 Description
=========================== =====================
200 (OK)                    Request succeeded
304 (No servers since date) Can be returned if ``changes-since`` is given
400 (Bad Request)           Invalid or malformed ``changes-since`` parameter
401 (Unauthorized)          Missing or expired user token
161
403 (Forbidden)             User is not allowed to perform this operation
162
500 (Internal Server Error) The request cannot be completed because of an
Stavros Sachtouris's avatar
Stavros Sachtouris committed
163
\                           internal error
164 165 166
503 (Service Unavailable)   The server is not currently available
=========================== =====================

167 168 169
|

Response body contents::
170

171 172 173 174 175 176
  servers: [
    {
      <server attribute>: <value>,
      ...
    }, ...
  ]
177 178

================= ====================== ======== ==========
179
Server Attributes Description            Cyclades OS/Compute
180 181 182
================= ====================== ======== ==========
id                The server id          ✔        ✔
name              The server name        ✔        ✔
183
links             Reference links        ✔        ✔
184 185 186
hostId            Server playground      empty    ✔
created           Creation date          ✔        ✔
updated           Creation date          ✔        ✔
187 188
flavor            The flavor id          ✔        ✔
image             The image id           ✔        ✔
189 190 191 192 193 194
progress          Build progress         ✔        ✔
status            Server status          ✔        ✔
attachments       Network interfaces     ✔        **✘**
addresses         Network interfaces     **✘**    ✔
metadata          Server custom metadata ✔        ✔
================= ====================== ======== ==========
195

196 197
* **hostId** is not used in Cyclades, but is returned as an empty string for
  compatibility
198

199
* **progress** is changing while the server is building up and has values
200
  between 0 and 100. When it reaches 100 the server is built.
201

202
* **status** refers to `the status <#status-ref>`_ of the server
203

204
* **metadata** are custom key:value pairs used to specify various attributes of
205
  the VM (e.g. OS, super user, etc.)
206

207
* **attachments** in Cyclades are lists of network interfaces (nics).
208
  **Attachments** are different to OS/Compute's **addresses**. The former is a
209 210 211 212 213
  list of the server's `network interface connections <#nic-ref>`_ while the
  later is just a list of networks. Thus, a Cyclades virtual server may be
  connected to the same network through more than one distinct network
  interfaces (e.g. server 43 is connected to network 101 with nic-43-1 and
  nic-43-2 in the example bellow).
214

215
* **Network Interfaces (NICs)** contain information about a server's connection
216 217 218
  to a network. Each NIC is identified by an id of the form
  nic-<server-id>-<ordinal-number>. More details can be found `here
  <#nic-ref>`_.
219

220 221

*Example List Servers: JSON (regular)*
222 223

.. code-block:: javascript
224

225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
    [
      {
        "links": [
            {
                "href": "https://example.org/compute/v2.0/servers/42", 
                "rel": "self"
            }, 
            {
                "href": "https://example.org/compute/v2.0/servers/42", 
                "rel": "bookmark"
            }
        ],
        "id": "42",
        "name": "My Server",
      }, {
        "links": [
            {
                "href": "https://example.org/compute/v2.0/servers/43", 
                "rel": "self"
            }, 
            {
                "href": "https://example.org/compute/v2.0/servers/43", 
                "rel": "bookmark"
            }
        ],
        "id": "43",
        "name": "My Server",
      }
    ]

*Example List Servers: JSON (detail)*

.. code-block:: javascript

    [
260 261 262 263 264 265 266 267 268 269 270
      {
        "attachments": [
            {
              "id": "nic-42-0",
              "network_id": "101",
              "mac_address": "aa:00:00:49:2e:7e",
              "firewallProfile": "DISABLED",
              "ipv4": "192.168.4.5",
              "ipv6": "2001:648:2ffc:1222:a800:ff:fef5:3f5b"
            }
        ],
271 272 273 274 275 276 277 278 279 280
        "links": [
            {
                "href": "https://example.org/compute/v2.0/servers/42", 
                "rel": "self"
            }, 
            {
                "href": "https://example.org/compute/v2.0/servers/42", 
                "rel": "bookmark"
            }
        ],
281
        "created': '2011-04-19T10:18:52.085737+00:00',
282 283 284 285 286 287 288 289 290 291 292 293 294 295
        "flavor": {
            "id": 1",
            "links": [
                {
                    "href": "https://example.org/compute/v2.0/flavors/1", 
                    "rel": "self"
                }, 
                {
                    "href": "https://example.org/compute/v2.0/flavors/1", 
                    "rel": "bookmark"
                }
            ]

        },
296 297
        "hostId": "",
        "id": "42",
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
        "image": {
            "id": "im4g3-1d",
            "links": [
                {
                    "href": "https://example.org/compute/v2.0/images/im4g3-1d", 
                    "rel": "self"
                }, 
                {
                    "href": "https://example.org/compute/v2.0/images/im4g3-1d", 
                    "rel": "bookmark"
                }, 
                {
                    "href": "https://example.org/image/v1.0/images/im4g3-1d", 
                    "rel": "alternate"
                }
            ]
        },
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
        "metadata": {{"foo": "bar"},
        "name": "My Server",
        "status": "ACTIVE",
        "updated": "2011-05-29T14:07:07.037602+00:00"
      }, {
        "attachments": [
            {
              "id": "nic-43-0",
              "mac_address": "aa:00:00:91:2f:df",
              "network_id": "1",
              "ipv4": "192.168.32.2"
            }, {
              "id": "nic-43-1",
              "network_id": "101",
              "mac_address": "aa:00:00:49:2g:7f",
              "firewallProfile": "DISABLED",
              "ipv4": "192.168.32.6",
              "ipv6": "2001:648:2ffc:1222:a800:ff:fef5:3f5c'
            }, {
              "id": "nic-43-2",
              "network_id": "101",
              "mac_address": "aa:00:00:51:2h:7f",
              "firewallProfile": "DISABLED",
              "ipv4": "192.168.32.7",
              "ipv6": "2001:638:2eec:1222:a800:ff:fef5:3f5c"
            }
        ],
342 343 344 345 346 347 348 349 350 351
        "links": [
            {
                "href": "https://example.org/compute/v2.0/servers/43", 
                "rel": "self"
            }, 
            {
                "href": "https://example.org/compute/v2.0/servers/43", 
                "rel": "bookmark"
            }
        ],
352
        "created": "2011-05-02T20:51:08.527759+00:00",
353 354 355 356 357 358 359 360 361 362 363 364 365 366
        "flavor": {
            "id": 1",
            "links": [
                {
                    "href": "https://example.org/compute/v2.0/flavors/1", 
                    "rel": "self"
                }, 
                {
                    "href": "https://example.org/compute/v2.0/flavors/1", 
                    "rel": "bookmark"
                }
            ]

        },
367 368
        "hostId": "",
        "id": "43",
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
        "image": {
            "id": "im4g3-1d",
            "links": [
                {
                    "href": "https://example.org/compute/v2.0/images/im4g3-1d", 
                    "rel": "self"
                }, 
                {
                    "href": "https://example.org/compute/v2.0/images/im4g3-1d", 
                    "rel": "bookmark"
                }, 
                {
                    "href": "https://example.org/image/v1.0/images/im4g3-1d", 
                    "rel": "alternate"
                }
            ]
        },
386 387 388 389 390 391 392
        "name": "Other Server",
        "description": "A sample server to showcase server requests",
        "progress": "0",
        "status": "ACTIVE",
        "updated": "2011-05-29T14:59:11.267087+00:00"
      }
    ]
393 394


395 396 397
Create Server
.............

398 399 400 401
Create a new virtual server

.. rubric:: Request

402
============ ====== ======== ==========
403
URI          Method Cyclades OS/Compute
404 405 406
============ ====== ======== ==========
``/servers`` POST   ✔        ✔
============ ====== ======== ==========
407 408 409

|

410 411 412 413
==============  ========================= ======== ==========
Request Header  Value                     Cyclades OS/Compute
==============  ========================= ======== ==========
X-Auth-Token    User authentication token required required
414 415
Content-Type    Type or request body      required required
Content-Length  Length of request body    required required
416 417
==============  ========================= ======== ==========

418 419 420 421 422 423
*Example Request Headers*::

  X-Auth-Token:   z31uRXUn1LZy45p1r7V==
  Content-Type:   application/json
  Content-Length: 735

424 425
|

426
================= ===============
427
Request Parameter Value
428 429
================= ===============
json              Respond in json
430
xml               Respond in xml
431 432
================= ===============

433
Request body contents::
434

435 436 437 438 439 440 441 442 443 444 445 446
  server: {
      <server attribute>: <value>,
      ...
      personality: [
        {
          <personality attribute>: <value>,
          ...
        },
        ...
      ],
      ...
  }
447 448

=========== ==================== ======== ==========
449
Attributes  Description          Cyclades OS/Compute
450 451 452 453 454 455
=========== ==================== ======== ==========
name        The server name      ✔        ✔
imageRef    Image id             ✔        ✔
flavorRef   Resources flavor     ✔        ✔
personality Personality contents ✔        ✔
metadata    Custom metadata      ✔        ✔
456
project     Project assignment   ✔        **✘**
457 458 459 460
=========== ==================== ======== ==========

* **name** can be any string

461
* **imageRed** and **flavorRed** should refer to existing images and hardware
462
  flavors accessible by the user
463

464 465
* **metadata** are ``key``:``value`` pairs of custom server-specific metadata.
  There are no semantic limitations.
466

467 468 469 470
* **project** (optional) is the project where the VM is to be assigned. If not
  given, user's base project is assumed (identified with the same uuid as the
  user).

471
* **personality** (optional) is a list of personality injections. A personality
472 473 474 475 476
  injection is a way to add a file into a virtual server while creating it.
  Each change modifies/creates a file on the virtual server. The injected data
  (``contents``) should not exceed 10240 *bytes* in size and must be base64
  encoded. The file mode should be a number, not a string. A personality
  injection contains the following attributes:
477

478 479 480 481 482 483 484 485 486
====================== =================== ======== ==========
Personality Attributes Description         Cyclades OS/Compute
====================== =================== ======== ==========
path                   File path on server ✔        ✔
contents               Data to inject      ✔        ✔
group                  User group          ✔        **✘**
mode                   File access mode    ✔        **✘**
owner                  File owner          ✔        **✘**
====================== =================== ======== ==========
487

488 489 490 491 492 493 494 495 496 497 498 499 500 501
*Example Create Server Request: JSON*

.. code-block:: javascript

  {
    "server": {
      "name": "My Server Name: Example Name",
      "imageRef": "da7a211f-...-f901ce81a3e6",
      "flavorRef": 289,
      "personality": [
        {
          "path": "/Users/myusername/personlities/example1.file",
          "contents": "some data to inject",
          "group": "remotely-set user group",
502
          "mode": 0600,
503 504 505 506 507
          "owner": "ausername"
        }, {
          "path": "/Users/myusername/personlities/example2.file",
          "contents": "some more data to inject",
          "group": "",
508
          "mode": 0777,
509 510 511 512
          "owner": "anotherusername"
        }
      ],
      "metadata": {
513 514
        "EloquentDescription": "Example server with personality",
        "ShortDescription": "Trying VMs"
515 516 517
      }
    }
  }
518

519 520
.. rubric:: Response

521 522 523 524 525 526 527 528
=========================== =====================
Return Code                 Description
=========================== =====================
200 (OK)                    Request succeeded
400 (Bad Request)           Malformed request data
401 (Unauthorized)          Missing or expired user token
403 (Forbidden)             User is not allowed to perform this operation
404 (Not Found)             Image or Flavor not found
529
413 (Over Limit)            Exceeded some resource limit (#VMs, personality
530
size, etc.)
531
415 (Bad Media Type)        
532
500 (Internal Server Error) The request cannot be completed because of an
Stavros Sachtouris's avatar
Stavros Sachtouris committed
533
\                           internal error
534
503 (Service Unavailable)   No available backends or service currently
Stavros Sachtouris's avatar
Stavros Sachtouris committed
535
\                           unavailable
536 537 538 539
=========================== =====================

|

540 541 542 543 544 545 546 547
Response body contents::

  server: {
    <server attribute>: <value>,
    ...
  }

Server attributes are `listed here <#server-ref>`_.
548

549
*Example Create Server Response: JSON*
550 551

.. code-block:: javascript
552

553 554
  {
    "server": {
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
      "addresses": 
      "id": 28130,
        "links": [
            {
                "href": "https://example.org/compute/v2.0/servers/42", 
                "rel": "self"
            }, 
            {
                "href": "https://example.org/compute/v2.0/servers/42", 
                "rel": "bookmark"
            }
        ],

      "image": {
        "id": im4g3-1d
        "links": [
            {
                "href": "https://example.org/compute/v2.0/images/im4g3-1d"
                "rel": "self"
            }, {
                "href": "https://example.org/compute/v2.0/images/im4g3-1d"
                "rel": "bookmark"
            }, {
                "href": "https://example.org/image/v1.0/images/im4g3-1d"
                "rel": "alternate"
            }
        ]
      },
      "flavor": {
        "id": 289
        "links": [
            {
                "href": "https://example.org/compute/v2.0/flavors/289"
                "rel": "self"
            }, {
                "href": "https://example.org/compute/v2.0/flavors/289"
                "rel": "bookmark"
            }
        ]
      },
595 596 597 598 599 600 601
      "status": "BUILD",
      "updated": "2013-04-10T13:52:18.140686+00:00",
      "hostId": "",
      "name": "My Server Name: Example Name",
      "created": "2013-04-10T13:52:17.085402+00:00",
      "adminPass": "fKCqlZe2at",
      "suspended": false,
602
      "progress": 0
603
      "metadata": {
604 605
        "EloquentDescription": "Example server with personality",
        "ShortDescription": "Trying VMs"
606
      }
607 608
    }
  }
609

610
*Example Create Server Response: XML*
611 612 613 614 615 616 617 618 619 620 621 622 623 624

.. code-block:: xml

  <?xml version="1.0" encoding="UTF-8"?>
  <server xmlns="http://docs.openstack.org/compute/api/v1.1"\
    xmlns:atom="http://www.w3.org/2005/Atom"
    id="1"
    status="BUILD"
    hostId="",
    name="My Server Name: Example Name"
    created="2013-04-10T13:52:17.085402+00:00"
    adminPass="fKCqlZe2at"
    suspended="false"
    progress="0"
625
    ...
626 627
  />

628 629 630
Get Server Stats
................

631 632 633
.. note:: This operation is not part of OS/Compute v2.

This operation returns URLs of graphs showing CPU and Network statistics.
634

635
.. rubric:: Request
636

637
============================== ====== ======== ==========
638
URI                            Method Cyclades OS/Compute
639 640 641
============================== ====== ======== ==========
``/servers/<server-id>/stats`` GET    ✔        **✘**
============================== ====== ======== ==========
642

643
* **server-id** is the identifier of the virtual server
644

645 646
|

647
==============  ========================= ======== ==========
648
Request Header  Value                     Cyclades OS/Compute
649 650 651
==============  ========================= ======== ==========
X-Auth-Token    User authentication token required required
==============  ========================= ======== ==========
652 653 654 655 656 657 658 659 660 661

|

================= ===============
Request Parameter Value          
================= ===============
json              Respond in json
xml               Respond in xml 
================= ===============

662 663
* **json** and **xml** parameters are mutually exclusive. If none supported,
the response will be formated in json.
664

665 666 667
.. note:: Request body should be empty

.. rubric:: Response
668 669 670 671 672 673 674 675 676

=========================== =====================
Return Code                 Description
=========================== =====================
200 (OK)                    Request succeeded
400 (Bad Request)           Invalid server ID or Server deleted
401 (Unauthorized)          Missing or expired user token
403 (Forbidden)             Administratively suspended server
404 (Not Found)             Server not found
677
500 (Internal Server Error) The request cannot be completed because of an
Stavros Sachtouris's avatar
Stavros Sachtouris committed
678
\                           internal error
679 680 681 682
503 (Service Unavailable)   The server is not currently available
=========================== =====================

|
683

684 685 686 687 688
Response body contents::

  stats: {<parameter>: <value> }

============= ======================
689
Parameter     Description
690 691 692 693 694 695 696 697 698 699
============= ======================
serverRef     Server ID
refresh       Refresh frequency
cpuBar        Latest CPU load graph URL
cpuTimeSeries CPU load / time graph URL
netBar        Latest Network load graph URL
netTimeSeries Network load / time graph URL
============= ======================

* **refresh** is the recommended sampling rate
700

701
*Example Get Server Stats Response: JSON*
702 703

.. code-block:: javascript
704 705

  {
706 707 708 709 710 711 712 713
    "stats": {
      "serverRef": 1,
      "refresh": 60,
      "cpuBar": "http://stats.okeanos.grnet.gr/b9a...048c/cpu-bar.png",
      "cpuTimeSeries": "http://stats.okeanos.grnet.gr/b9a...048c/cpu-ts.png",
      "netBar": "http://stats.okeanos.grnet.gr/b9a...048c/net-bar.png",
      "netTimeSeries": "http://stats.okeanos.grnet.gr/b9a...048c/net-ts.png"
    }
714 715
  }

716
*Example Get Network Details Response: XML*
717 718

.. code-block:: xml
719 720

  <?xml version="1.0" encoding="UTF-8"?>
721
  <stats xmlns="http://docs.openstack.org/compute/api/v1.1"\
722 723 724 725 726 727 728
    xmlns:atom="http://www.w3.org/2005/Atom"
    serverRef="1"
    refresh="60"
    cpuBar="https://www.example.com/stats/snf-42/cpu-bar/",
    netTimeSeries="https://example.com/stats/snf-42/net-ts/",
    netBar="https://example.com/stats/snf-42/net-bar/",
    cpuTimeSeries="https://www.example.com/stats/snf-42/cpu-ts/"
729 730
  </stats>

731 732 733
Get Server Diagnostics
......................

734
.. note:: This operation is not part of OS/Compute v2.
735

736 737 738
This operation returns diagnostic information (logs) for a server.

.. rubric:: Request
739 740

==================================== ====== ======== ==========
741
URI                                  Method Cyclades OS/Compute
742 743 744 745 746 747 748 749
==================================== ====== ======== ==========
``/servers/<server-id>/diagnostics`` GET    ✔        **✘**
==================================== ====== ======== ==========

* **server-id** is the identifier of the virtual server

|

750 751 752 753 754
==============  ========================= ======== ==========
Request Header  Value                     Cyclades OS/Compute
==============  ========================= ======== ==========
X-Auth-Token    User authentication token required required
==============  ========================= ======== ==========
755

756 757 758 759 760
.. note:: Request parameters should be empty

.. note:: Request body should be empty

.. rubric:: Response
761 762 763 764 765 766 767 768 769 770

=========================== =====================
Return Code                 Description
=========================== =====================
200 (OK)                    Request succeeded
400 (Bad Request)           Invalid server ID or Server deleted
401 (Unauthorized)          Missing or expired user token
403 (Forbidden)             Administratively suspended server
404 (Not Found)             Server not found
500 (Internal Server Error) The request cannot be completed because of an
Stavros Sachtouris's avatar
Stavros Sachtouris committed
771
\                           internal error
772 773 774
503 (Service Unavailable)   The server is not currently available
=========================== =====================

775 776 777 778 779 780 781 782 783 784 785 786 787 788
|

Response body contents::

  [
    {
      <diagnostic attribute}: <value>,
      ...
    }, {
      <diagnostic attribute}: <value>,
      ...
    },
    ...
  ]
789 790 791 792 793 794 795

==================== ===========
Diagnostic attribute Description
==================== ===========
level                Debug level
created              Log entry timestamp
source               Log source proccess
796
source_date          Log source date
797 798 799 800
message              Log description
details              Detailed log description
==================== ===========

801
*Example Get Server Diagnostics Response: JSON*
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829

.. code-block:: javascript

  [
    {
      "level": "DEBUG",
      "created": "2013-04-09T15:25:53.965144+00:00",
      "source": "image-helper-task-start",
      "source_date": "2013-04-09T15:25:53.954695+00:00",
      "message": "FixPartitionTable",
      "details": null
    }, {
      "level": "DEBUG",
      "created": "2013-04-09T15:25:46.413718+00:00",
      "source": "image-info",
      "source_date": "2013-04-09T15:25:46.404477+00:00",
      "message": "Starting customization VM...",
      "details": null
    }, {
      "level": "DEBUG",
      "created": "2013-04-09T15:25:46.207038+00:00",
      "source": "image-info",
      "source_date": "2013-04-09T15:25:46.197183+00:00",
      "message": "Image copy finished.",
      "details": "All operations finished as they should. No errors reported."
    }
  ]

830 831 832
Get Server Details
..................

833 834 835 836
This operation returns detailed information for a virtual server

.. rubric:: Request

837
======================== ====== ======== ==========
838
URI                      Method Cyclades OS/Compute
839 840 841 842 843 844 845 846 847
======================== ====== ======== ==========
``/servers/<server id>`` GET    ✔        ✔
======================== ====== ======== ==========

* **server-id** is the identifier of the virtual server

|

==============  ========================= ======== ==========
848
Request Header  Value                     Cyclades OS/Compute
849 850 851 852
==============  ========================= ======== ==========
X-Auth-Token    User authentication token required required
==============  ========================= ======== ==========

853 854 855 856 857
.. note:: Request parameters should be empty

.. note:: Request body should be empty

.. rubric:: Response
858 859 860 861 862 863 864 865 866

=========================== =====================
Return Code                 Description
=========================== =====================
200 (OK)                    Request succeeded
400 (Bad Request)           Malformed server id
401 (Unauthorized)          Missing or expired user token
403 (Forbidden)             Administratively suspended server
404 (Not Found)             Server not found
867
500 (Internal Server Error) The request cannot be completed because of an
Stavros Sachtouris's avatar
Stavros Sachtouris committed
868
\                           internal error
869
503 (Service Unavailable)   No available backends or service currently
Stavros Sachtouris's avatar
Stavros Sachtouris committed
870
\                           unavailable
871 872 873 874
=========================== =====================

|

875 876 877 878 879 880
Response body contents::

  server: {
    <server attribute>: <value>,
    ...
  }
881 882

================= ====================== ======== ==========
883
Server Attributes Description            Cyclades OS/Compute
884 885 886 887 888 889
================= ====================== ======== ==========
id                The server id          ✔        ✔
name              The server name        ✔        ✔
hostId            Server playground      empty    ✔
created           Creation date          ✔        ✔
updated           Creation date          ✔        ✔
890 891
flavor            The flavor id          ✔        ✔
image             The image id           ✔        ✔
892 893
progress          Build progress         ✔        ✔
status            Server status          ✔        ✔
894
suspended         If server is suspended ✔        **✘**
895 896 897
attachments       Network interfaces     ✔        **✘**
addresses         Network interfaces     **✘**    ✔
metadata          Server custom metadata ✔        ✔
898
diagnostics       Diagnostic information ✔        **✘**
899 900
================= ====================== ======== ==========

901 902
* **hostId** is not used in Cyclades, but is returned as an empty string for
  compatibility
903

904
* **progress** is changing while the server is building up and has values
905
  between 0 and 100. When it reaches 100 the server is built.
906

Stavros Sachtouris's avatar
Stavros Sachtouris committed
907
* **status** refers to `the status <#status-ref>`_ of the server
908

909
* **metadata** are custom key:value pairs used to specify various attributes of
910
  the VM (e.g. OS, super user, etc.)
911

912
* **attachments** in Cyclades are lists of network interfaces (NICs).
913
  **Attachments** are different to OS/Compute's **addresses**. The former is a
914 915 916 917
  list of the server's `network interface connections <#nic-ref>`_ while the
  later is just a list of networks. Thus, a Cyclades virtual server may be
  connected to the same network through more than one distinct network
  interfaces.
918

919
* **diagnostics** is a list of items that contain key:value information useful
920 921
  for diagnosing the server behavior and may be used by the administrators of
  deployed Synnefo setups.
922

923
*Example Details for server with id 42042: JSON*
924 925 926 927 928

.. code-block:: javascript

  {
    "server": {
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
        "attachments": [
            {
              "network_id": "1888",
              "mac_address": "aa:0c:f5:ad:16:41",
              "firewallProfile": "DISABLED",
              "ipv4": "83.212.112.56",
              "ipv6": "2001:648:2ffc:1119:a80c:f5ff:fead:1641",
              "id": "nic-42042-0"
            }
        ],
        "links": [
            {
                "href": "https://example.org/compute/v2.0/servers/42031", 
                "rel": "self"
            }, 
            {
                "href": "https://example.org/compute/v2.0/servers/42042",
                "rel": "bookmark"
            }
        ],
        "created": "2011-05-02T20:51:08.527759+00:00",
        "flavor": {
            "id": 1,
            "links": [
                {
                    "href": "https://example.org/compute/v2.0/flavors/1", 
                    "rel": "self"
                }, 
                {
                    "href": "https://example.org/compute/v2.0/flavors/1", 
                    "rel": "bookmark"
                }
            ]

        },
        "hostId": "",
        "id": "42042",
        "image": {
            "id": "im4g3-1d",
            "links": [
                {
                    "href": "https://example.org/compute/v2.0/images/im4g3-1d", 
                    "rel": "self"
                }, 
                {
                    "href": "https://example.org/compute/v2.0/images/im4g3-1d", 
                    "rel": "bookmark"
                }, 
                {
                    "href": "https://example.org/image/v1.0/images/im4g3-1d", 
                    "rel": "alternate"
                }
            ]
        },
        "name": "My Example Server",
        "description": "A sample server to showcase server requests",
        "progress": "0",
        "status": "ACTIVE",
        "updated": "2011-05-29T14:59:11.267087+00:00",
        "suspended": false,
        "diagnostics": [
            {
                "level": "DEBUG",
                "created": "2013-04-18T10:09:52.776920+00:00",
                "source": "image-info",
                "source_date": "2013-04-18T10:09:52.709791+00:00",
                "message": "Image customization finished successfully.",
                "details": null
            }
        ],
999 1000 1001
      }
    }
  }
1002

1003 1004 1005
Rename Server
.............

1006 1007 1008 1009 1010
Modify the ``name`` attribute of a virtual server. OS/Compute API also features
the modification of IP addresses

.. rubric:: Response

1011
======================== ====== ======== ==========
1012
URI                      Method Cyclades OS/Compute
1013 1014 1015 1016 1017 1018 1019 1020 1021
======================== ====== ======== ==========
``/servers/<server id>`` PUT    ✔        ✔
======================== ====== ======== ==========

* **server-id** is the identifier of the virtual server

|

==============  ========================= ======== ==========
1022
Request Header  Value                     Cyclades OS/Compute
1023 1024
==============  ========================= ======== ==========
X-Auth-Token    User authentication token required required
1025 1026
Content-Type    Type or request body      required required
Content-Length  Length of request body    required required
1027 1028
==============  ========================= ======== ==========

1029 1030 1031 1032 1033 1034
**Example Request Headers**::

  X-Auth-Token:   z31uRXUn1LZy45p1r7V==
  Content-Type:   application/json
  Content-Length: 54

1035 1036 1037 1038 1039 1040 1041 1042
.. note:: Request parameters should be empty

Request body contents::

  server: {
    <server attribute>: <value>,
    ...
  }
1043 1044

=========== ==================== ======== ==========
1045
Attribute   Description          Cyclades OS/Compute
1046 1047 1048 1049 1050 1051
=========== ==================== ======== ==========
name        The server name      ✔        ✔
accessIPv4  IP v4 address        **✘**    ✔
accessIPv6  IP v6 address        **✘**    ✔
=========== ==================== ======== ==========

1052 1053
* Cyclades support multiple network connections per virtual server, which
  explains the above differences in request body attributes.
1054

1055 1056 1057 1058 1059 1060
*Example Rename Server Request: JSON*

.. code-block:: javascript

  {"server": {"name": "A new name for my virtual server"}}

1061
.. rubric:: Response
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072

=========================== =====================
Return Code                 Description
=========================== =====================
204 (OK)                    Request succeeded
400 (Bad Request)           Malformed request or malformed server id
401 (Unauthorized)          Missing or expired user token
403 (Forbidden)             User is not allowed to perform this operation
404 (Not Found)             Server not found
415 (Bad Media Type)
409 (Build In Progress)     Server is not ready yet
1073
500 (Internal Server Error) The request cannot be completed because of an
Stavros Sachtouris's avatar
Stavros Sachtouris committed
1074
\                           internal error
1075
503 (Service Unavailable)   No available backends or service currently
Stavros Sachtouris's avatar
Stavros Sachtouris committed
1076
\                           unavailable
1077 1078
=========================== =====================

1079 1080 1081
.. note:: In case of a 204 return code, there will be no request results
  according to the Cyclades API. Compute OS API suggests that response should
  include the new server details.
1082

1083 1084 1085
Delete Server
.............

1086 1087 1088 1089 1090
Delete a virtual server. When a server is deleted, all its connections are
deleted as well.

.. rubric:: Request

1091
======================== ====== ======== ==========
1092
URI                      Method Cyclades OS/Compute
1093 1094 1095 1096
======================== ====== ======== ==========
``/servers/<server id>`` DELETE ✔        ✔
======================== ====== ======== ==========

1097
* **server-id** is the identifier of the virtual server.
1098 1099 1100 1101

|

==============  ========================= ======== ==========
1102
Request Header  Value                     Cyclades OS/Compute
1103 1104 1105 1106
==============  ========================= ======== ==========
X-Auth-Token    User authentication token required required
==============  ========================= ======== ==========

1107 1108 1109 1110 1111
.. note:: Request parameters should be empty

.. note:: Request body should be empty

.. rubric:: Response
1112 1113 1114 1115 1116 1117 1118 1119 1120

=========================== =====================
Return Code                 Description
=========================== =====================
204 (OK)                    Request succeeded
400 (Bad Request)           Malformed server id or machine already deleted
401 (Unauthorized)          Missing or expired user token
404 (Not Found)             Server not found
409 (Build In Progress)     Server is not ready yet
1121
500 (Internal Server Error) The request cannot be completed because of an
Stavros Sachtouris's avatar
Stavros Sachtouris committed
1122
\                           internal error
1123
503 (Service Unavailable)   Action not supported or service currently
Stavros Sachtouris's avatar
Stavros Sachtouris committed
1124
\                           unavailable
1125 1126
=========================== =====================

1127
.. note:: In case of a 204 code, response body should be empty
1128

1129 1130
List Server Addresses
.....................
1131

1132 1133 1134 1135 1136 1137 1138 1139 1140
List all network connections of a server. In Cyclades API, connections are
represented as Network Connection Interfaces (NICs), which describe a server -
network relation through their respective identifiers. This mechanism ensures
flexibility and multiple networks connecting the same virtual servers.

The Synnefo/Cyclades approach in this matter differs substantially to the
`one suggested by the OS/Compute API <http://docs.openstack.org/api/openstack-compute/2/content/List_Addresses-d1e3014.html>`_.

.. rubric:: Request
1141 1142

============================ ====== ======== ==========
1143
URI                          Method Cyclades OS/Compute
1144 1145 1146 1147 1148 1149 1150 1151 1152
============================ ====== ======== ==========
``/servers/<server id>/ips`` GET    ✔        ✔
============================ ====== ======== ==========

* **server-id** is the identifier of the virtual server

|

==============  ========================= ======== ==========
1153
Request Header  Value                     Cyclades OS/Compute
1154 1155 1156 1157
==============  ========================= ======== ==========
X-Auth-Token    User authentication token required required
==============  ========================= ======== ==========

1158
.. note:: Request parameters should be empty
1159

1160
.. note:: Request body should be empty
1161

1162
.. rubric:: Response
1163 1164 1165 1166 1167 1168 1169 1170 1171

=========================== =====================
Return Code                 Description
=========================== =====================
200 (OK)                    Request succeeded
400 (Bad Request)           Malformed server id or machine already deleted
401 (Unauthorized)          Missing or expired user token
404 (Not Found)             Server not found
409 (Build In Progress)     Server is not ready yet
1172
500 (Internal Server Error) The request cannot be completed because of an
Stavros Sachtouris's avatar
Stavros Sachtouris committed
1173
\                           internal error
1174 1175 1176
503 (Service Unavailable)   Service currently unavailable
=========================== =====================

1177 1178
Response body contents::

1179
  addresses: [
1180 1181 1182 1183 1184
    {
      <NIC attribute>: <value>,
      ...
    },
    ...
1185
  ]