Scalr\Service\OpenStack\Services\Network\V2\NetworkApi::createSubnet PHP Method

createSubnet() public method

This operation creates a new subnet on the specified network. The network ID, network_id, is required. You must also specify the cidr attribute for the subnet. The remaining attributes are optional. By default, Quantum creates IP v4 subnets. To create an IP v6 subnet, you must specify the value 6 for the ip_version attribute in the request body. Quantum does not try to derive the correct IP version from the provided CIDR. If the parameter for the gateway address, gateway_ip, is not specified, Quantum allocates an address from the cidr for the gateway for the subnet. To specify a subnet without a gateway, specify the value null for the gateway_ip attribute in the request body. If allocation pools attribute, allocation_pools, is not specified, Quantum automatically allocates pools for covering all IP addresses in the CIDR, excluding the address reserved for the subnet gateway. Otherwise, you can explicitly specify allocation pools as shown in the following example. When allocation_pools and gateway_ip are both specified, it is up to the user ensuring the gateway ip does not overlap with the specified allocation pools; otherwise a 409 Conflict error will be returned.
public createSubnet ( Scalr\Service\OpenStack\Services\Network\Type\CreateSubnet $request ) : object
$request Scalr\Service\OpenStack\Services\Network\Type\CreateSubnet Create subnet request object
return object Returns subnet object on success or throws an exception otherwise
    public function createSubnet(CreateSubnet $request)
    {
        $result = null;
        $options = array('subnet' => array_filter(get_object_vars($request), [$this, 'filterNull']));
        $response = $this->getClient()->call($this->service, '/subnets', $options, 'POST');
        if ($response->hasError() === false) {
            $result = json_decode($response->getContent());
            $result = $result->subnet;
        }
        return $result;
    }