LoadBalancers
Warning
Load balancing functions accessed via the neutron endpoint are deprecated and will be removed in a future release. Users are strongly encouraged to migrate to using the octavia endpoint. This library does not support the octavia endpoint yet. Consider helping us to implement it .
More information can be found in the official documentation.
In order to work with load balancers you have to create the service first.
Create
$networking = $openstack->networkingV2();
$options = [
'name' => 'loadBalancerName',
'description' => 'My LoadBalancer',
'vipSubnetId' => '{subnetId}',
'adminStateUp' => true,
];
// Create the loadbalancer
$lb = $networking->createLoadBalancer($options);
Read
$networking = $openstack->networkingV2();
// Get the loadbalancer
$lb = $networking->getLoadBalancer('{loadbalancerId}');
$lb->retrieve();
Update
$networking = $openstack->networkingV2();
// Get the loadbalancer
$lb = $networking->getLoadBalancer('{loadbalancerId}');
$lb->name = 'newLoadBalancer1';
$lb->description = 'New Description';
$lb->update();
Delete
$networking = $openstack->networkingV2();
// Get the loadbalancer
$lb = $networking->getLoadBalancer('{loadbalancerId}');
$lb->delete();
List
$networking = $openstack->networkingV2();
foreach ($networking->listLoadBalancers() as $lb) {
// Do Stuff
}
Add Listener
$networking = $openstack->networkingV2();
// Get the loadbalancer
$lb = $networking->getLoadBalancer('{loadbalancerId}');
// Options for listener
$options = [
'name' => 'listenerName',
'description' => 'Load Balancer Listener',
'adminStateUp' => true,
'protocol' => 'HTTPS',
'protocolPort' => 443,
'connectionLimit' => 1000
];
$listener = $lb->addListener($options);
Get Stats
$networking = $openstack->networkingV2();
// Get the loadbalancer
$lb = $networking->getLoadBalancer('{loadbalancerId}');
$stats = $lb->getStats();
Get Status Tree
$networking = $openstack->networkingV2();
$lb = $networking->getLoadBalancer('{loadbalancerId}');
$status = $lb->getStatuses();