openstack.placement.v1.allocation

The Allocation Class

The Allocation class inherits from Resource.

class openstack.placement.v1.allocation.Allocation(_synchronized=False, connection=None, **attrs)

Allocations for a single consumer.

Allocations are records representing resources that have been assigned and used by a consumer of those resources. The consumer is identified by its UUID, which serves as the resource ID in the URL (/allocations/{consumer_uuid}).

An allocation maps resource providers to the resources consumed from them. Each entry in the allocations dict is keyed by resource provider UUID and contains a resources sub-dict mapping resource class names to quantities.

The base resource

Parameters:
  • _synchronized – This is not intended to be used directly. See new() and existing().

  • connection – Reference to the Connection being used. Defaults to None to allow Resource objects to be used without an active Connection, such as in unit tests. Use of self._connection in Resource code should protect itself with a check for None.

resource_key = None

Singular form of key for resource.

resources_key = None

Plural form of key for resource.

base_path = '/allocations'

The base part of the URI for this resource.

allow_fetch = True

Allow get operation for this resource.

allow_commit = True

Allow update operation for this resource.

allow_delete = True

Allow delete operation for this resource.

allocations

A dictionary of resource allocations keyed by resource provider UUID. Each value is a dict with a resources key mapping resource class names to quantities, e.g. {"DISK_GB": 4, "VCPU": 2}. Setting this to an empty dict removes all allocations for the consumer.

consumer_generation

The generation of the consumer. Should be set to None when indicating that the caller expects the consumer does not yet exist.

consumer_type

A string that consists of numbers, A-Z, and _ describing what kind of consumer is creating, or has created, allocations using a quantity of inventory. The string is determined by the client when writing allocations and it is up to the client to ensure correct choices amongst collaborating services. For example, the compute service may choose to type some consumers ‘INSTANCE’ and others ‘MIGRATION’.

project_id

The UUID of a project.

user_id

The UUID of a user.

classmethod set(session, allocations)

Set allocations for multiple consumers in a single atomic request.

Parameters:
  • session – The session to use for making this request.

  • allocations – A dict keyed by consumer UUID; see set_allocations() for the expected structure of each value.

Raises:

ConflictException if any resource provider or consumer generation does not match, or if there is insufficient inventory.