Networks

Network represents an isolated Layer-2 networking segment within the cloud. It can be shared across tenants, or isolated to a single tenant.

More information can be found in the official documentation.

In order to work with networks you have to create the service first.

Create

$service = $openstack->networkingV2();
$network = $service->createNetwork([
    'name'         => '{networkName}',
    'adminStateUp' => true,
]);

Batch

To create multiple networks in a single request, use the following code:

$service = $openstack->networkingV2();
$networks = $service->createNetworks([
    [
        'name' => '{networkName1}',
    ],
    [
        'name' => '{networkName2}',
    ],
]);

Read

$service = $openstack->networkingV2();
$network = $service->getNetwork('{networkId}');

$network->retrieve();

Update

$service = $openstack->networkingV2();
$network = $service->getNetwork('{networkId}');

$network->name = '{newName}';
$network->update();

Delete

$service = $openstack->networkingV2();
$network = $service->getNetwork('{networkId}');

$network->delete();