Chuyển tới nội dung chính

Liệt kê interface của virtual router

GET/v2.0/ports

Liệt kê các port mà user có quyền truy cập.

Dùng lệnh gọi này để tìm port ID của virtual router theo ID được chỉ định. Lọc với device_id={router_id}. Bạn cũng có thể lọc theo device_owner=network:router_interface cho interface nội bộ hoặc device_owner=network:router_gateway cho interface external gateway.

Theo policy mặc định, chỉ các port thuộc project của user gửi request được trả về, trừ khi request được gửi bởi user có quyền admin.

Nếu extension ip-substring-filtering được bật, API Networking hỗ trợ lọc chuỗi con địa chỉ IP trên thuộc tính fixed_ips. Nếu bạn chỉ định chuỗi con địa chỉ IP (ip_address_substr) trong một phần tử của thuộc tính fixed_ips, API sẽ liệt kê tất cả port có địa chỉ IP khớp chuỗi con đó.

info

Nguồn: list-ports

Request​

Tham số​

admin_state_upboolean

Lọc theo trạng thái quản trị: up (true) hoặc down (false).

bindingstring

Lọc theo ID của host nơi port đang nằm.

descriptionstring

Lọc theo mô tả dễ đọc của port.

device_idstring

Lọc theo ID của thiết bị sử dụng port này (ví dụ một server instance hoặc ID logical router).

device_ownerstring

Lọc theo loại thực thể sử dụng port này (ví dụ compute:nova, network:dhcp, network:router_interface).

fixed_ipsarray

Lọc theo địa chỉ IP của port. Mỗi phần tử có thể gồm ip_address, ip_address_substr và/hoặc subnet_id.

idstring

Lọc theo ID của port.

ip_allocationstring

Lọc port theo cách cấp IP: deferred, immediate hoặc không cấp IP (none).

mac_addressstring

Lọc theo địa chỉ MAC của port.

namestring

Lọc theo tên dễ đọc của port.

network_idstring

Lọc theo ID của mạng được gắn.

project_idstring

Lọc theo ID của project sở hữu tài nguyên.

revision_numberinteger

Lọc theo revision number của tài nguyên.

sort_dirstring

Hướng sắp xếp, asc hoặc desc. Cho phép nhiều cặp sort_key/sort_dir.

sort_keystring

Sắp xếp theo một thuộc tính của port. Các key hợp lệ: admin_state_up, device_id, device_owner, id, ip_allocation, mac_address, name, network_id, project_id, status, tenant_id.

statusstring

Lọc theo trạng thái port: ACTIVE, DOWN, BUILD, ERROR.

tenant_idstring

Lọc theo ID của project sở hữu tài nguyên.

tagsstring

Trả về tài nguyên khớp tất cả tag được chỉ định (phân tách bằng dấu phẩy).

tags-anystring

Trả về tài nguyên khớp bất kỳ tag nào được chỉ định (phân tách bằng dấu phẩy).

not-tagsstring

Loại trừ tài nguyên khớp tất cả tag được chỉ định (phân tách bằng dấu phẩy).

not-tags-anystring

Loại trừ tài nguyên khớp bất kỳ tag nào được chỉ định (phân tách bằng dấu phẩy).

fieldsstring

Giới hạn các field trả về. Có thể chỉ định nhiều lần, ví dụ fields=id&fields=name.

mac_learning_enabledboolean

Lọc theo trạng thái MAC learning: bật (true) hoặc tắt (false).

Request mẫu​

Dùng curl​

curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
https://api.vietnix.cloud:9696/v2.0/ports?device_id=66fa6a3b-4b3a-485f-819d-c671765eb915

HTTP request​

GET https://api.vietnix.cloud:9696/v2.0/ports?device_id={router_id}
X-Auth-Token: gAAAAA<...>

Response​

Tham số response​

portsarraybắt buộc

Danh sách object port.

admin_state_upbooleanbắt buộc

Trạng thái quản trị: up (true) hoặc down (false).

allowed_address_pairsarraybắt buộc

Không hoặc nhiều object allowed address pair (ip_address, mac_address).

bindingstringbắt buộc

ID của host nơi port đang nằm.

bindingobjectbắt buộc

Thông tin binding VIF riêng cho host/driver.

bindingobjectbắt buộc

Thông tin bổ sung về port (ví dụ port_filter, ovs_hybrid_plug).

bindingstringbắt buộc

Cơ chế được dùng cho port (ví dụ ovs, bridge, vhostuser). Bao gồm các giá trị đặc biệt: unbound, binding_failed.

bindingstringbắt buộc

Loại vNIC mà port nên gắn vào (normal, direct, v.v.).

created_atstringbắt buộc

Timestamp tạo theo ISO 8601.

data_plane_statusstringbắt buộc

Trạng thái data plane bên dưới của port.

descriptionstringbắt buộc

Mô tả dễ đọc cho port.

device_idstringbắt buộc

ID của thiết bị sử dụng port (ví dụ server instance hoặc ID logical router).

device_ownerstringbắt buộc

Loại thực thể sử dụng port (ví dụ network:router_interface).

dns_assignmentobjectbắt buộc

Thông tin gán DNS nội bộ của Networking cho port.

dns_domainstringbắt buộc

DNS domain.

dns_namestringbắt buộc

Tên DNS.

extra_dhcp_optsarraybắt buộc

Các cặp tuỳ chọn DHCP bổ sung.

fixed_ipsarraybắt buộc

Một hoặc nhiều fixed IP (ip_address, subnet_id).

idstringbắt buộc

ID của port.

ip_allocationstringbắt buộc

Thời điểm cấp IP: deferred, immediate hoặc none.

mac_addressstringbắt buộc

Địa chỉ MAC của port.

namestringbắt buộc

Tên port.

network_idstringbắt buộc

ID mạng được gắn.

port_security_enabledbooleanbắt buộc

Port security có được bật hay không.

project_idstringbắt buộc

ID project.

qos_network_policy_idstringbắt buộc

ID policy QoS của mạng nơi port được gắn.

qos_policy_idstringbắt buộc

ID policy QoS liên kết với port.

revision_numberintegerbắt buộc

Revision number.

resource_requestobject

Tài nguyên và trait của Placement mà port yêu cầu.

security_groupsarraybắt buộc

ID các security group áp dụng cho port.

statusstringbắt buộc

Trạng thái port (ACTIVE, DOWN, BUILD, ERROR).

tenant_idstringbắt buộc

ID project.

tagsarraybắt buộc

Danh sách tag trên tài nguyên.

updated_atstringbắt buộc

Timestamp cập nhật theo ISO 8601 hoặc null.

propagate_uplink_statusbooleanbắt buộc

Truyền trạng thái uplink (true/false).

mac_learning_enabledboolean

MAC Learning có được bật trên port hay không.

Response mẫu​

Response body
{
"ports": [
{
"id": "a60d084b-5bac-489c-b549-7e651b577e36",
"name": "",
"network_id": "36a3666a-8ed4-48bf-9528-15f573c4a4f0",
"tenant_id": "f33507157a634f1cac71e06a70fb558e",
"mac_address": "fa:16:3e:8a:27:15",
"admin_state_up": true,
"status": "ACTIVE",
"device_id": "66fa6a3b-4b3a-485f-819d-c671765eb915",
"device_owner": "network:router_interface_distributed",
"fixed_ips": [
{
"subnet_id": "b367fdf4-d111-4c4c-b8c2-ea5d484ac0fb",
"ip_address": "192.168.10.1"
}
],
"allowed_address_pairs": [],
"extra_dhcp_opts": [],
"security_groups": [],
"description": "",
"binding:vnic_type": "normal",
"port_security_enabled": false,
"qos_policy_id": null,
"qos_network_policy_id": "dfc42ced-02c8-4b1f-bbe6-14cc014f259d",
"tags": [],
"created_at": "2025-09-23T16:01:32Z",
"updated_at": "2025-09-24T05:07:52Z",
"revision_number": 18,
"project_id": "f33507157a634f1cac71e06a70fb558e"
},
{
"id": "f43d2167-fcaf-4ac7-b8ab-8d96ef896f59",
"name": "",
"network_id": "36a3666a-8ed4-48bf-9528-15f573c4a4f0",
"tenant_id": "",
"mac_address": "fa:16:3e:c9:34:38",
"admin_state_up": true,
"status": "ACTIVE",
"device_id": "66fa6a3b-4b3a-485f-819d-c671765eb915",
"device_owner": "network:router_centralized_snat",
"fixed_ips": [
{
"subnet_id": "b367fdf4-d111-4c4c-b8c2-ea5d484ac0fb",
"ip_address": "192.168.10.242"
}
],
"allowed_address_pairs": [],
"extra_dhcp_opts": [],
"security_groups": [],
"description": "",
"binding:vnic_type": "normal",
"port_security_enabled": false,
"qos_policy_id": null,
"qos_network_policy_id": "dfc42ced-02c8-4b1f-bbe6-14cc014f259d",
"tags": [],
"created_at": "2025-09-23T16:01:32Z",
"updated_at": "2025-09-24T05:07:50Z",
"revision_number": 12,
"project_id": ""
}
]
}

Mã trạng thái​

Thành công​

MãMô tả
200 - OKRequest thành công.

Lỗi​

MãMô tả
401 - UnauthorizedCần xác thực trước khi gửi request.