更新时间:2024-01-09 GMT+08:00

更新子网

功能介绍

更新子网。

接口约束:

更新allocation_pools字段时范围不能包含网关和广播地址的所有IP。

URI

PUT /v2.0/subnets/{subnet_id}

请求参数

表1 请求参数

参数名称

类型

必选

说明

subnet

subnet object

subnet对象,参见表2

更新操作时至少指定一项属性

表2 subnet对象

属性

是否必选

类型

说明

name

String

子网的名称

allocation_pools

Array of allocation_pool objects

可用的IP池,allocation_pool对象参见表3

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

每个子网的第1个和最后3个IP地址为系统保留地址。以192.168.1.0/24为例,192.168.1.0、 192.168.1.253、192.168.1.254和192.168.1.255这些地址是系统保留地址。系统预留地址默认不在allocation_pool范围内。

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

ipv6子网以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这些地址是系统保留地址。

约束:更新时allocation_pool范围不能包含网关和广播地址的所有IP。

dns_nameservers

Array of strings

dns服务器

【使用说明】

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

最大为5个

host_routes

Array of host_route objects

虚拟机静态路由,参见表4

【使用说明】不支持,忽略输入信息

enable_dhcp

Boolean

是否启动dhcp,false表示不提供dhcp服务的能力

【使用说明】只支持true

表3 allocation_pool对象

参数名

是否必选

参数类型

说明

start

String

网络池起始IP

end

String

网络池结束IP

表4 host_route对象

参数名

是否必选

参数类型

说明

destination

String

路由目的子网

nexthop

String

路由下一跳IP

请求示例

更新id为98bac90c-0ba7-4a63-8995-097da9bead1c的子网,名称更新为subnet-test。

PUT https://{Endpoint}/v2.0/subnets/98bac90c-0ba7-4a63-8995-097da9bead1c  
{
  "subnet": {
    "name": "subnet-test"
  }
}

响应参数

表5 响应参数

参数名称

类型

说明

subnet

subnet object

subnet对象,参见表6

表6 subnet对象

属性

类型

说明

id

String

子网的id

【使用说明】在查询子网列表时非必选

name

String

子网的名称

ip_version

Integer

IP版本

【使用说明】支持4(IPv4)、6(IPv6)

ipv6_address_mode

String

IPv6寻址模式

【使用说明】仅支持dhcpv6-stateful

ipv6_ra_mode

String

IPv6路由广播模式

【使用说明】仅支持dhcpv6-stateful

network_id

String

所属网络的id

cidr

String

CIDR格式

【使用说明】IPV4只支持10.0.0.0/8,172.16.0.0/12,192.168.0.0/16三个网段内的地址,掩码长度不能大于28。

IPV6掩码长度不能大于128。

gateway_ip

String

网关IP不允许和allocation_pools地址块冲突。

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

allocation_pools

Array of allocation_pool objects

可用的IP池,allocation_pool对象参见

表7

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

每个子网的第1个和最后3个IP地址为系统保留地址。以192.168.1.0/24为例,192.168.1.0、 192.168.1.253、192.168.1.254和192.168.1.255这些地址是系统保留地址。

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

ipv6子网以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这些地址是系统保留地址。

系统预留地址默认不在allocation_pool范围内。

约束:更新时allocation_pool范围不能包含网关和广播地址的所有IP。

dns_nameservers

Array of strings

dns服务器

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

host_routes

Array of host_route objects

虚拟机静态路由,参见表8

【使用说明】不支持,忽略输入信息

tenant_id

String

项目ID

enable_dhcp

Boolean

是否启动dhcp,false表示不提供dhcp服务的能力

【使用说明】只支持true

project_id

String

项目ID,请参见获取项目ID

created_at

String

资源创建时间,UTC时间

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

updated_at

String

资源更新时间,UTC时间

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

表7 allocation_pool对象

参数名

参数类型

备注

start

String

网络池起始IP

end

String

网络池结束IP

表8 host_route对象

参数名

参数类型

备注

destination

String

路由目的子网

nexthop

String

路由下一跳IP

响应示例

{
    "subnet": {
        "name": "subnet-test",
        "cidr": "172.16.2.0/24",
        "id": "98bac90c-0ba7-4a63-8995-097da9bead1c",
        "enable_dhcp": true,
        "network_id": "0133cd73-34d4-4d4c-bf1f-e65b24603206",
        "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "dns_nameservers": [],
        "allocation_pools": [
            {
                "start": "172.16.2.2",
                "end": "172.16.2.251"
            }
        ],
        "host_routes": [],
        "ip_version": 4,
        "gateway_ip": "172.16.2.1",
        "created_at": "2018-09-20T02:02:16",
        "updated_at": "2018-09-20T02:03:03"
    }
}

状态码

请参见状态码

错误码

请参见错误码