Description
When you're not sure of network ID
Caution about specifying "fixed_ips"
Caution about creating a port for DBserver network
Request URL
Network API v2.0 POST /v2.0/ports
Request Paramters
Parameter | Value | Style | Description |
---|---|---|---|
X-Auth-Token | User Token | header | |
network_id | Network ID | plain | |
security_groups (Optional) | plain | If you do not specify any, the default setting (security group) will be automatically applied. | |
fixed_ips(Optional) | plain | Use this parameter when you want to specify an IP address | |
allowed_address_pairs(Optional) | plain | Use this parameter when you use VIP |
The parameter will be different for each network. So you should be careful.
add ip net | local net | DB net | |
---|---|---|---|
network_id | Required | Required | Required |
security_groups | Optional | Optional | Optional |
fixed_ips | Optional | Optional | x |
allowed_address_pairs | Optional | x | x |
Request Json(IP auto allocated)
{ "port": { "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7" } }
Request Json(fixed IP)
{ "port": { "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7", "fixed_ips": [ { "ip_address": "157.7.80.103", "subnet_id": "bca5f8ff-1d43-4118-9e99-2882da34cd5b" } ] } }
Request Json(fixed allowed_address_pairs)
{ "port": { "network_id": "78c3a130-7325-4a59-8e2f-fb18f107ff80", "allowed_address_pairs": [ { "ip_address": "2400:8500:1301:2078:a17:7:8:255/124" } ] } }
Request Json(When Specifying Security Group)
{ "port": { "network_id": "799158d5-cc2a-42e9-93c5-99307b9ab2e9", "fixed_ips": [ { "ip_address": "157.7.80.103", "subnet_id": "bca5f8ff-1d43-4118-9e99-2882da34cd5b" } ], "security_groups": [ "659dffb6-852a-46a3-8fbb-add8d23bb73a" ] } }
Request Json(when creating multiple ports)
{ "ports": [ { "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7", "fixed_ips": [ { "ip_address": "157.7.80.103", "subnet_id": "bca5f8ff-1d43-4118-9e99-2882da34cd5b" } ] }, { "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7", "fixed_ips": [ { "ip_address": "157.7.80.103", "subnet_id": "bca5f8ff-1d43-4118-9e99-2882da34cd5b" } ] } ] }
Normal response codes
201
Example
curl -i -X POST \ -H "Accept: application/json" \ -H "X-Auth-Token: 0925897a3d4543218ff0dcd2bb378a8e" \ -d '{"port":{"network_id":"9656c592-7cb3-48f0-ac28-fc457bfe371f","fixed_ips":[{"ip_address":"133.130.50.63","subnet_id":"4c048fed-51c8-43b4-9975-c498dc3fced9"}]}}' \ https://networking.tyo1.cloud.z.com/v2.0/ports
HTTP/1.1 201 Created Server: openresty/1.7.10.1 Date: Fri, 08 May 2015 10:08:06 GMT Content-Type: application/json Content-Length: 505 Connection: keep-alive { "port": { "status": "DOWN", "name": "add-i_100000-o_100000-p_0a", "allowed_address_pairs": [], "admin_state_up": true, "network_id": "9656c592-7cb3-48f0-ac28-fc457bfe371f", "tenant_id": "22394afc818d471ca2f0308c06ae7460", "binding:vnic_type": "normal", "device_owner": "", "mac_address": "fa:16:3e:71:31:94", "fixed_ips": [ { "subnet_id": "4c048fed-51c8-43b4-9975-c498dc3fced9", "ip_address": "133.130.50.63" } ], "id": "86b8db4b-c6ac-4b19-86b7-04eb4c0a3695", "security_groups": [ "6cdb77f5-0e85-49cf-b093-acb3ab41e730" ], "device_id": "" } }
curl -i -X POST \ -H "Accept: application/json" \ -H "X-Auth-Token: 0925897a3d4543218ff0dcd2bb378a8e" \ -d '{"ports":[{"name":"test-port1","admin_state_up":true,"network_id":"9656c592-7cb3-48f0-ac28-fc457bfe371f"},{"name":"test-port2","admin_state_up":true,"network_id":"9656c592-7cb3-48f0-ac28-fc457bfe371f"}]}' \ https://networking.tyo1.cloud.z.com/v2.0/ports
HTTP/1.1 201 Created Server: openresty/1.7.10.1 Date: Fri, 08 May 2015 10:13:20 GMT Content-Type: application/json Content-Length: 1005 Connection: keep-alive { "ports": [ { "status": "DOWN", "name": "add-i_100000-o_100000-p_0a", "allowed_address_pairs": [], "admin_state_up": true, "network_id": "9656c592-7cb3-48f0-ac28-fc457bfe371f", "tenant_id": "22394afc818d471ca2f0308c06ae7460", "binding:vnic_type": "normal", "device_owner": "", "mac_address": "fa:16:3e:b3:f4:37", "fixed_ips": [ { "subnet_id": "4c048fed-51c8-43b4-9975-c498dc3fced9", "ip_address": "133.130.50.48" } ], "id": "5a22c0aa-d84d-47d3-ba82-2ab606376b03", "security_groups": [ "6cdb77f5-0e85-49cf-b093-acb3ab41e730" ], "device_id": "" }, { "status": "DOWN", "name": "add-i_100000-o_100000-p_0a", "allowed_address_pairs": [], "admin_state_up": true, "network_id": "9656c592-7cb3-48f0-ac28-fc457bfe371f", "tenant_id": "22394afc818d471ca2f0308c06ae7460", "binding:vnic_type": "normal", "device_owner": "", "mac_address": "fa:16:3e:11:fa:10", "fixed_ips": [ { "subnet_id": "4c048fed-51c8-43b4-9975-c498dc3fced9", "ip_address": "133.130.50.49" } ], "id": "fa0b7f8c-8e9a-418d-81cb-0e3c4ebf03d0", "security_groups": [ "6cdb77f5-0e85-49cf-b093-acb3ab41e730" ], "device_id": "" } ] }