Consulta de puertos
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 Obtención de un ID de proyecto. |
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 |
Especifica un ID de recurso para la consulta de paginación, que indica que la consulta comienza en el siguiente registro del ID de recurso especificado. Este parámetro puede funcionar junto con el parámetro limit.
|
limit |
No |
Integer |
Especifica el número de registros que se devolverán en cada página. El valor es de 0 a intmax (2^31-1). limit se puede utilizar junto con marker. Para obtener más información, consulte la descripción de parámetros de marker. |
fixed_ips |
No |
Array of strings |
You can use fixed_ips=ip_address or fixed_ips=subnet_id for filtering. |
enterprise_project_id |
No |
String |
NOTA:
Para obtener más información acerca de los proyectos de empresa y cómo obtener los ID de proyecto de empresa, consulte la Guía del usuario de Enterprise Management. |
Request Message
- Request parameter
None
- Example request
GET https://{Endpoint}/v1/{project_id}/ports
Response Message
- Response parameter
Tabla 2 Response parameter Name
Type
Description
ports
Array of port objects
Specifies the port objects. For details, see Tabla 3.
Tabla 3 Description of the port field Parameter
Type
Description
id
String
Specifies the port ID, which uniquely identifies the port.
name
String
- Specifies the port name.
- The value can contain no more than 255 characters. This parameter is left blank by default.
network_id
String
- Specifies the ID of the network that the port belongs to.
- The network ID must be a real one in the network environment.
NOTA:To obtain the network ID:
- Method 1: Log in to the VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page.
- Method 2: Call the API for querying subnets. For details, see Querying Subnets.
admin_state_up
Boolean
- Specifies the administrative state of the port.
- The value can only be true, and the default value is true.
mac_address
String
- Specifies the port MAC address.
- The system automatically sets this parameter, and you are not allowed to configure the parameter value.
fixed_ips
Array of fixed_ip objects
- Specifies the port IP address. For example, the value is "fixed_ips": [{"subnet_id": "4dc70db6-cb7f-4200-9790-a6a910776bba", "ip_address": "192.169.25.79"}]. For details, see Tabla 4.
- In IPv4 scenarios, a port supports only one fixed IP address that cannot be changed. In IPv6 scenarios, a port supports a maximum of two fixed IP addresses that cannot be changed.
device_id
String
- Specifies the ID of the device that the port belongs to.
- The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
device_owner
String
- Specifies the belonged device, which can be the DHCP server, router, load balancer, or Nova.
- The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
tenant_id
String
Specifies the project ID.
status
String
- Specifies the port status. The status of a HANA SR-IOV VM port is always DOWN.
- The value can be ACTIVE, BUILD, or DOWN.
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 allow_address_pair objects
- Specifies a set of zero or more allowed address pairs. An address pair consists of an IP address and a MAC address. For details, see Tabla 5.
- The IP address cannot be 0.0.0.0/0.
- Configure a dedicated security group for the port if the parameter allowed_address_pairs has a large CIDR block (subnet mask less than 24).
- If the value of allowed_address_pairs is 1.1.1.1/0, the source/destination check is disabled.
- Set allowed_address_pairs of the cloud server to 1.1.1.1/0.
extra_dhcp_opts
Array of extra_dhcp_opt objects
Specifies the extended option (extended attribute) of DHCP. For details, see Tabla 6.
binding:vif_details
binding:vif_details object
For details, see Tabla 7.
binding:profile
Object
- Specifies the custom information configured by users. This is an extended attribute.
binding:vnic_type
String
- Specifies the type of the bound vNIC.
- The value can be normal or direct.
- Parameter normal indicates software switching. Parameter direct indicates SR-IOV PCIe passthrough, which is not supported.
dns_assignment
Array of dns_assignment objects
- Specifies the default private domain name information of the primary NIC.
- The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
dns_name
String
- Specifies the default private network DNS name of the primary NIC.
- The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
instance_id
String
- Specifies the ID of the instance to which the port belongs, for example, RDS instance ID.
- The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
instance_type
String
- Specifies the type of the instance to which the port belongs, for example, RDS.
- The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
port_security_enabled
Boolean
- Specifies whether the security option is enabled for the port. If the option is not enabled, the security group and DHCP snooping do not take effect.
zone_id
String
Specifies the availability zone that the port belongs to.
Tabla 4 Objeto de fixed_ip Nombre
Tipo
Descripción
subnet_id
String
Especifica el ID de subred.
Si utiliza la consola de gestión, el valor de este parámetro es el valor Network ID.
No se puede cambiar el valor del parámetro.
ip_address
String
Especifica la dirección IP del puerto.
Tabla 5 Objeto de allow_address_pair Nombre
Tipo
Descripción
ip_address
String
- Especifica la dirección IP.
- No se puede establecer en 0.0.0.0/0.
- Configure un grupo de seguridad dedicado para el puerto si el parámetro allowed_address_pairs tiene un bloque CIDR grande (máscara de subred menor que 24).
- Si el valor de allowed_address_pairs es 1.1.1.1/0, la comprobación de origen/destino está deshabilitada.
- Establezca el allowed_address_pairs del servidor en la nube en 1.1.1.1/0.
mac_address
String
Especifica la dirección MAC.
Tabla 6 Objeto de extra_dhcp_opt Nombre
Tipo
Descripción
opt_name
String
Especifica el nombre de la opción DHCP. El valor de este parámetro sólo puede ser 51, lo que indica el tiempo de concesión DHCP.
opt_value
String
Especifica el valor de la opción DHCP.
Si el valor de opt_name es 51, el formato de valor de opt_value es Xh, lo que indica que el tiempo de concesión DHCP es X horas.
El valor de X es -1 o de 1 a 30000. Si el valor es -1, el tiempo de concesión DHCP es infinito.
Tabla 7 objeto binding:vif_details Nombre
Tipo
Descripción
primary_interface
Boolean
Si el valor es true, esta es la NIC principal.
port_filter
Boolean
Especifica el puerto utilizado para filtrar en grupos de seguridad para protegerse contra la suplantación de MAC o IP.
ovs_hybrid_plug
Boolean
Especifica que el conector híbrido OVS debe ser utilizado por las API de Nova.
- 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" }, { "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" } ] }
Status Code
See Códigos de estado.
Error Code
See Códigos de error.