• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Neutron
  5. Subnets
  6. Create subnet

Create subnet

Function Description

This interface is used to create a subnet.

Interface Format

Method

URI

Description

POST

/v2.0/subnets

Creates a subnet.

Restrictions

N/A

Request Parameter

Parameter

Type

Mandatory

Description

subnet

dict

Yes

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

Mandatory fields: network_id and cidr

Response Parameter

Parameter

Type

Mandatory

Description

subnet

dict

Yes

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

Request Example

POST /v2.0/subnets
{
    "subnet": {
        "name": "testsubnet",
        "enable_dhcp": true,
        "network_id": "60c809cb-6731-45d0-ace8-3bf5626421a9",
        "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
        "dns_nameservers": [
            "8.8.8.8",
            "8.8.8.7"
        ],
        "allocation_pools": [
            {
                "start": "10.0.10.2",
                "end": "10.0.10.254"
            }
        ],
        "host_routes": [],
        "ip_version": 4,
        "gateway_ip": "10.0.10.1",
        "cidr": "10.0.10.0/24"
    }
}

Response Example

{
    "subnet": {
        "name": "testsubnet",
        "enable_dhcp": true,
        "network_id": "60c809cb-6731-45d0-ace8-3bf5626421a9",
        "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
        "dns_nameservers": [
            "8.8.8.7",
            "8.8.8.8"
        ],
        "allocation_pools": [
            {
                "start": "10.0.10.2",
                "end": "10.0.10.254"
            }
        ],
        "host_routes": [],
        "ip_version": 4,
        "gateway_ip": "10.0.10.1",
        "cidr": "10.0.10.0/24",
        "id": "e0fa7de1-a6e2-44c9-b052-b9d8cebe93c4"
    }
}

Error Code

See section Return Code Processing.