Querying Ports
Function
This API is used to query ports.
URI
GET /v1/{project_id}/ports
GET https://{Endpoint}/v1/{project_id}/ports?id={port_id}&name={port_name}&admin_state_up={is_admin_status_up}&network_id={network_id}&mac_address={port_mac}&device_id={port_device_id}&device_owner={device_owner}&status={port_status}&fixed_ips=ip_address={ip_address}&fixed_ips=subnet_id={subnet_id}
Name |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID. |
id |
No |
String |
Specifies that the port ID is used as the filter. |
name |
No |
String |
|
admin_state_up |
No |
Boolean |
Specifies that the administrative state is used as the filter. |
network_id |
No |
String |
Specifies that the network ID is used as the filter. |
mac_address |
No |
String |
Specifies that the MAC address is used as the filter. |
device_id |
No |
String |
Specifies that the device ID is used as the filter. |
device_owner |
No |
String |
Specifies that the device owner is used as the filter. |
status |
No |
String |
|
security_groups |
No |
Array of strings |
Specifies that the security group is used as the filtering condition. |
marker |
No |
String |
Specifies a resource ID for pagination query, indicating that the query starts from the next record of the specified resource ID. This parameter can work together with the parameter limit.
|
limit |
No |
Integer |
Specifies the number of records that will be returned on each page. The value is from 0 to intmax (2^31-1). The default value is 2000. limit can be used together with marker. For details, see the parameter description of marker. |
fixed_ips |
No |
Array of strings |
Filter by fixed_ips=ip_address={ip_address} or fixed_ips=subnet_id={subnet_id}. Set {ip_address} to an IP address, for example, 192.168.21.22. Set {subnet_id} to the IPv4 or IPv6 subnet ID, for example, 011fc878-5521-4654-a1ad-f5b0b5820302. |
enterprise_project_id |
No |
String |
NOTE:
For more information about enterprise projects and how to obtain enterprise project IDs, see the Enterprise Management User Guide. |
enable_efi |
No |
Boolean |
Specifies that whether efi is enabled is used as the filtering condition. |
Request Parameters
None
Example Request
GET https://{Endpoint}/v1/{project_id}/ports
Response Parameters
Name |
Type |
Description |
---|---|---|
ports |
Array of port objects |
Specifies the port objects. For details, see Table 3. |
Parameter |
Type |
Description |
---|---|---|
id |
String |
Specifies the port ID, which uniquely identifies the port. |
name |
String |
|
network_id |
String |
NOTE:
To obtain the network ID:
|
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 |
If the value of allowed_address_pairs is the IP address of the ECS NIC, the port corresponding to the virtual IP address is bound. |
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 6. |
binding:vif_details |
binding:vif_details object |
For details, see Table 7. |
binding:profile |
Object |
Specifies the user-defined settings. This is an extended attribute. Notes
|
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 that the port belongs to. |
enable_efi |
Boolean |
|
ipv6_bandwidth_id |
String |
|
Name |
Type |
Description |
---|---|---|
subnet_id |
String |
Specifies the subnet ID. If you use the management console, the value of this parameter is the IPv4 Subnet ID or IPv6 Subnet ID value. You cannot change the parameter value. |
ip_address |
String |
Specifies the port IP address. |
Name |
Type |
Description |
---|---|---|
ip_address |
String |
|
mac_address |
String |
Specifies the MAC address. |
Name |
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 |
Specifies the value of the DHCP option. If the value of opt_name is 51, the value format of opt_value is Xh, indicating that the DHCP lease time is X hours. The value of X is -1 or from 1 to 30000. If the value is -1, the DHCP lease time is infinite. |
Name |
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
{ "ports": [ { "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", "instance_type": "RDS", "instance_id": "03a4e9ee-64eb-4a31-802e-5490df22146c", "enable_efi": false }, { "id": "28ba8f45-7636-45e4-8c0a-675d7663717c", "name": "test1", "status": "DOWN", "admin_state_up": "true", "fixed_ips": [ { "subnet_id": "061d3ca2-bd1f-4bd1-a01d-7a5155328c0e", "ip_address": "192.168.10.10" } ], "dns_name": "", "mac_address": "fa:16:3e:3d:91:cd", "network_id": "be2fe79a-3ee2-4d87-bd71-5afa78a5670d", "tenant_id": "43f2d1cca56a40729dcb17212482f34d", "device_id": "", "device_owner": "", "security_groups": [ "0bfc8687-ca18-4c37-ac84-d2198baba585" ], "extra_dhcp_opts": [], "allowed_address_pairs": [], "binding:vnic_type": "normal", "enable_efi": false } ] }
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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot