Jump to: navigation, search

Difference between revisions of "QuantumAPISpec"

Line 301: Line 301:
 
<span style="font-size: larger"><span style="font-size: smaller">''Response Codes:'' </span></span>
 
<span style="font-size: larger"><span style="font-size: smaller">''Response Codes:'' </span></span>
  
~+~-Normal Response code: 200
+
~+~-Normal Response code: 202
  
 
Error response code(s):  [[#470-ServiceUnavailable]],[[#401-Unauthorized]],[[#400-BadRequest]],[[#422-NetworkAlreadyExists]]
 
Error response code(s):  [[#470-ServiceUnavailable]],[[#401-Unauthorized]],[[#400-BadRequest]],[[#422-NetworkAlreadyExists]]
Line 646: Line 646:
 
<span style="font-size: larger"><span style="font-size: smaller">''Response Codes:'' </span></span>
 
<span style="font-size: larger"><span style="font-size: smaller">''Response Codes:'' </span></span>
  
~+~-Normal Response code: 200
+
~+~-Normal Response code: 202
  
 
Error response code(s):  [[#470-ServiceUnavailable]],[[#401-Unauthorized]],[[#400-BadRequest]],[[#420-NetworkNotFound]],[[#431-RequestedStateInvalid]] -~  
 
Error response code(s):  [[#470-ServiceUnavailable]],[[#401-Unauthorized]],[[#400-BadRequest]],[[#420-NetworkNotFound]],[[#431-RequestedStateInvalid]] -~  
Line 814: Line 814:
  
 
<pre><nowiki>
 
<pre><nowiki>
<attachment>
+
<attachment id="test_interface_identifier"/>
    test_interface_identifier
 
</attachment>
 
 
 
 
</nowiki></pre>
 
</nowiki></pre>
  
Line 832: Line 829:
 
<pre><nowiki>
 
<pre><nowiki>
 
{
 
{
  "attachment": "test_interface_identifier"
+
  "attachment":
 +
  { "id: "test_interface_identifier" }
 
}
 
}
 
</nowiki></pre>
 
</nowiki></pre>

Revision as of 15:31, 2 August 2011

Quantum API Specification

<<TableOfContents()>>

Introduction

~+~- Quantum is a project to provide "network connectivity as a service" between devices managed by other Openstack services such as nova. For more information on Quantum and the other network-related projects please check the Quantum home page and the Network projects home page.

This document constitutes a first attempt in defining an API for the Quantum service. The operation list cannot be deemed complete, and formats for request and response messages have not yet been defined. Moreover, authentication, authorization, and extension mechanisms, as well as the URL structure, are not defined in this document. -~+~

Since Quantum provides “network connectivity as a service”, this API defines Layer-2 operations only.

We first introduce the operation list, and then discuss how these operations can be used to accomplish some common use cases.

Glossary

Entity
Network
Plugin
Logical Port
VIF
Attachment

Theory of Operation

This section presents the objects and semantics of quantum’s logical model. Quantum abstracts the physical implementation of the network, allowing plugins to configure and manage physical resources.

Quantum is a standalone service, in that it requires no other projects within Openstack to function correctly. Further quantum is agnostic to the entities it allows to connect. While we anticipate Nova created instances will be a heavy user of quantum, any entity can make use of any quantum created network so long as it implements a standard interface (VIF). In this way it our intent to future proof quantum to allow additional entity types such as Load Balancers, Firewalls, Volumes (VaaS) or other entities to connect. Virtual Interfaces(VIF) in the logical model are analogous to physical network interface cards (NIC). In the same way as a physical NIC a VIF may have and advertise capabilities. The VIF is instantiated with these capabilities when it is created as part of the entity. Use of the VIF capabilities is out of scope of this document. However intelligently schedulers may chose to place entities on physical hardware best capable of honouring these capabilities, much as logical processors of virtual memory requirements may be used to schedule in a virtual machine instances.

The VIF will be connected to the network via a logical port. The logical port begins in a “down” state. Logic ports are transient when in the “down” state, by this we mean they don’t have any binding to a physical implementation. The plugin must create this binding as a part of the attachment process. When a VIF is attached to a logical port the plugin creates the binding to the physical hardware required to allow operation of the VIF. This is indicated by the change in port state from “down” to “active”. As a result of the attachment operation, quantum can now knows the capabilities of the VIF as dictated by the physical binding. As a result the logical port may advertise capabilities once it moves to the “active” state.

Entities attached to an “active” port are required to have access to the L2 broadcast domain. The entity shall be capable of exchanging L2 traffic with all other entities attached through an “Active” port. At this point any additional behaviour is outside the scope of quantum. However in practice the VIF is likely to make use of additional services or extensions to add L3 protocols on top of this interface.

Template:Http://i56.tinypic.com/vem4c6.jpg

Operation List

List of error response codes:

Code Name
<#4F91BD><<Anchor(400-BadRequest)>|>400 Bad Request
>401 Unauthorized
<#4F91BD><<Anchor(420-NetworkNotFound)>|>420 NetworkNotFound
<<Anchor(421-NetworkInUse)>|>421 NetworkInUse
<#4F91BD><<Anchor(422-NetworkAlreadyExists)>|>422 NetworkAlreadyExists
<<Anchor(430-PortNotFound)>|>430 PortNotFound
<#4F91BD><<Anchor(431-RequestedStateInvalid)>|>431 RequestedStateInvalid
<<Anchor(432-PortInUse)>|>432 PortInUse
<#4F91BD><<Anchor(440-AlreadyAttached)>|>440 AlreadyAttached

<<Anchor(GetNetworks)>>


List networks


~+

Verb URI
GET /tenants/{tenant-id}/networks

+~

Request Body:

This operation does not require a request body.

Description:

This operation returns the list of all networks currently defined in Quantum; returned list includes at least the network’s unique identifier.

Sample Request/Response:

XML

Request:

GET /tenants/XYZ/networks.xml

Response:

<networks>
    <network id="8bec1293-16bd-4568-ba75-1f58bec0b4c3"/>
    <network id="2a39409c-7146-4501-8429-3579e03e9b56"/>
</networks>


JSON

Request:

GET /tenants/XYZ/networks.json

Response:

{
    "networks": 
         [
          {"id": "8bec1293-16bd-4568-ba75-1f58bec0b4c3"},
          {"id": "2a39409c-7146-4501-8429-3579e03e9b56"}
         ]
}


Response Codes:

~+~-Normal Response code: 200

Error response code(s): #470-ServiceUnavailable, #401-Unauthorized -~ +~

<<Anchor(GetNetworkDetails)>>


List network details


~+

Verb URI
GET /tenants/{tenant-id}/networks/{network-idid}

+~

Request Body:

This operation does not require a request body.

Description:

This operation provides detailed output for a specific network configured in Quantum.' Details about ports configured for the network and resources attached to can be retrieved using the detail action for this operation: GET /tenants/{tenant-id}/networks/{network-id}/detail

Sample Request/Response:

XML

Request:

GET /tenants/XYZ/networks/8bec1293-16bd-4568-ba75-1f58bec0b4c3.xml

Response:

    <network 
           id="8bec1293-16bd-4568-ba75-1f58bec0b4c3"
           name="test_network"/>


JSON

Request:

GET /tenants/XYZ/networks/8bec1293-16bd-4568-ba75-1f58bec0b4c3.json

Response:

{
   "network": 
       {
           "id": "8bec1293-16bd-4568-ba75-1f58bec0b4c3",
           "name": "test_network"
       }
}


Response Codes:

~+~-Normal Response code: 200

Error response code(s): #470-ServiceUnavailable, #401-Unauthorized, #420-NetworkNotFound -~+~

<<Anchor(PostNetwork)>>


Create Network


~+

Verb URI
POST /tenants/{tenant-id}/networks

+~

Request Body:

~+~-The body for this request should contain a Network object includind a symbolic name for the network. Note that network names must be unique for each tenant. The unique identifier for the Network will be returned with the response.-~+~

Description:

~+~-This operation asynchronously creates a Layer-2 network in Quantum based on the information provided in the request body.

Quantum validates the request, and dispatches it to the plugin, and then returns the unique identifier of the network to the caller, who can check the progress of the operation performing a GET on networks/id.

Resources for the new network can be either provided at create time or when virtual interfaces are plugged into this network depending on the particular plugin implementation.

If the validation phase fails, the network object is not created at all, and a 400 error is returned to the caller. -~+~

Sample Request/Response:

XML

Request:

POST /tenants/XYZ/networks.xml

<network name="test_create_network"/>

Response:

<network id="158233b0-ca9a-40b4-8614-54a4a99d47d1"/>


JSON

Request:

POST tenants/XYZ/networks.json

{
   "network":
       {
            "name": "test_create_network"
       }
}

Response:

{
   "network": 
       {
           "id": "158233b0-ca9a-40b4-8614-54a4a99d47d1",
       }
}


Response Codes:

~+~-Normal Response code: 202

Error response code(s): #470-ServiceUnavailable,#401-Unauthorized,#400-BadRequest,#422-NetworkAlreadyExists

-~ <<Anchor(PutNetwork)>> +~


Update Network


~+

Verb URI
PUT /tenants/{tenant-id}/networks/{network-id}

+~

Request Body:

~+~-The request body for this operation must contain the new symbolic name for the network. Note that network names must be unique for each tenant. -~+~

Description: This operation asynchronously updates a network in Quantum according to the information provided in the request body.

Sample Request/Response:

XML

Request:

PUT /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1.xml

<network name="new_network_name"/>

Response:

No data returned in response body

JSON

Request:

PUT /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1.json

{
   "network":
       {
            "name": "new_network_name"
       }
}

Response:

No data returned in response body

Response Codes:

~+~-Normal Response code: 204

Error response code(s): #470-ServiceUnavailable,#401-Unauthorized,#400-BadRequest,#420-NetworkNotFound,#422-NetworkAlreadyExists -~ <<Anchor(DeleteNetwork)>>


+~

Delete Network

~+


Verb URI
DELETE /tenants/{tenant-id}/networks/{network-id}

+~

Request Body:

This operation does not require a request body.

Description:

~+~-This operation removes the network specified in the URI. This request will fail as long as there is at least one "active" port on the network. Logical ports will be destroyed together with the network.

The operation is asynchronous. Quantum forwards the request to the plugin, which will then destroy the network. Callers can check the current status of the operation by performing a GET on networks/id. The operation has complete when a #420-NetworkNotFound is returned.

This operation is not recoverable. -~+~

Sample Request/Response:

XML

Request:

DELETE /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1.xml

Response:

No data returned in response body

JSON

Request:

DELETE /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1.json

Response:

No data returned in response body

Response Codes:

~+~-Normal Response code: 204

Error response code(s): #470-Service Unavailable,#401-Unauthorized,#420-NetworkNotFound,#421-NetworkInUse -~ <<Anchor(GetPorts)>> +~


List logical ports for network


~+

Verb URI
GET /tenants/{tenant-id}/networks/{network-id}/ports

+~

Request Body:

This operation does not require a request body.

Description:

This operation lists all the ports currently configured for a network. Response for each port includes at least its unique identifier. If no logical ports have been created on the network an empty list will be returned.

Sample Request/Response:

XML

Request:

GET /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports.xml

Response:


<ports>
    <port id="98017ddc-efc8-4c25-a915-774b2a633855"/>
    <port id="b832be00-6553-4f69-af33-acd554e36d08"/>
</ports>


JSON

Request:

GET /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports.json

Response:


{
    "ports": 
        [
           {"id": "98017ddc-efc8-4c25-a915-774b2a633855"},
           {"id": "b832be00-6553-4f69-af33-acd554e36d08"}
        ]
}

Response Codes:

~+~-Normal Response code: 200

Error response code(s): #470-ServiceUnavailable,#401-Unauthorized,#420-NetworkNotFound -~ <<Anchor(GetPortDetails)>> +~


List port details


~+

Verb URI
GET /tenants/{tenant-id}/networks/{network-id}/ports/{port-id}

+~

Request Body:

This operation does not require a request body.

Description:

This operation provides the identifier and the current state for specific port configured for a given network.

Sample Request/Response:

XML

Request:

GET /tenants/33/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/98017ddc-efc8-4c25-a915-774b2a633855.xml

Response:


<port 
    id="98017ddc-efc8-4c25-a915-774b2a633855"
    state="DOWN"/>


JSON

Request:

GET /tenants/33/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/98017ddc-efc8-4c25-a915-774b2a633855.json

Response:



{
    "port":
        {
            "state": "DOWN",
            "id": "98017ddc-efc8-4c25-a915-774b2a633855"
        }
}


Response Codes:

~+~-Normal Response code: 200

Error response code(s): #470-ServiceUnavailable,#401-Unauthorized,#420-NetworkNotFound,#430-PortNotFound -~ <<Anchor(PostPort)>> +~


Create Port


~+

Verb URI
POST /tenants/{tenant-id}/networks/{network-id}/ports

+~

Request Body:

The request body is not mandatory, but can optionally contain the state of the newly created port, which can be either 'DOWN' or 'ACTIVE'.

Description:

~+~-This operation asynchronously creates a port on a Quantum network based on the information provided in the request body. Quantum validates the request, and dispatches the request to the plugin, which creates the logical port and attaches it to the appropriate network. Resources for the new port can be either provided at create time or when virtual interfaces are plugged into this port depending on the particular plugin implementation. Also, this operation could not be implemented for some plugins as the number of ports available might be fixed when the network is created. If the validation phase fails, the port object is not created at all, and a #400-BadRequest error is returned to the caller. The operation returns a port with an identifier, and state set to DOWN. -~+~

Sample Request/Response:

XML

Request:

POST /tenants/33/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports.xml

<port state="ACTIVE"/>

Response:


<port id="98017ddc-efc8-4c25-a915-774b2a633855"/>


JSON

Request:

POST /tenants/33/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports.json

{ 
"port": 
    { "state": "ACTIVE" }
}

Response:



{
    "port":
        {
            "id": "98017ddc-efc8-4c25-a915-774b2a633855"
        }
}


Response Codes:

~+~-Normal Response code: 202

Error response code(s): #470-ServiceUnavailable,#401-Unauthorized,#400-BadRequest,#420-NetworkNotFound,#431-RequestedStateInvalid -~

<<Anchor(DeletePort)>> +~


Delete Port


~+

Verb URI
DELETE /tenants/{tenant-id}/networks/{network-id}/ports/{port-id}

+~

Request Body: This operation does not require a request body.

Description:

~+~-This operation removes a logical port from a Quantum network. This operation might not be available for plugins in which the number of ports is fixed at network creation; in this case ports should not be deleted, just as they cannot be created.

The operation is not recoverable and will fail if an attachment is plugged into the port. -~+~

Sample Request/Response:

XML

Request:

DELETE tenants/33/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/98017ddc-efc8-4c25-a915-774b2a633855.xml

Response:

No data returned in response body

JSON

Request:

DELETE tenants/33/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/98017ddc-efc8-4c25-a915-774b2a633855.json

Response:

No data returned in response body

Response Codes:

~+~-Normal Response code: 204

Error response code(s): #470-ServiceUnavailable,#401-Unauthorized,#420-NetworkNotFound,#430-PortNotFound,#432-PortInUse.

-~ <<Anchor(GetPortAttachment)>> +~


Set Port State


~+

Verb URI
PUT /tenants/{tenant-id}/networks/{network-id}/ports/{port-id}

+~

Request Body: The operation's request body contains the new administrative state for the logical port. Valid values are 'DOWN' and 'ACTIVE'

Description:

~+~-This operation attempts to set the state of the logical port. Currently Quantum recognizes two port states: DOWN and ACTIVE. In the DOWN state a port is not required to be bound to physical resources of the network. Setting a currently active port to down allows plugins to make intelligent use of current resources. Additionally it allows the tenant the ability to take entities offline without destroying their logical topology.

The operation will return #431-RequestedStateInvalid if the specified administrative state is not DOWN or ACTIVE. -~+~

Sample Request/Response:

XML

Request:

PUT tenants/33/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/98017ddc-efc8-4c25-a915-774b2a633855.xml

<port state="ACTIVE"/>

Response:

No data returned in response body

JSON

Request:

PUT tenants/33/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/98017ddc-efc8-4c25-a915-774b2a633855.json

{ 
"port": 
    { "state": "ACTIVE" }
}

Response:

No data returned in response body

Response Codes:

~+~-Normal Response code: 204

Error response code(s): #470-ServiceUnavailable,#400-BadRequest,#401-Unauthorized,#420-NetworkNotFound,#430-PortNotFound,#431-RequestedStateInvalid.

-~ <<Anchor(GetPortAttachment)>> +~


List attachment for port


~+

Verb URI
GET /tenants/{tenant-id}/networks/{network-id}/ports/{port-id}/attachment

+~

Request Body:

This operation does not require a request body.

Description:

~+~-This operation returns configuration details for the attachment plugged into the port specified in the request URI.

This information is a reference to a virtual interface identifier, which could be either:

  • A reference to a resource managed by Quantum;
  • A reference to an external resource not managed by Quantum (for instance a network interface defined in nova); -~+~

If no attachment is currently plugged into the logical port, the operation returns an empty response.

Sample Request/Response:

XML

Request:

GET /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/b832be00-6553-4f69-af33-acd554e36d08/attachment.xml

Response:

<attachment id="test_interface_identifier"/>

JSON

Request:

GET /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/b832be00-6553-4f69-af33-acd554e36d08/attachment.json

Response:

{
 "attachment": 
   { "id: "test_interface_identifier" }
}


Response Codes:

~+~-Normal Response code: 200

Error response code(s): #470-ServiceUnavailable,#400-MalformedRequest,#401-Unauthorized,#420-NetworkNotFound,#430-PortNotFound -~ <<Anchor(PutPortAttachment)>> +~


Attach resource to port


~+

Verb URI
PUT /tenants/{tenant-id}/networks/{network-id}/ports/{port-id}/attachment

+~

Request Body:

~+~-The request body for this network should contain a reference to the resource to plug into the logical port. Plugged resources can either be managed by or external to Quantum. In both cases, the request body will contain an identifier for that resource. -~+~

Description:

~+~-This operation asynchronously plugs a resource, or attachment, into the logical port specified in the request URL. A resource is typycally a virtual network interface belonging to a VM instance. Different kinds of resources can be defined in the future.

The request will be first validated by Quantum and then dispatched to the plugin. As the request is asynchronous, control is immediately returned to the caller.

The validation can fail if:

  • The attachment is already plugged somewhere else;
  • There is already another attachment plugged into the specified logical port.

If the validation phase fails, the attachment object is not created at all, and a 400 error is returned to the caller. -~+~

Sample Request/Response:

XML

Request:

PUT /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/b832be00-6553-4f69-af33-acd554e36d08/attachment.xml

<attachment>test_interface_identifier</attachment>


Response:

No data returned in response body

JSON

Request:

PUT /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/b832be00-6553-4f69-af33-acd554e36d08/attachment.json

{
 "attachment": "test_interface_identifier"
}

Response:

No data returned in response body

Response Codes:

~+~-Normal Response code: 204

Error response code(s): #470-ServiceUnavailable, #400-BadRequest, #401-Unauthorized,#420-NetworkNotFound,#430-PortNotFound,#432-PortInUse,#440-AlreadyAttached -~ <<Anchor(DeletePortAttachment)>> +~


Remove attachment from port


~+

Verb URI
DELETE /tenants/{tenant-id}/networks/{network-id}/ports/{port-id}/attachment

+~

Request Body:

This operation does not require a request body.

Description:

This operation asynchronously removes an attachment from a logical port. This operation cannot be undone.

Sample Request/Response:

XML

Request:

DELETE /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/b832be00-6553-4f69-af33-acd554e36d08/attachment.xml


Response:

No data returned in response body

JSON

Request:

DELETE /tenants/XYZ/networks/158233b0-ca9a-40b4-8614-54a4a99d47d1/ports/b832be00-6553-4f69-af33-acd554e36d08/attachment.json

Response:

No data returned in response body

Response Codes:

~+~-Normal Response code: 204

Error response code(s): #470-ServiceUnavailable,#401-Unauthorized,#420-NetworkNotFound,#430-PortNotFound