Flavors

Flavors define the compute, memory, and storage capacity of nova computing instances. To put it simply, a flavor is an available hardware configuration for a server. It defines the size of a virtual server that can be launched.

More information can be found in the official documentation.

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

Read

$compute = $openstack->computeV2();

$flavor = $compute->getFlavor(['id' => '{flavorId}']);
$flavor->retrieve();

List

$compute = $openstack->computeV2();

$flavors = $compute->listFlavors();

foreach ($flavors as $flavor) {
    /** @var \OpenStack\Compute\v2\Models\Flavor $flavor */
}

Each iteration will return a Flavor instance <OpenStack/Compute/v2/Models/Flavor.html>.

By default, PHP generators are used to represent collections of resources in the SDK. The benefit of using generators is that it generally improves performance, since objects are not saved in memory as the iteration cycle goes on; instead, each resource is directly output to the user-defined foreach loop. For all intents and purposes, you interact with generators like any other Traversable object, but to retain collections in memory, you will need to implement your own logic.

Detailed information

By default, only the id, links and name attributes are returned. To return all information for a flavor, you must pass true as the last parameter, like so:

$flavors = $service->listFlavors([], null, true);