创建子网
功能介绍
创建子网。
URI
POST /v2.0/subnets
请求参数
| 
        属性  | 
      
        是否必选  | 
      
        类型  | 
      
        说明  | 
     
|---|---|---|---|
| 
        name  | 
      
        否  | 
      
        String  | 
      
        子网的名称  | 
     
| 
        ip_version  | 
      
        否  | 
      
        Integer  | 
      
        IP版本 【使用说明】支持4(IPv4)、6(IPv6)  | 
     
| 
        network_id  | 
      
        是  | 
      
        String  | 
      
        所属网络的id  | 
     
| 
        cidr  | 
      
        是  | 
      
        String  | 
      
        CIDR格式 【使用说明】IPV4只支持10.0.0.0/8,172.16.0.0/12,192.168.0.0/16三个网段内的地址,掩码长度不能大于28。  | 
     
| 
        gateway_ip  | 
      
        否  | 
      
        String  | 
      
        网关IP不允许和allocation_pools地址块冲突。 【使用说明】不支持修改。  | 
     
| 
        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范围内。 约束:更新时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  | 
     
请求示例
创建IPv4子网,所在network为0133cd73-34d4-4d4c-bf1f-e65b24603206,指定cidr为172.16.2.0/24,命名为subnet-test。
POST https://{Endpoint}/v2.0/subnets 
{
    "subnet": {
           "name": "subnet-test",
           "network_id": "0133cd73-34d4-4d4c-bf1f-e65b24603206",
           "cidr": "172.16.2.0/24",
           "enable_dhcp": true
    }
}
 响应参数
| 
        属性  | 
      
        类型  | 
      
        说明  | 
     
|---|---|---|
| 
        id  | 
      
        String  | 
      
        子网的id 【使用说明】在查询子网列表时非必选  | 
     
| 
        name  | 
      
        String  | 
      
        子网的名称  | 
     
| 
        ip_version  | 
      
        Integer  | 
      
        IP版本 【使用说明】支持4(IPv4)、6(IPv6)  | 
     
| 
        network_id  | 
      
        String  | 
      
        所属网络的id  | 
     
| 
        cidr  | 
      
        String  | 
      
        CIDR格式 【使用说明】只支持10.0.0.0/8,172.16.0.0/12,192.168.0.0/16三个网段内的地址,掩码长度不能大于28。  | 
     
| 
        gateway_ip  | 
      
        String  | 
      
        网关IP不允许和allocation_pools地址块冲突。 【使用说明】不支持修改。  | 
     
| 
        allocation_pools  | 
      
        Array of allocation_pool objects  | 
      
        可用的IP池,allocation_pool对象参见 例如:[ { "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范围内。 约束:更新时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  | 
     
响应示例
{
    "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:02:16"
    }
}
 状态码
请参见状态码。
错误码
请参见错误码。