Server groups let you express affinity or anti-affinity placement rules for Nova servers.
.. osdoc:: https://docs.openstack.org/api-ref/compute/#server-groups-os-server-groups
.. sample:: Compute/v2/server_groups/list.php
Each iteration will return a :php:class:`ServerGroup` instance <OpenStack/Compute/v2/Models/ServerGroup.html>.
Admin-only listing across all projects is also available:
$serverGroups = $service->listServerGroups([
'allProjects' => true,
]);Use name and policies for the baseline Compute API:
.. sample:: Compute/v2/server_groups/create.php
If the Compute service is created with microversion 2.64 or later, you can use the singular policy field and
optional rules object instead:
$compute = $openstack->computeV2([
'microVersion' => '2.64',
]);
$serverGroup = $compute->createServerGroup([
'name' => 'db-group',
'policy' => 'anti-affinity',
'rules' => [
'max_server_per_host' => 1,
],
]);When Nova responds with the newer singular policy field, the SDK also exposes that value as the first item in
policies for compatibility with the older response shape.
.. sample:: Compute/v2/server_groups/read.php
.. sample:: Compute/v2/server_groups/delete.php