Scalr\Service\OpenStack\Services\Network\V2\NetworkApi::createPort PHP Метод

createPort() публичный Метод

This operation creates a new Quantum port. The network where the port is created must be specified in the network_id attribute in the request body. You can also specify the following optional attributes: • A symbolic name for the port • MAC address. If an invalid address is specified a 400 Bad Request error will be returned, whereas a 409 Conflict error will be returned if the specified MAC address is already in use. When the MAC address is not specified, Quantum will try to allocate one for the port being created. If there is a failure while generating the address, a 503 Service Unavailable error will be returned. • Administrative state. Set to true for up, and false for down. • Fixed IPs • If you specify just a subnet ID, Quantum allocates an available IP from that subnet to the port. • If you specify both a subnet ID and an IP address, Quantum tries to allocate the specified address to the port. • Host routes for the port, in addition to the host routes defined for the subnets that the port is associated with.
public createPort ( Scalr\Service\OpenStack\Services\Network\Type\CreatePort $request ) : object
$request Scalr\Service\OpenStack\Services\Network\Type\CreatePort Create port request object
Результат object Returns port object on success or throws an exception otherwise
    public function createPort(CreatePort $request)
    {
        $result = null;
        $options = array('port' => array_filter(get_object_vars($request), [$this, 'filterNull']));
        $response = $this->getClient()->call($this->service, '/ports', $options, 'POST');
        if ($response->hasError() === false) {
            $result = json_decode($response->getContent());
            $result = $result->port;
        }
        return $result;
    }