華為云計(jì)算 云知識(shí) 查詢端口列表NeutronListPorts
查詢端口列表NeutronListPorts

 

功能介紹

查詢提交請(qǐng)求的租戶的所有端口,單次查詢最多返回2000條數(shù)據(jù),超過2000后會(huì)返回分頁標(biāo)記。分頁查詢請(qǐng)參考分頁查詢。

調(diào)試

您可以在API Explorer中調(diào)試該接口。

URI

GET /v2.0/ports

樣例:

GET https://{Endpoint}/v2.0/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}&tenant_id={tenant_id}&status={port_status}&
fixed_ips=ip_address={ip_address}&fixed_ips=subnet_id={subnet_id}&dns_name={dns_name}

分頁查詢樣例:

GET https://{Endpoint}/v2.0/ports?limit=2&marker=791870bd-36a7-4d9b-b015-a78e9b06af08&page_reverse=False

參數(shù)說明請(qǐng)參見表1。

表1 參數(shù)說明

名稱

是否必選

參數(shù)類型

id

String

name

String

admin_state_up

Boolean

network_id

String

mac_address

String

device_id

String

device_owner

String

status

String

security_groups

Array of strings

fixed_ips

Array of strings

tenant_id

String

marker

String

limit

Integer

請(qǐng)求消息

請(qǐng)求示例

【示例一】

GET https://{Endpoint}/v2.0/ports?limit=1

【示例二】

GET https://{Endpoint}/v2.0/ports?mac_address=fa:16:3e:f1:0b:09

【示例三】

GET https://{Endpoint}/v2.0/ports?admin_state_up=False

【示例四】

GET https://{Endpoint}/v2.0/ports?device_id=e6c05704-c907-4cc1-8106-69b0996c43b9

【示例五】

GET https://{Endpoint}/v2.0/ports?tenant_id=6c9298ec8c874f7f99688489ab65f90e&name=port_vm_50_3

【示例六】

GET https://{Endpoint}/v2.0/ports?name=port_vm_50_3

響應(yīng)參數(shù)

表2 響應(yīng)參數(shù)

參數(shù)名稱

類型

ports

Array of port objects

ports_links

Array of ports_link objects

表4 fixed_ip對(duì)象

屬性

類型

說明

subnet_id

String

所屬子網(wǎng)ID

【使用說明】不支持更新

ip_address

String

端口IP地址

【使用說明】不支持更新

表5 allowed_address_pairs對(duì)象

名稱

是否必選

參數(shù)類型

ip_address

String

mac_address

String

表6 extra_dhcp_opt對(duì)象

屬性

類型

說明

opt_name

String

Option名稱

opt_value

String

Option值

表7 binding:vif_details對(duì)象

名稱

參數(shù)類型

primary_interface

Boolean

port_filter

Boolean

ovs_hybrid_plug

Boolean

表8 dns_assignment對(duì)象

名稱

參數(shù)類型

說明

hostname

String

端口hostname

ip_address

String

端口IP地址

fqdn

String

端口內(nèi)網(wǎng)fqdn

表9 ports_link對(duì)象

名稱

參數(shù)類型

說明

href

String

API鏈接

rel

String

API鏈接與該API版本的關(guān)系

響應(yīng)示例

【示例一】
{
 "ports": [{
       "id": "791870bd-36a7-4d9b-b015-a78e9b06af08",
       "name": "port-test",
       "status": "DOWN",
       "admin_state_up": true,
       "fixed_ips": [],
       "mac_address": "fa:16:3e:01:e0:b2",
       "network_id": "00ae08c5-f727-49ab-ad4b-b069398aa171",
       "tenant_id": "db82c9e1415a464ea68048baa8acc6b8",
       "project_id": "db82c9e1415a464ea68048baa8acc6b8",
       "device_id": "",
       "device_owner": "",
       "security_groups": ["d0d58aa9-cda9-414c-9c52-6c3daf8534e6"],
       "extra_dhcp_opts": [],
       "allowed_address_pairs": [],
       "binding:vnic_type": "normal",
       "binding:vif_details": {},
       "binding:profile": {},
       "port_security_enabled": true,
       "created_at": "2018-09-13T01:43:41",
       "updated_at": "2018-09-13T01:43:41"
 }],
    "ports_links": [
       {
            "rel": "next", 
            "href": "https://{Endpoint}/v2.0/ports?limit=1&marker=791870bd-36a7-4d9b-b015-a78e9b06af08"
        }, 
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/ports?limit=1&marker=791870bd-36a7-4d9b-b015-a78e9b06af08&page_reverse=True"
        }
    ]
}

【示例二】
{
    "ports": [
        {
            "admin_state_up": true,
            "allowed_address_pairs": [],
            "binding:vnic_type": "normal",
            "device_id": "e6c05704-c907-4cc1-8106-69b0996c43b9",
            "device_owner": "compute:az3.dc1",
            "port_security_enabled":true,
            "extra_dhcp_opts": [],
            "fixed_ips": [
                {
                    "ip_address": "172.16.0.37",
                    "subnet_id": "b3ac1347-63f2-4e82-b853-3d86416a0db5"
                }
            ],
            "dns_assignment": [
                {
                    "hostname": "ip-172-16-0-37",
                    "ip_address": "172.16.0.37",
                    "fqdn": "ip-172-16-0-37.xxx.compute.internal."
                }
            ],
            "dns_name": "ip-172-16-0-37",
            "id": "7bb64706-6e46-4f94-a28a-4bc7caaab87d",
            "mac_address": "fa:16:3e:f1:0b:09",
            "name": "port_vm_50_3",
            "network_id": "a54e1b19-ce78-4b7e-b28b-d2d716cdc161",
            "security_groups": [
                "ef69bc60-2f4b-4f97-b95b-e3b68df0c0b2"
            ],
            "status": "ACTIVE",
            "tenant_id": "6c9298ec8c874f7f99688489ab65f90e",
            "project_id": "6c9298ec8c874f7f99688489ab65f90e", 
            "created_at": "2018-09-13T01:43:41",
            "updated_at": "2018-09-13T01:43:41"
        }
    ],
    "ports_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/ports?mac_address
=fa%3A16%3A3e%3Af1%3A0b%3A09&marker=7bb64706-6e46-4f94-a28a-4bc7caaab87d&page_reverse=True" } ] }

【示例三】
{
    "ports": [

        {
            "admin_state_up": false, 
            "allowed_address_pairs": [], 
            "binding:vnic_type": "normal", 
            "device_id": "", 
            "device_owner": "", 
            "port_security_enabled":true,
            "extra_dhcp_opts": [], 
            "fixed_ips": [
                {
                    "ip_address": "10.100.100.62", 
                    "subnet_id": "9b28f20c-0234-419f-a0b4-4a84f182f64b"
                }
            ], 
            "dns_name": "",
            "id": "ffc0bdee-8413-4fa2-bd82-fa8efe5b3a87", 
            "mac_address": "fa:16:3e:2b:bc:57", 
            "name": "small_net_port", 
            "network_id": "b299b151-7a66-4c6f-a313-cdd3b5724296", 
            "security_groups": [
                "ef69bc60-2f4b-4f97-b95b-e3b68df0c0b2"
            ], 
            "status": "DOWN", 
            "tenant_id": "6c9298ec8c874f7f99688489ab65f90e",
            "project_id": "6c9298ec8c874f7f99688489ab65f90e", 
            "created_at": "2018-09-13T01:43:41",
            "updated_at": "2018-09-13T01:43:41"
        }
    ],
    "ports_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/ports?admin_state_up=False&marker=ffc0bdee-8413-4fa2-bd82-fa8efe5b3a87&page_reverse=True"
        }
    ]
}

【示例四】
{
    "ports": [
        {
            "admin_state_up": true, 
            "allowed_address_pairs": [], 
            "binding:vnic_type": "normal", 
            "device_id": "e6c05704-c907-4cc1-8106-69b0996c43b9", 
            "device_owner": "compute:az3.dc1", 
            "port_security_enabled":true,
            "extra_dhcp_opts": [], 
            "fixed_ips": [
                {
                    "ip_address": "10.1.0.37", 
                    "subnet_id": "b3ac1347-63f2-4e82-b853-3d86416a0db5"
                }
            ], 
            "dns_assignment": [
                {
                    "hostname": "ip-10-1-0-37",
                    "ip_address": "10.1.0.37",
                    "fqdn": "ip-10-1-0-37.xxx.compute.internal."http://xxx為區(qū)域名稱。
                }
            ],
            "dns_name": "ip-10-1-0-37",
            "id": "7bb64706-6e46-4f94-a28a-4bc7caaab87d", 
            "mac_address": "fa:16:3e:f1:0b:09", 
            "name": "port_vm_50_3", 
            "network_id": "a54e1b19-ce78-4b7e-b28b-d2d716cdc161", 
            "security_groups": [
                "ef69bc60-2f4b-4f97-b95b-e3b68df0c0b2"
            ], 
            "status": "ACTIVE", 
            "tenant_id": "6c9298ec8c874f7f99688489ab65f90e",
            "project_id": "6c9298ec8c874f7f99688489ab65f90e" ,
            "created_at": "2018-09-13T01:43:41",
            "updated_at": "2018-09-13T01:43:41"
        }
    ],
    "ports_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/ports?device_id=77307088-ae60-49fb-9146-924dcf1d1402
&marker=7bb64706-6e46-4f94-a28a-4bc7caaab87d&page_reverse=True" } ] }

【示例五】
{
    "ports": [
        {
            "admin_state_up": true, 
            "allowed_address_pairs": [], 
            "binding:vnic_type": "normal", 
            "device_id": "e6c05704-c907-4cc1-8106-69b0996c43b9", 
            "device_owner": "compute:az3.dc1", 
            "port_secuirty_enabled":true,
            "extra_dhcp_opts": [], 
            "fixed_ips": [
                {
                    "ip_address": "10.1.0.37", 
                    "subnet_id": "b3ac1347-63f2-4e82-b853-3d86416a0db5"
                }
            ], 
            "dns_assignment": [
                {
                    "hostname": "ip-10-1-0-37",
                    "ip_address": "10.1.0.37",
                    "fqdn": "ip-10-1-0-37.xxx.compute.internal."http://xxx為區(qū)域名稱。
                }
            ],
            "dns_name": "ip-10-1-0-37",
            "id": "7bb64706-6e46-4f94-a28a-4bc7caaab87d", 
            "mac_address": "fa:16:3e:f1:0b:09", 
            "name": "port_vm_50_3", 
            "network_id": "a54e1b19-ce78-4b7e-b28b-d2d716cdc161", 
            "security_groups": [
                "ef69bc60-2f4b-4f97-b95b-e3b68df0c0b2"
            ], 
            "status": "ACTIVE", 
            "tenant_id": "6c9298ec8c874f7f99688489ab65f90e",
            "project_id": "6c9298ec8c874f7f99688489ab65f90e" ,
            "created_at": "2018-09-13T01:43:41",
            "updated_at": "2018-09-13T01:43:41"
        }
    ],
    "ports_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/ports?tenant_id=6c9298ec8c874f7f99688489ab65f90e&name=
port_vm_50_3&marker=7bb64706-6e46-4f94-a28a-4bc7caaab87d&page_reverse=True" } ] }

【示例六】
{
    "ports": [
        {
            "status": "DOWN",
            "allowed_address_pairs": [],
            "extra_dhcp_opts": [],
            "device_owner": "",
            "port_security_enabled":true,
            "fixed_ips": [
                {
                    "subnet_id": "391c74f7-e3b1-405c-8473-2f71a0aec7dc",
                    "ip_address": "10.1.0.33"
                }
            ],
            "dns_name": "",
            "id": "0f405555-739f-4a19-abb7-ec11d005b3a9",
            "security_groups": [
                "043548bc-1020-4be0-885a-caac8530e8f6"
            ],
            "device_id": "",
            "port_security_enabled":true,
            "name": "port_vm_50_3",
            "admin_state_up": true,
            "network_id": "9898a82d-7795-4ad5-bf2c-0ed8b822be4f",
            "tenant_id": "3e4a1816927f405cacbc3dca1e05111e",
            "project_id": "3e4a1816927f405cacbc3dca1e05111e",
            "created_at": "2018-09-13T01:43:41",
            "updated_at": "2018-09-13T01:43:41",
            "binding:vnic_type": "normal",
            "mac_address": "fa:16:3e:b0:d9:cf"
        },
        {
            "status": "ACTIVE",
            "allowed_address_pairs": [],
            "extra_dhcp_opts": [],
            "device_owner": "compute:az3.dc1",
            "port_security_enabled":true,
            "fixed_ips": [
                {
                    "subnet_id": "b3ac1347-63f2-4e82-b853-3d86416a0db5",
                    "ip_address": "10.1.0.37"
                }
            ],
            "dns_assignment": [
                {
                    "hostname": "ip-10-1-0-37",
                    "ip_address": "10.1.0.37",
                    "fqdn": "ip-10-1-0-37.xxx.compute.internal."http://xxx為區(qū)域名稱。
                 }  
            ],
            "dns_name": "ip-10-1-0-37",
            "id": "7bb64706-6e46-4f94-a28a-4bc7caaab87d",
            "security_groups": [
                "ef69bc60-2f4b-4f97-b95b-e3b68df0c0b2"
            ],
            "device_id": "e6c05704-c907-4cc1-8106-69b0996c43b9",
            "name": "port_vm_50_3",
            "admin_state_up": true,
            "network_id": "a54e1b19-ce78-4b7e-b28b-d2d716cdc161",
            "tenant_id": "6c9298ec8c874f7f99688489ab65f90e",
            "project_id": "3e4a1816927f405cacbc3dca1e05111e",
            "created_at": "2018-09-13T01:43:41",
            "updated_at": "2018-09-13T01:43:41",
             "binding:vnic_type": "normal", 
            "binding:vnic_type": "normal",
            "mac_address": "fa:16:3e:f1:0b:09"
        }
    ],
    "ports_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/ports?name=port_vm_50_3&marker=0f405555-739f-4a19-abb7-ec11d005b3a9&page_reverse=True"
        }
    ]
}

狀態(tài)碼

請(qǐng)參見狀態(tài)碼。

錯(cuò)誤碼

請(qǐng)參見錯(cuò)誤碼。