• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Neutron
  5. Subnet
  6. Creating a Subnet

Creating a Subnet

Function

This interface is used to create a subnet.

URI

POST /v2.0/subnets

Request Message

Table 1 Request parameter

Parameter

Type

Mandatory

Description

subnet

dict

Yes

Specifies the subnet list. For details, see Table 1.

Mandatory fields: network_id and cidr

Response Message

Table 2 Response parameter

Parameter

Type

Description

subnet

dict

Specifies the subnet list. For details, see Table 1.

Example:

Example request
POST /v2.0/subnets 
{
    "subnet": {
           "name": "subnet-test",
           "network_id": "0133cd73-34d4-4d4c-bf1f-e65b24603206",
           "cidr": "172.16.2.0/24",
           "enable_dhcp": true
    }
}

Example response

{
    "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"
    }
}

Status Codes

For details, see section Status Codes.