Creating a Port
Function
This API is used to create a port to provide functions such as virtual IP addresses and NICs.
URI
POST /v1/{project_id}/ports
Parameter |
Mandatory |
Description |
---|---|---|
project_id |
Yes |
Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
port |
Yes |
port object |
Specifies the port objects. For details, see Table 3. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
|
network_id |
Yes |
String |
|
admin_state_up |
No |
Boolean |
|
device_owner |
No |
String |
|
fixed_ips |
No |
Array of fixed_ip objects |
|
tenant_id |
No |
String |
Specifies the project ID. |
security_groups |
No |
Array of strings |
Specifies the UUID of the security group, for example, "security_groups": ["a0608cbf-d047-4f54-8b28-cd7b59853fff"]. This is an extended attribute. |
allowed_address_pairs |
No |
Array of allowed_address_pairs objects |
|
extra_dhcp_opts |
No |
Array of extra_dhcp_opt objects |
Specifies the extended option (extended attribute) of DHCP. For details, see Table 6. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
ip_address |
Yes |
String |
|
mac_address |
No |
String |
Specifies the MAC address. By default, the MAC address of the local port is used. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
opt_name |
No |
String |
Specifies the name of the DHCP option. The value of this parameter can only be 51, indicating the DHCP lease time. |
opt_value |
No |
String |
|
Example Request
- Create a port. Set its network ID to 28a1c93c-9a5e-4a9f-813b-e495bdef7d34, subnet ID to 06bc2359-d75e-4f96-82f4-313e39c7148c, IP address to 192.168.0.38, and associated security group to f2c5b3fc-b971-4a86-87b9-032586260e3e.
POST https://{Endpoint}/v1/{project_id}/ports { "port": { "fixed_ips": [ { "ip_address": "192.168.0.38", "subnet_id": "06bc2359-d75e-4f96-82f4-313e39c7148c" } ], "network_id": "28a1c93c-9a5e-4a9f-813b-e495bdef7d34", "security_groups": [ "f2c5b3fc-b971-4a86-87b9-032586260e3e" ] } }
Response Parameters
Parameter |
Type |
Description |
---|---|---|
port |
port object |
Specifies the port objects. For details, see Table 8. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Specifies the port ID that uniquely identifies the port. |
name |
String |
|
network_id |
String |
|
admin_state_up |
Boolean |
|
mac_address |
String |
|
fixed_ips |
Array of fixed_ip objects |
|
device_id |
String |
|
device_owner |
String |
|
tenant_id |
String |
Specifies the project ID. |
status |
String |
|
security_groups |
Array of strings |
Specifies the security group UUID (extended attribute). |
allowed_address_pairs |
Array of allowed_address_pairs objects |
|
extra_dhcp_opts |
Array of extra_dhcp_opt objects |
Specifies the extended option (extended attribute) of DHCP. For details, see Table 11. |
binding:vif_details |
binding:vif_details object |
For details, see Table 12. |
binding:profile |
Object |
Specifies the user-defined settings. This is an extended attribute. Note:
|
binding:vnic_type |
String |
|
dns_assignment |
Array of dns_assignment objects |
|
dns_name |
String |
|
instance_id |
String |
|
instance_type |
String |
|
port_security_enabled |
Boolean |
|
zone_id |
String |
Specifies the availability zone to which the port belongs. |
ipv6_bandwidth_id |
String |
|
Parameter |
Type |
Description |
---|---|---|
subnet_id |
String |
|
ip_address |
String |
Specifies the port IP address. |
Parameter |
Type |
Description |
---|---|---|
ip_address |
String |
|
mac_address |
String |
Specifies the MAC address. By default, the MAC address of the local port is used. |
Parameter |
Type |
Description |
---|---|---|
opt_name |
String |
Specifies the name of the DHCP option. The value of this parameter can only be 51, indicating the DHCP lease time. |
opt_value |
String |
|
Parameter |
Type |
Description |
---|---|---|
primary_interface |
Boolean |
If the value is true, this is the primary NIC. |
port_filter |
Boolean |
Specifies the port used for filtering in security groups to protect against MAC or IP spoofing. |
ovs_hybrid_plug |
Boolean |
Specifies that OVS hybrid plug should be used by Nova APIs. |
Example Response
{ "port": { "id": "d00f9c13-412f-4855-8af3-de5d8c24cd60", "name": "test", "status": "DOWN", "admin_state_up": "true", "fixed_ips": [ { "subnet_id": "70f2e74b-e660-410a-b754-0ca46744348a", "ip_address": "10.128.1.10" } ], "dns_name": "", "mac_address": "fa:16:3e:d7:f2:6c", "network_id": "5b808927-13c9-4e60-a4f4-ed6ffe225167", "tenant_id": "43f2d1cca56a40729dcb17212482f34d", "device_id": "", "device_owner": "", "security_groups": [ "02b4e8ee-74fa-4a31-802e-5490df11245e" ], "extra_dhcp_opts": [], "allowed_address_pairs": [], "binding:vnic_type": "normal" } }
Status Code
See Status Codes.
Error Code
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.