• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Neutron
  5. Port
  6. List ports

List ports

Function Description

Query all ports accessible to the tenant submitting the request.

Interface Format

Method

URI

Description

GET

/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={id_address}&fixed_ips=subnet_id={subnet_id}

Queries all ports accessible to the tenant submitting the request.

Restrictions

N/A

Extension Description

N/A

Request Parameter

N/A

Response Parameter

Parameter

Type

Mandatory

Description

ports

List(port)

Yes

Specifies the port object list.

For details, see Table 1.

Example Request

[Example 1]

  • Example JSON request
GET /v2.0/ports?limit=2&marker=0000f817-6d8d-46a0-85b7-2eb53a2e6bcb
  • Example JSON response
{
    "ports": [
        {
            "admin_state_up": true, 
            "allowed_address_pairs": [], 
            "binding:vnic_type": "normal", 
            "device_id": "dhcp4ebd0208-8328-5d69-8c44-ec50939c0967-babaf0c4-d6e5-409c-9bbc-ede841e010f0", 
            "device_owner": "network:dhcp", 
            "port_security_enabled":false,
            "extra_dhcp_opts": [], 
            "fixed_ips": [
                {
                    "ip_address": "172.16.1.2", 
                    "subnet_id": "4d57c51a-e53c-4895-9dc4-23dec6bd6699"
                }
            ], 
            "id": "0050d1cb-202a-4a46-8674-03eb6f06a814", 
            "mac_address": "fa:16:3e:7f:ed:2c", 
            "name": "distributed_dhcp_port", 
            "network_id": "babaf0c4-d6e5-409c-9bbc-ede841e010f0", 
            "security_groups": [], 
            "status": "DOWN", 
            "tenant_id": "3e4a1816927f405cacbc3dca1e05111e"
        }, 
        {
            "admin_state_up": true, 
            "allowed_address_pairs": [], 
            "binding:host_id": "dummy_725DFB13-D21D-B211-9630-000000821800", 
            "binding:vnic_type": "normal", 
            "device_id": "3dc6d518-460e-47c1-a786-5ff2c382fdd6", 
            "device_owner": "network:router_gateway", 
            "port_security_enabled":false,
            "extra_dhcp_opts": [], 
            "fixed_ips": [
                {
                    "ip_address": "10.10.10.53", 
                    "subnet_id": "bb739afa-d755-4cd9-a268-f419927c5a12"
                }
            ], 
            "id": "0102ddd1-e444-4786-9897-d6ae8f6e27c1", 
            "mac_address": "fa:16:3e:51:fd:8c", 
            "name": "", 
            "network_id": "f65e9ebc-ed5d-418b-a931-9a723718ba4e", 
            "security_groups": [], 
            "status": "ACTIVE", 
            "tenant_id": ""
        }
    ], 
    "ports_links": [
        {
            "href": "https://network.localdomain.com:8020/v2.0/ports?limit=2&marker=0102ddd1-e444-4786-9897-d6ae8f6e27c1", 
            "rel": "next"
        }, 
        {
            "href": "https://network.localdomain.com:8020/v2.0/ports?limit=2&marker=0050d1cb-202a-4a46-8674-03eb6f06a814&page_reverse=True", 
            "rel": "previous"
        }
    ]
}

[Example 2]

  • Example JSON request
GET /v2.0/ports?mac_address=fa:16:3e:f1:0b:09
  • Example JSON response
{
    "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"
                }
            ], 
            "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"
        }
    ]
}

[Example 3]

  • Example JSON request
GET /v2.0/ports?admin_state_up=False
  • Example JSON response
{
    "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"
                }
            ], 
            "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"
        }
    ]
}

[Example 4]

  • Example JSON request
GET /v2.0/ports?device_id=e6c05704-c907-4cc1-8106-69b0996c43b9
  • Example JSON response
{
    "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"
                }
            ], 
            "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"
        }
    ]
}

[Example 5]

  • Example JSON request
GET /v2.0/ports?tenant_id=6c9298ec8c874f7f99688489ab65f90e&name=port_vm_50_3
  • Example JSON response
{
    "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"
                }
            ], 
            "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"
        }
    ]
}

[Example 6]

  • Example JSON request
GET /v2.0/ports?name=port_vm_50_3
  • Example JSON response
{
"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"
}
], 
"id": "0f405555-739f-4a19-abb7-ec11d005b3a9", 
"security_groups": [
"043548bc-1020-4be0-885a-caac8530e8f6"
], 
"device_id": "", 
"name": "port_vm_50_3", 
"admin_state_up": true, 
"network_id": "9898a82d-7795-4ad5-bf2c-0ed8b822be4f", 
"tenant_id": "3e4a1816927f405cacbc3dca1e05111e", 
"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"
}
], 
"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", 
"binding:vnic_type": "normal", 
"mac_address": "fa:16:3e:f1:0b:09"
}
]
}

Error Code

See section Return Code Processing.