Neutron/APIv2-specification

= Neutron v2 API = This page is a draft spec and may not reflect the actual implementation.

Refer to http://developer.openstack.org/api-ref-networking-v2.html for the latest.

Overview
Neutron is a project to provide virtual networking services between devices managed by the OpenStack compute service. This document presents and discusses version 2.0 of the Neutron API. For more information on the Neutron project, and additional documentation, please visit http://wiki.openstack.org/Neutron, and docs.openstack.org. We welcome feedback, comments, and bug reports at https://bugs.launchpad.net/neutron.

The v2.0 API represents a combination of the Quantum v1.1 API with some of the most essential IPAM capabilities from the Melange API. These IPAM capabilities focus on being able to associate IP address blocks and other network configuration required by a network device (e.g., default gateway, dns-servers) with a Neutron Network, and then being able to allocate an IP address out of such a block and associate it with a device that is attached to the network via a Neutron Port.

The v2.0 API does this by introducing a new entity, called a Subnet. Subnets can represent the binding of either a IPv4 or IPv6 address block to a previously created Quantum network, and each Neutron Network commonly has one or more subnets. When a port is created on the network, by default it will be allocated an available fixed IP address out of one the designated subnets for each IP version. When the Port is destroyed, the allocated addresses return to the pool of available IPs on the subnet. Users of the Neutron API can either choose a specific IP address from the block, or let Neutron choose the first available IP address.

''Please note that version 1.x of the Neutron API has been removed from the source code tree. In order to use v1.x API, an earlier release of Neutron should be installed.''

High-level flow

 * Tenant creates a network (e.g., "net1")
 * Tenant creates a subnet (e.g., "10.0.0.0/24"), which implicitly associates the address space with that network. This association creates a binding of the address space to the previously created network. While it is common to say, that a subnet is represented by an IPv4 or IPv6 address range, the address range alone is not a subnet. Rather it is the binding of the address space to the network, which creates the subnet.
 * Tenant boots a VM, specifying a single NIC connected to "net1" (e.g.: nova boot --image  --nic net-id= )
 * Nova contacts Neutron and creates a port1 on net1.
 * Neutron assigns an IP to port1 is assigned IP. (The IP is chosen by Neutron)
 * Tenant destroys VM.
 * Nova contacts Neutron and destroys port1. Allocated IP is returned to the pool of available IP address.

The Plugin
While the Neutron API represents the interface of the virtual network service to users and other services, these network services are implemented by a component called "Plugin". Plugins may adopt different techniques and technologies for providing isolated virtual networks to tenant, as well as providing other services such as IP address management. Users should not be concerned about the particular plugin employed as far as the API discussed in this document is concerned, as every plugin will implement all the operations included in the Neutron v2 API.

However, some plugins might expose additional capabilities through API extensions, discussed later in this document. For more information about the extensions exposed by a particular plugin, please refer to the plugin documentation.

Concepts
The Neutron v2 API manages three kind of entities:


 * Network, representing isolated virtual Layer-2 domains; a network can also be regarded as a virtual (or logical) switch;
 * Subnet, representing IPv4 or IPv6 address blocks from which IPs to be assigned to VMs on a given network are selected.
 * Port, representing virtual (or logical) switch ports on a given network.

All entities, discussed in detail in the rest of this chapter, support the basic CRUD operations with POST/GET/PUT/DELETE verbs, and have an auto-generated unique identifier.

Network
A network is a virtual isolated layer-2 broadcast domain which is typically reserved to the tenant who created it, unless the network has been explicitly configured to be shared. Tenants can create multiple networks, until they reach the thresholds specified by per-tenant Quotas (see next chapter for more details). The network is the principal entity for the Neutron API. Ports and subnets must always be associated with a network. The following table describes the attributes of network objects. For each attribute, the CRUD column should be read as follows:


 * C - the attribute can be used in create operations;
 * R - the attribute is returned in the response for show or list operations;
 * U - the value of attribute can be updated;
 * D - the value of the attribute can be removed;

Subnet
A subnet represents an IP address block that can be used for assigning IP addresses to virtual instances. Each subnet must have a CIDR and must be associated with a network. IPs can be either selected from the whole subnet CIDR, or from "allocation pools" that can be specified by the user.

A subnet can also optionally have a gateway, a list of DNS name servers, and host routes. All this information will then be pushed to instances whose interfaces are associated with the subnet.

Port
A port represents a virtual switch port on a logical network switch. Virtual instances attach their interfaces into ports. The logical port also defines the MAC address and the IP address(es) to be assigned to the interfaces plugged into them. When IP addresses are associated to a port, this also implies the port is associated with a subnet, as the IP address was taken from the allocation pool for a specific subnet.

* The tenant_id attribute is mandatory if Neutron is not running with the Keystone Identity service

Authentication and authorization
Neutron uses the Keystone identity service (http://keystone.openstack.org) as the default authentication service. When keystone is enabled Users submitting requests to the Neutron service must provide an authentication token in X-Auth-Token request header. The aforementioned token should have been obtained by authenticating with the keystone endpoint. For more information concerning authentication with Keystone, please refer to the Keystone documentation. When keystone is enabled, it is not mandatory to specify tenant_id for resources in create requests, as the tenant identifier will be derived from the Authentication token. Please note that the default authorization settings only allow administrative users to create resources on behalf of a different tenant.

Neutron uses information received from Keystone to authorize user requests. Neutron handles two kind of authorization policies:
 * Operation-based: policy specifying access criteria for specific operations, possibly with fine-grained control over specific attributes
 * Resource-based: whether access to specific resource might be granted or not according to the permissions configured for the resource (currently available only for the network resource)

The actual authorization policies enforced in Neutron might vary from deployment to deployment.

Request and Response types
The OpenStack Neutron API supports the JSON data format. The format for both the request and the response can be specified either using the Accept header or adding the .json extension to the request URI.

Example: Request/Response with Headers: JSON

Request:

POST /v1.0/tenants/tenantX/networks HTTP/1.1 Host 127.0.0.1:9696 Content-Type application/json Accept application/json Content-Length 57

{ "network": {     "name": "net-name", "admin_state_up": true } }

Response:

HTTP/1.1 200 Accepted Content-Type application/json Content-Length 204

{ "network": {    "status": "ACTIVE", "subnets": [], "name": "net-name", "admin_state_up": true, "tenant_id": "388a70781bae4ca895f17b7f6293eb70", "shared": false, "id": "2a4017ef-31ff-496a-9294-e96ecc3bc9c9" } }

NOTE: We have still to finalize a decision concerning XML support. Quantum v2 API XML blueprint

Filtering and Column Selection
The Neutron API supports filtering based on all top level attributes of a resource. Filters are applicable to all list requests. For instance:

GET /v2.0/networks?name=foobar

will return all the networks whose name is foobar. When multiple filters are specified, the Neutron API will return only objects that satisfy all the filters, this applying an AND condition among filters. Neutron does not offer a mechanisms for ORing filters. To this aim, the user can submit a distinct request for each filters, and then build a set on the client-side from received responses.

By default, Neutron returns all attributes for any Show or List call. The Neutron API has a mechanism to limit the set of attributes returned (e.g., return just 'id'). Attributes returned from the Neutron API can be controller using the fields query parameter. For example the following request:

GET /v2.0/networks.json?fields=id&fields=name

will return only id and name for each network.

Synchronous vs Asynchronous Plugin Behavior
The Neutron API presents a logical model of network connectivity consisting of networks, ports, and subnets. It is up to the Neutron plugin to communicate with the underlying infrastructure to ensure packet forwarding is consistent with the logical model. A plugin might perform these operations asynchronously. This means that when an API client modifies the logical model using an HTTP POST, PUT, or DELETE, the API call may return prior to the plugin performing any modifications to underlying virtual and/or physical switching devices. The only guarantee an API client has is that all subsequent API calls will properly reflect the changed logical model. As a concrete example, consider the case where a client uses an HTTP PUT to set the attachment for a port. There is no guarantee that packets sent by the interface named in the attachment will be forwarded immediately once the HTTP call returns. However, there is a guarantee that a subsequent HTTP GET to view the attachment on that port would return the new attachment value. The "status" attribute, available for network and port resources might be used to understand whether the Neutron plugin has successfully completed the configuration of the interested resource.

Bulk Create Operations
The Neutron API allow for creating several objects of the same type in the same API request. Bulk create operations use exactly the same API as singleton create operations, with the only difference being that a list of objects, rather than a single object, is specified in the request body.

Bulk operations are always performed atomically, meaning that either all or none of the objects in the request body are created. Should the particular plugin does not support atomic operations, Neutron API will emulate the atomic behavior, thus ensuring users might expect the same behavior regardless of the particular plugin running in the backend.

Neutron might be deployed without support for bulk operations. In that case a 400 Bad Request error will be returned when the client attempts a bulk create operation.

For more details concerning how to submit bulk requests to the Neutron API, please refer to create operations discussed in the next chapter.

Quotas
[tbd] Yong to contribute

Notifications
[tbd] Yong to contribute

Extensions
The Neutron API is extensible. Extensions serve several purposes:


 * They allow the introduction of new features in the API without requiring a version change;
 * They allow the introduction of vendor specific niche functionality
 * They act as a proving ground for experimental functionalities which might be included in a future version of the API.

Applications can programmatically determine what extensions are available by performing a GET on the v2.0/extensions URI. Extensions may also be queried individually by their unique alias by performing a GET on the /v2.0/extensions/alias_name. This provides the simplest method of checking if an extension is available as an unavailable extension will issue an itemNotFound (404) response. Existing core API resources can be extended with new actions or extra attributes. Also, new resources can also be added as extensions. Extensions usually have tags that prevent clash with other extensions defining attributes and/or resources with the same name, and with core resources and attributes. As an extension might not be supported by all plugin, availability of an extension will vary with deployments and the specific plugin in use.

Faults
If a failure occurs while processing a request, the Neutron API returns an error response. Neutron uses only standard HTTP error codes. 4xx errors are indicative of problems in the particular request being sent from the client.

Users submitting requests to the Neutron API might also receive the following errors:


 * 401 Unauthorized - if invalid credentials are provided
 * 403 Forbidden - If the user cannot access a specific resource or perform the requested operation.

List Networks
This operation returns the list of all the network the tenants has access to. This includes networks owned by tenant and shared networks. By default, network objects will be returned with all their attributes. Users can control which attribute should be returned by using the field query parameter. Responses can be filtered by specifying search criteria on the query string. Only exact match supported at the moment.

Normal Response Code: 200

Error Response Codes: Unauthorized (401), Bad Request (400)

JSON Request and Response sample:

Request

GET /v2.0/networks Accept: application/json

Response

{ "networks": [ {   "status": "ACTIVE", "subnets": [], "name": "network_1", "admin_state_up": true, "tenant_id": "c1210485b2424d48804aad5d39c61b8f", "id": "3a06dfc7-d239-4aad-9a57-21cd171c72e5", "shared": false }, {    "status": "ACTIVE", "subnets": [], "name": "network-2", "admin_state_up": true, "tenant_id": "c1210485b2424d48804aad5d39c61b8f", "id": "7db8c5a4-6eb0-478d-856b-7cfda2b25e13", "shared": false }, {    "status": "ACTIVE", "subnets": ["e12f0c45-46e3-446a-b207-9474b27687a6"], "name": "network_3", "admin_state_up": true, "tenant_id": "ed680f49ff714162ab3612d7876ffce5", "id": "afc75773-640e-403c-9fff-62ba98db1f19", "shared": true } ] }

Show Network
This operation returns the complete list of attributes for the network whose identifier is specified in the request URI, assuming the network exists and the user making the request is authorized to access it. The set of attributes which is actually returned by the API can be controller through the field query parameter.

Normal Response Code: 200

Error Response Codes: Unauthorized (401), Bad Request (400), Not Found (404)

JSON Request and Response sample:

Request:

GET /v2.0/networks/afc75773-640e-403c-9fff-62ba98db1f19 Accept: application/json

Response:

{ "network": {   "status": "ACTIVE", "subnets": ["e12f0c45-46e3-446a-b207-9474b27687a6"], "name": "network_3", "admin_state_up": true, "shared": false, "tenant_id": "ed680f49ff714162ab3612d7876ffce5", "id": "afc75773-640e-403c-9fff-62ba98db1f19" } }

Create Network
This operation will create a new Neutron network. The identifier of the newly created network is returned in the response. The shared attribute can be used to create a public network, i.e.: a network which is shared with all other tenants. However, the current model of the Neutron API allows only for either completely private or completely open networks. More sophisticated mechanisms for specifying ACLs on networks will come in future releases of the API.

Moreover, control of the shared attribute could be reserved to particular users only, such as administrators. In this case, regular users trying to create a shared network will receive a 403 - Forbidden error.

Normal Response Code: 200

Error Response Codes: Unauthorized (401), Bad Request (400)

JSON Request and Response sample:

Request:

POST v2.0/networks.json Content-Type: application/json Accept: application/json

{ "network": {   "name": "sample_network", "admin_state_up": false } }

Response:

'status': '201' 'content-length': '194' 'content-type': 'application/json;

{ "network": {     "status": "ACTIVE", "subnets": [], "name": "sample_network", "admin_state_up": false, "shared": false, "tenant_id": "c1210485b2424d48804aad5d39c61b8f", "id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766" } }

Bulk version
The bulk version of operation allows for creating several networks with a single request. The behavior of the bulk create operation is always atomic: either all networks in the request body are created, or none of them is created. To this aim, a list of networks must be supplied in the request body, as follows:

JSON Request and Response sample:

Request:

POST v2.0/networks.json

Content-Type: application/json Accept: application/json

{ "networks": [ {    "name": "sample_network_1", "admin_state_up": false },  {     "name": "sample_network_2", "admin_state_up": false }] }

Update Network
The update network operation allow users for updating some attributes of a network object, such as name and admin_state_up. Attributes such as tenant_id cannot be updated. If an attempt is made to update such attributes a 422 'Unprocesable Entity' error will be returned.

Users authorized to control the shared attribute are also allowed to change it. While sharing a previously private network is always possible, the opposite is not always true. If the user attempts to turn private a shared network with subnets and/or ports belonging to tenants different from the network owner, a 409 Conflict error will be returned.

Note: Update operations in Neutron adopt patch semantics. This implies that the Neutron API does not require the user to send the whole resource to be updated, but just the attributes that the user wishes to update, as reported in the example below.

Normal Response Code: 200 Ok

Error Response Codes: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found

JSON Request and Response sample:

Request:

PUT /v2.0/networks/fc68ea2c-b60b-4b4f-bd82-94ec81110766.json

Content-Type: application/json Accept: application/json

{ "network": {     "name": "updated_name" } }

Response:

status: 200 content-length: 192 content-type: application/json

{ "network": {"status": "ACTIVE", "subnets": [], "name": "updated_name", "admin_state_up": false, "shared": false, "tenant_id": "c1210485b2424d48804aad5d39c61b8f", "id": "fc68ea2c-b60b-4b4f-bd82-94ec81110766"}}

Delete Network
JSON Request and Response sample:

This operation will remove a Neutron network, and all its associated subnets, provided that no port is currently configured on the network. If ports are still configured on the network being removed, a 409 error will be returned.

Normal Response Code: 204

Error Response Codes: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Network in Use.

Request:

DELETE /v2.0/networks/fc68ea2c-b60b-4b4f-bd82-94ec81110766

Content-Type: application/json Accept: application/json

Response:

status: 204

List Subnets
This operation will return a list of subnets objects the tenant has access to. Default policy settings will return exclusively subnets owned by the tenant submitting the request, unless the request is submitted by an user with administrative rigths. Users can control which attributes should be returned using the fields query parameter as discussed in the previous chapter. Moreover, results can be filtered using query string parameters as discussed in the previous chapter.

This operation does not require a reques body.

Normal Response Code: 200 Ok

Error Response Codes: 401 Unauthorized

JSON Request and Response sample:

Request:

GET v2.0/subnets.json

Accept: application/json

Response:

status: 200 content-length: 607 content-type: application/json

{ "subnets": [ {    "name": "", "network_id": "ed2e3c10-2e43-4297-9006-2863a2d1abbc", "tenant_id": "c1210485b2424d48804aad5d39c61b8f", "allocation_pools": [{"start": "10.10.0.2", "end": "10.10.0.254"}], "gateway_ip": "10.10.0.1", "ip_version": 4, "cidr": "10.10.0.0/24", "id": "4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861", "enable_dhcp": true },   {      "name": "", "network_id": "afc75773-640e-403c-9fff-62ba98db1f19", "tenant_id": "ed680f49ff714162ab3612d7876ffce5", "allocation_pools": [{"start": "10.0.0.2", "end": "10.0.0.254"}], "gateway_ip": "10.0.0.1", "ip_version": 4, "cidr": "10.0.0.0/24", "id": "e12f0c45-46e3-446a-b207-9474b27687a6", "enable_dhcp": true }] }

Show Subnet
This operation returns data about the subnet specified in the request URI. Users can control which attributes should be returned using the fields query parameter as discussed in the previous chapter. If the user submitting the request is not authorized to access the requested subnet, or if the requested subnet does not exist, a 404 error will be returned.

This operation does not require a request body.

Normal Response Code: 200 Ok

Error Response Codes: 400 Bad Request, 401 Unauthorized, 404 Not Found

JSON Request and Response sample:

Request:

GET /v2.0/subnets/4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861

Accept: application/json

Response:

status: 200 content-length: 309 content-type: application/json

{ "subnet": {    "name": "", "network_id": "ed2e3c10-2e43-4297-9006-2863a2d1abbc", "tenant_id": "c1210485b2424d48804aad5d39c61b8f", "allocation_pools": [{"start": "10.10.0.2", "end": "10.10.0.254"}], "gateway_ip": "10.10.0.1", "ip_version": 4, "cidr": "10.10.0.0/24", "id": "4156c7a5-e8c4-4aff-a6e1-8f3c7bc83861", "enable_dhcp": false, } }

Create Subnet
This operation creates a new subnet on a specific network. The identifier of the network, network_id is mandatory. The user must also specify the cidr for the subnet, in the form / . The remaining parameters are optional.

By default, Neutron creates IP v4 subnets. In order to create an IP v6 subnet, users must specify the value 6 for the ip_version attribute in the request body. Please note that Neutron does not make any attempt to derive the correct IP version from the provided CIDR. If the parameter for the gateway address, gateway_ip is not specified, then Neutron will allocate an address from the subnet's cidr for the subnet's gateway. In order to specify a subnet without a gateway, users should specify the value null for the gateway_ip attribute in the request body. If allocation pools (attribute allocation_pools) are not specified, Neutron will automatically allocate pools for covering all IP addresses in the CIDR, excluding the address reserved for the subnet gateway. Otherwise users can explicitly specify allocation pools as shown in the example below.

Finally, a subnet by default will leverage DHCP for distributing addresses to VMs. If a different strategy is used, such as, for instance, file system IP configuration injection, the enable_dhcp attribute should be explicitly set to False in a create_subnet request.

Normal Response Code: 201 Created

Error Response Codes: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found

JSON Request and Response sample:

Request:

POST /v2.0/subnets Content-Type: application/json Accept: application/json

{ "subnet": { "network_id": "ed2e3c10-2e43-4297-9006-2863a2d1abbc", "ip_version": 4, "cidr": "10.0.3.0/24", "allocation_pools": [{"start": "10.0.3.20", "end": "10.0.3.150"}] } } }}

Response: {{{ status: 201, content-length: 306, content-type: application/json

{ "subnet": { "name": "", "network_id": "ed2e3c10-2e43-4297-9006-2863a2d1abbc", "tenant_id": "c1210485b2424d48804aad5d39c61b8f", "allocation_pools": [{"start": "10.0.3.20", "end": "10.0.3.150"}], "gateway_ip": "10.0.3.1", "ip_version": 4, "cidr": "10.0.3.0/24", "id": "9436e561-47bf-436a-b1f1-fe23a926e031", "enable_dhcp": true} }

Bulk version
This operation allows for creating several subnets with a single request. To this aim, a list of subnets must be supplied in the request body. The behavior of the operation is always atomic, meaning that either all subnets are created, or none is created.

Request:

POST /v2.0/subnets Content-Type: application/json Accept: application/json

{ "subnets": [ {     "network_id": "ed2e3c10-2e43-4297-9006-2863a2d1abbc", "ip_version": 4, "cidr": "10.0.4.0/24", }   {      "network_id": "ed2e3c10-2e43-4297-9006-2863a2d1abbc", "ip_version": 4, "cidr": "10.0.5.0/24", }  ] }

Update Subnet
This operation updates information concerning a subnet. Some attributes, such as IP version (ip_version), CIDR (cidr), and IP allocation pools ('allocation_pools) cannot be updated. Attempting to update these attributes will result in a 400 Bad Request error.

After updating host_routes and dns_nameservers attributes, there is no guarantee about when these changes will be reflected on running VM instances. The only responsibility of the Neutron API is to update the data model with the new information. When these information are then propagated on running VMs depends on the mechanism used for providing them with IP configuration. In case of DHCP, this will happen as soon as the VMs send a new DHCP request, and therefore it is likely to happen either when the DHCP lease expires or when the VM is rebooted.

Note: Update operations in Neutron adopt patch semantics. This implies that the Neutron API does not require the user to send the whole resource to be updated, but just the attributes that the user wishes to update, as reported in the example below

Normal Response Code: 200 Ok

Error Response Codes: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 400 Bad Request

JSON Request and Response sample:

Request:

PUT /v2.0/subnets/9436e561-47bf-436a-b1f1-fe23a926e031

Content-Type: application/json Accept: application/json

{ "subnet": {     "gateway_ip": "10.0.3.254", "name": "new_name" } }

Response:

status: 200 content-length: 316 content-type: application/json

{ "subnet": {    "name": "new_name", "network_id": "ed2e3c10-2e43-4297-9006-2863a2d1abbc", "tenant_id": "c1210485b2424d48804aad5d39c61b8f", "allocation_pools": [{"start": "10.0.3.20", "end": "10.0.3.150"}], "gateway_ip": "10.0.3.254", "ip_version": 4, "cidr": "10.0.3.0/24", "enable_dhcp": true, "id": "9436e561-47bf-436a-b1f1-fe23a926e031" } }

Delete Subnet
This operation remove a subnet from a Neutron network. The operation will fail if IPs from the subnet being removed are still allocated.

Normal Response Code: 204

Error Response Codes: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict

JSON Request and Response sample:

Request:

DELETE /v2.0/subnets/9436e561-47bf-436a-b1f1-fe23a926e031

Accept: application/json

Response:

Status: 204

List Ports
This operation will return a list of ports objects the tenant has access to. Default policy settings will return exclusively subnets owned by the tenant submitting the request, unless the request is submitted by an user with administrative rigths. Users can control which attributes should be returned using the fields query parameter as discussed in the previous chapter. Moreover, results can be filtered using query string parameters as discussed in the previous chapter.

This operation does not require a reques body.

Normal Response code: 200

Error Response Code: 401 Unauthorized

JSON Request and Response sample:

Request:

GET /v2.0/ports.json HTTP/1.1 accept: application/json

Response:

Status: 200 Content-Type: application/json Content-Length: 805

{   "ports": [ {           "admin_state_up": true, "device_id": "257614cc-e178-4c92-9c61-3b28d40eca44", "device_owner": "", "fixed_ips": [ {                   "ip_address": "192.168.111.3", "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27" }           ],            "id": "24e6637e-c521-45fc-8b8b-d7331aa3c99f", "mac_address": "fa:16:3e:0f:3f:b5", "name": "", "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12", "status": "ACTIVE", "tenant_id": "cf1a5775e766426cb1968766d0191908" },       {            "admin_state_up": true, "device_id": "d266f9de-fe2c-4705-93b3-9da71168c93b", "device_owner": "", "fixed_ips": [ {                   "ip_address": "192.168.111.2", "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27" }           ],            "id": "e54dfd9b-ce6e-47f7-af47-1609cfd1cdb0", "mac_address": "fa:16:3e:f5:41:7f", "name": "", "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12", "status": "ACTIVE", "tenant_id": "cf1a5775e766426cb1968766d0191908" }   ] }

Show Port
This operation will return information regarding the port specified in the request URI. If the port does not exist or the user submitting the request is not authorized to access it, a 404 error is returned.

Normal Response code: 200

Error Response Code: 400 Bad Request, 401 Unauthorized, 404 Not Found

JSON Request and Response sample:

Request:

GET /v2.0/ports/ebe69f1e-bc26-4db5-bed0-c0afb4afe3db.json accept: application/json

Response:

Status: 200 Content-Type: application/json Content-Length: 410

{   "port": { "admin_state_up": true, "device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0", "device_owner": "", "fixed_ips": [ {               "ip_address": "192.168.111.4", "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27" }       ],        "id": "ebe69f1e-bc26-4db5-bed0-c0afb4afe3db", "mac_address": "fa:16:3e:a6:50:c1", "name": "port1", "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12", "status": "ACTIVE", "tenant_id": "cf1a5775e766426cb1968766d0191908" } }

Create Port
This operation creates a new Neutron port. The network where the port shall be created (network_id parameter) in the request body, must be specified. Optionally, user can also specify the following parameters:


 * A symbolic name for the port
 * MAC address
 * Administrative state (True: Up, False: Down)
 * Fixed IPs
 * Specifying just a subnet id, Neutron allocates the first available IP from that subnet to the port
 * Specifying both a subnet id and an IP address, Neutron will try to allocate the specified address to the port
 * Identifier of the device attached to the port (e.g.: VM identifier)
 * Identifier of the owner of the device attached to the port (e.g.: DHCP agent identifier)

Normal Response code: 201

Error Response Code: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict

JSON Request and Response sample:

Request:

POST /v2.0/ports.json HTTP/1.1 Content-Length: 158 content-type: application/json accept: application/json

{   "port": { "admin_state_up": true, "device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0", "name": "port1", "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12" } }

Response:

Status: 201 Content-Type: application/json; charset=UTF-8 Content-Length: 410

{   "port": { "admin_state_up": true, "device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0", "device_owner": "", "fixed_ips": [ {               "ip_address": "192.168.111.4", "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27" }       ],        "id": "ebe69f1e-bc26-4db5-bed0-c0afb4afe3db", "mac_address": "fa:16:3e:a6:50:c1", "name": "port1", "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12", "status": "ACTIVE", "tenant_id": "cf1a5775e766426cb1968766d0191908" } }

Bulk version
This operation allows for creating several ports with a single request. To this aim, a list of ports must be supplied in the request body. The Neutron API always guarantees the atomic completion of the bulk operation.

Bulk Request example:

{   "ports": [ {        "admin_state_up": true, "device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0", "name": "port1", "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12" },       {         "admin_state_up": true, "device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0", "name": "port2", "network_id": "2cd34a97-e087-75fb-9904-dd12937009ea" }    ] }

Update Port
This operation can be used for updating information on a port, such as the symbolic name and the associated IPs. When IPs for a port are updated, the previously associated IPs are removed, returned to the respective subnets allocation pools, and replaced by the IPs specified in the body for the Update request. In other words, the behavior of this operation is to replace the fixed_ip attribute when it is specified in the request body. If the new IP addresses are invalid (e.g.: already in use), the operation fail and the existing IP addresses are not disassociated from the port.

Please note that the only responsibility of the API is to update the data model with the new IP association information. The way in which IP addresses are actually updated on running VMs depends on the particular mechanism used to propagate IP configuration. In case of DHCP, this would happen either when the DHCP lease expires, or when the VM is rebooted.

Normal Response code: 200

Error Response Code: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict

JSON Request and Response sample:

Request:

PUT /v2.0/ports/1d8591f4-7b62-428e-857d-e82a15e5a7f1.json HTTP/1.1 Content-Length: 63 content-type: application/json accept: application/json

{   "port": { "device_id": "37b4f622-5e17-4dca-bf67-7338c5b7dd63" } }

Response:

Status: 200 Content-Type: application/json; Content-Length: 410

{   "port": { "admin_state_up": true, "device_id": "37b4f622-5e17-4dca-bf67-7338c5b7dd63", "fixed_ips": [ {               "ip_address": "192.168.111.4", "subnet_id": "22b44fc2-4ffb-4de4-b0f9-69d58b37ae27" }       ],        "id": "1d8591f4-7b62-428e-857d-e82a15e5a7f1", "mac_address": "fa:16:3e:70:d2:8c", "name": "port2", "network_id": "6aeaf34a-c482-4bd3-9dc3-7faf36412f12", "status": "ACTIVE", "tenant_id": "cf1a5775e766426cb1968766d0191908" } }

Delete Port
This operation removes a port from a Neutron network. If IP addresses are associated with the port, they are returned to the respective subnets allocation pools.

Normal Response code: 204

Error Response Code: 401 Unauthorized, 403 Forbidden, 404 Not Found

JSON Request and Response sample:

Request:

DELETE /v2.0/ports/ebe69f1e-bc26-4db5-bed0-c0afb4afe3db.json accept: application/json

Response:

status: 204