Verb | URI | Description |
POST | /ports | Creates a port on a specified network. |
Normal Response Code: 201
Error Response Codes: Bad Request (400), Unauthorized (401), Forbidden (403), Not Found (404), Conflict (409), MAC generation failure (503)
This operation creates a new OpenStack
Networking port. You must specify the network
where the port is to created on the
network_id
attribute in
the request body.
If you specify a security group ID, this port is associated with the security group. You can associate more than one security group with a port.
You can also specify the following optional attributes:
Security groups. Specify one or more security group IDs.
A symbolic name for the port
MAC address. If you specify an address that is not valid, a
400 Bad Request
error is returnedIf the specified MAC address is already in use, a
409 Conflict
error is returned.When the MAC address is not specified, OpenStack Networking tries to allocate one for the port being created.
If a failure occurs while generating the address, a
503 Service Unavailable
error is returned.Administrative state. Set to
true
for up, andfalse
for down.Fixed IPs
If you specify just a subnet ID, OpenStack Networking allocates an available IP from that subnet to the port.
If you specify both a subnet ID and an IP address, OpenStack Networking tries to allocate the specified address to the port.
Host routes for the port, in addition to the host routes defined for the subnets with which the port is associated.
This operation requires a request body.
This operation returns a response body.
Example 4.31. Create Port: JSON 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":"24df1d04-d5cb-41e1-8de5-61ed77c558df", "name":"port1", "network_id":"abaf2e70-4305-4e8d-ac70-3e4cc5f66a07", "security_groups":[ "85cc3048-abc3-43cc-89b3-377341426ac5" ] } }
Example 4.32. Create Port: JSON Response
{ "port":{ "admin_state_up":true, "device_id":"24df1d04-d5cb-41e1-8de5-61ed77c558df", "device_owner":"", "fixed_ips":[ { "ip_address":"10.0.0.4", "subnet_id":"3b498f11-0a20-43ed-b992-0e4202d5f930" } ], "id":"358c03ee-20f8-40d2-b74b-9b21a9df10a7", "mac_address":"fa:16:3e:ac:95:a9", "name":"port1", "network_id":"abaf2e70-4305-4e8d-ac70-3e4cc5f66a07", "security_groups":[ "85cc3048-abc3-43cc-89b3-377341426ac5" ], "status":"DOWN", "tenant_id":"e4f50856753b4dc6afee5fa6b9b6c550" } }