華為云計算 云知識 查詢子網(wǎng)列表NeutronListSubnets
查詢子網(wǎng)列表NeutronListSubnets

 

功能介紹

查詢提交請求的租戶的所有子網(wǎng),單次查詢最多返回2000條數(shù)據(jù),超過2000后會返回分頁標記。分頁查詢請參考分頁查詢。

調(diào)試

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

URI

GET /v2.0/subnets

樣例:

GET https://{Endpoint}/v2.0/subnets?name={subnet_name}&ip_version={ip_version}&
network_id={network_id}&cidr={subnet_cidr_address}&gateway_ip={subnet_gateway}&
tenant_id={tenant_id}&enable_dhcp={is_enable_dhcp}

分頁查詢樣例:

GET https://{Endpoint}/v2.0/subnets?limit=2&marker=011fc878-5521-4654-a1ad-f5b0b5820302&page_reverse=False

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

表1 參數(shù)說明

名稱

是否必選

參數(shù)類型

說明

id

String

按照子網(wǎng)對應的ID過濾查詢

name

String

按照子網(wǎng)的名稱過濾查詢

enable_dhcp

Boolean

按照子網(wǎng)是否開啟dhcp過濾查詢

取值范圍:true or false

cidr

String

按照子網(wǎng)的cidr過濾查詢

network_id

String

按照子網(wǎng)所屬network_id過濾查詢

ip_version

String

按照子網(wǎng)的IP協(xié)議版本過濾查詢

gateway_ip

String

按照子網(wǎng)的網(wǎng)關IP過濾查詢

tenant_id

String

按照子網(wǎng)所屬的項目ID過濾查詢

marker

String

分頁查詢的起始資源ID,表示從指定資源的下一條記錄開始查詢。

marker需要和limit配合使用:

  • 若不傳入marker和limit參數(shù),查詢結果返回第一頁全部資源記錄。
  • 若不傳入marker參數(shù),limit為10,查詢結果返回第1~10條資源記錄。
  • 若marker為第10條記錄的資源ID,limit為10,查詢結果返回第11~20條資源記錄。
  • 若marker為第10條記錄的資源ID,不傳入limit參數(shù),查詢結果返回第11條及之后的所有資源記錄。

limit

Integer

分頁查詢每頁返回的記錄個數(shù),取值范圍為0~intmax(2^31-1),默認值2000。

limit需要和marker配合使用,詳細規(guī)則請見marker的參數(shù)說明。

請求參數(shù)

無。

請求示例

【示例一】

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

【示例二】

GET https://{Endpoint}/v2.0/subnets?id=011fc878-5521-4654-a1ad-f5b0b5820322

響應參數(shù)

表2 響應參數(shù)

參數(shù)名稱

類型

說明

subnets

Array of subnet objects

subnet對象列表,參見表3。

subnets_links

Array of subnets_link objects

分頁信息,參見表6 。

只有在使用limit過濾,并且資源個數(shù)超過limit或者資源個數(shù)超過2000時(limit默認值),該參數(shù)的rel和href取值才會顯示為next和其對應的link。

表3 subnet對象

屬性

類型

說明

id

String

子網(wǎng)的id

【使用說明】在查詢子網(wǎng)列表時非必選

name

String

子網(wǎng)的名稱

ip_version

Integer

IP版本

【使用說明】支持IPv4、IPv6

ipv6_address_mode

String

IPv6尋址模式

【使用說明】僅支持dhcpv6-stateful

ipv6_ra_mode

String

IPv6路由廣播模式

【使用說明】僅支持dhcpv6-stateful

network_id

String

所屬網(wǎng)絡的id

cidr

String

CIDR格式

【使用說明】IPV4只支持10.0.0.0/8,172.16.0.0/12,192.168.0.0/16三個網(wǎng)段內(nèi)的地址,掩碼長度不能大于28。

約束:當ip_version=6時,該字段不支持設置

gateway_ip

String

網(wǎng)關IP不允許和allocation_pools地址塊沖突。

【使用說明】不支持修改。

allocation_pools

Array of allocation_pool objects

可用的IP池,allocation_pool對象參見表3 allocation_pool對象

例如:[ { "start": "10.0.0.2", "end": "10.0.0.251"} ]

每個子網(wǎng)的第1個和最后3個IP地址為系統(tǒng)保留地址。以192.168.1.0/24為例,192.168.1.0、 192.168.1.253、192.168.1.254和192.168.1.255這些地址是系統(tǒng)保留地址。

[{"start": "2001:db8:a583:9::2", "end": "2001:db8:a583:9:ffff:ffff:ffff:fffc"}]

ipv6子網(wǎng)以2001:db8:a583:9::/64為例,2001:db8:a583:9::1和2001:db8:a583:9:ffff:ffff:ffff:fffd、2001:db8:a583:9:ffff:ffff:ffff:fffe、2001:db8:a583:9:ffff:ffff:ffff:ffff這些地址是系統(tǒng)保留地址。

系統(tǒng)預留地址默認不在allocation_pool范圍內(nèi)。

約束:更新時allocation_pool范圍不能包含網(wǎng)關和廣播地址的所有IP。

dns_nameservers

Array of strings

dns服務器

例如:"dns_nameservers": ["8.xx.xx.8","8.xx.xx.4"]

host_routes

Array of host_route objects

虛擬機靜態(tài)路由,參見表5

【使用說明】不支持,忽略輸入信息

tenant_id

String

項目ID

enable_dhcp

Boolean

是否啟動dhcp,false表示不提供dhcp服務的能力

【使用說明】只支持true

subnetpool_id

String

子網(wǎng)池id

【使用說明】目前IPv4不支持,IPv6支持

project_id

String

項目ID,請參見獲取項目ID

created_at

String

資源創(chuàng)建時間,UTC時間

格式:yyyy-MM-ddTHH:mm:ss

updated_at

String

資源更新時間,UTC時間

格式:yyyy-MM-ddTHH:mm:ss

表4 allocation_pool對象

參數(shù)名

參數(shù)類型

備注

start

String

網(wǎng)絡池起始IP

end

String

網(wǎng)絡池結束IP

表5 host_route對象

參數(shù)名

參數(shù)類型

備注

destination

String

路由目的子網(wǎng)

nexthop

String

路由下一跳IP

表6 subnets_link對象

參數(shù)名

參數(shù)類型

備注

href

String

API鏈接

rel

String

API鏈接與該API版本的關系

響應示例

【示例一】

{
    "subnets": [
        {
            "name": "kesmdemeet",
            "cidr": "172.16.236.0/24",
            "id": "011fc878-5521-4654-a1ad-f5b0b5820302",
            "enable_dhcp": true,
            "network_id": "48efad0c-079d-4cc8-ace0-dce35d584124",
            "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
            "project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
            "dns_nameservers": [],
            "allocation_pools": [
                {
                    "start": "172.16.236.2",
                    "end": "172.16.236.251"
                }
            ],
            "host_routes": [],
            "ip_version": 4,
            "gateway_ip": "172.16.236.1",
            "created_at": "2018-03-26T08:23:43",
            "updated_at": "2018-03-26T08:23:44"
        }
    ],
    "subnets_links": [
       {
            "rel": "next", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&marker=011fc878-5521-4654-a1ad-f5b0b5820302"
        }, 
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&marker=011fc878-5521-4654-a1ad-f5b0b5820302&
page_reverse=True" } ] }

【示例二】
{
    "subnets": [
        {
	    "id": "011fc878-5521-4654-a1ad-f5b0b5820322",
	    "name": "elb_alpha_vpc0_subnet0_172_16_0_0_24",
	    "tenant_id": "0c55e5b2b100d5202ff6c01a2fac4580",
	    "network_id": "3053b502-11b2-4599-bcf4-d9d06b6118b2",
            "ip_version": 6,
	    "cidr": "2001:db8:a583:a0::/64",
            "subnetpool_id": "cb03d100-8687-4c0a-9441-ea568dcae47d",
	    "allocation_pools": [{
	        "start": "2001:db8:a583:a0::2",
		"end": "2001:db8:a583:a0:ffff:ffff:ffff:fffc"
	    }],
	    "gateway_ip": "2001:db8:a583:a0::1",
	    "enable_dhcp": true,
	    "ipv6_ra_mode": "dhcpv6-stateful",
	    "ipv6_address_mode": "dhcpv6-stateful",
	    "description": "",
	    "dns_nameservers": [],
	    "host_routes": [],
	    "project_id": "0c55e5b2b100d5202ff6c01a2fac4580",
	    "created_at": "2021-07-01T07:59:28",
	    "updated_at": "2021-07-01T07:59:28"
        }
    ],
    "subnets_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&id=011fc878-5521-4654-a1ad-f5b0b5820322&
marker=011fc878-5521-4654-a1ad-f5b0b5820302&page_reverse=True" } ] }

狀態(tài)碼

請參見狀態(tài)碼

錯誤碼

請參見錯誤碼。