Placement API¶
The Placement Class¶
The placement high-level interface is available through the placement
member of a Connection object.
The placement member will only be added if the service is detected.
Allocation Candidates¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- allocation_candidates(**query)
Retrieve a generator of allocation candidates.
Each yielded
AllocationCandidaterepresents one candidate set of allocations and contains:allocations— a dict mapping resource provider UUID to the resources to request from that provider.mappings— a dict mapping request-group suffixes to provider UUIDs (available from microversion 1.34).provider_summaries— a dict keyed by resource provider UUID with capacity and trait information for providers in this candidate.
- Parameters:
query –
Query parameters forwarded directly to placement. Common parameters include:
resources— a comma-separatedCLASS:AMOUNTstring, e.g.VCPU:1,DISK_GB:10,MEMORY_MB:512required— comma-separated required (or!-prefixed forbidden) traitsmember_of— aggregate UUID filterin_tree— restrict to a resource provider subtreelimit— maximum number of candidates to returngroup_policy—isolateornoneroot_required— traits required on the root providersame_subtree— request-group suffixes that must share a tree
Numbered variants (
resources1,required1,member_of1,in_tree1, …) are accepted for granular request groups.- Returns:
A generator of
AllocationCandidateinstances.
Allocations¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- get_allocation(consumer)
Get allocations for a consumer.
- Parameters:
consumer – The UUID of the consumer, or an
Allocationinstance.- Returns:
An instance of
Allocationwith all allocations for the given consumer.- Raises:
NotFoundExceptionwhen no allocations for the consumer could be found.
- update_allocation(consumer, **attrs)
Set or update allocations for a consumer.
Creates or replaces all allocation records for the consumer identified by
consumer. If allocations already exist for this consumer they are replaced.- Parameters:
consumer – The UUID of the consumer, or an
Allocationinstance.attrs – Keyword arguments which will be used to update the
Allocation, comprised of the properties on the Allocation class. At a minimum,allocations,project_id, anduser_idmust be provided when creating new allocations.
- Returns:
The updated
Allocation.
- create_allocations(allocations)
Create or update allocations for multiple consumers.
- Parameters:
allocations – A dict keyed by consumer UUID. Each value must contain
allocations,project_id,user_id, andconsumer_generation; from microversion 1.38consumer_typeis also required. Pass an emptyallocationsvalue for a consumer to remove all of their allocations.- Returns:
None- Raises:
ConflictExceptionif any resource provider or consumer generation does not match, or if there is insufficient inventory.
- delete_allocation(consumer, ignore_missing=True)
Delete all allocations for a consumer.
- Parameters:
consumer – The UUID of the consumer, or an
Allocationinstance.ignore_missing – When set to
FalseNotFoundExceptionwill be raised when no allocations exist for the consumer. When set toTrue, no exception will be raised when attempting to delete allocations for a consumer that has none.
- Returns:
None
Usages¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- usages(project_id, user_id=None, consumer_type=None)
Retrieve a generator of resource usages for a project.
Each yielded
Usagerepresents one consumer type and contains the total resource consumption by consumers of that type within the given project.- Parameters:
project_id – The UUID of the project to report usage for.
user_id – The UUID of the user to further filter by. Optional.
consumer_type – The consumer type to filter by. Optional; requires placement microversion 1.38 or later.
- Returns:
A generator of
Usageinstances.
Resource Classes¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- create_resource_class(**attrs)
Create a new resource class from attributes.
- Parameters:
attrs – Keyword arguments which will be used to create a
ResourceClass, comprised of the properties on the ResourceClass class.- Returns:
The results of resource class creation
- delete_resource_class(resource_class, ignore_missing=True)
Delete a resource class
- Parameters:
resource_class – The value can be either the ID of a resource class or an
ResourceClass, instance.ignore_missing – When set to
FalseNotFoundExceptionwill be raised when the resource class does not exist. When set toTrue, no exception will be set when attempting to delete a nonexistent resource class.
- Returns:
None
- update_resource_class(resource_class, **attrs)
Update a resource class
- Parameters:
resource_class – The value can be either the ID of a resource class or an
ResourceClass, instance.attrs – The attributes to update on the resource class represented by
resource_class.
- Returns:
The updated resource class
- get_resource_class(resource_class)
Get a single resource_class.
- Parameters:
resource_class – The value can be either the ID of a resource class or an
ResourceClass, instance.- Returns:
An instance of
ResourceClass- Raises:
NotFoundExceptionwhen no resource class matching the criteria could be found.
- resource_classes(**query)
Retrieve a generator of resource classs.
- Parameters:
query – Optional query parameters to be sent to restrict the resource classs to be returned.
- Returns:
A generator of resource class instances.
Resource Providers¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- create_resource_provider(**attrs)
Create a new resource provider from attributes.
- Parameters:
attrs – Keyword arguments which will be used to create a
ResourceProvider, comprised of the properties on the ResourceProvider class.- Returns:
The results of resource provider creation
- delete_resource_provider(resource_provider, ignore_missing=True)
Delete a resource provider
- Parameters:
resource_provider – The value can be either the ID of a resource provider or an
ResourceProvider, instance.ignore_missing – When set to
FalseNotFoundExceptionwill be raised when the resource provider does not exist. When set toTrue, no exception will be set when attempting to delete a nonexistent resource provider.
- Returns:
None
- update_resource_provider(resource_provider, **attrs)
Update a resource provider
- Parameters:
resource_provider – The value can be either the ID of a resource provider or an
ResourceProvider, instance.attrs – The attributes to update on the resource provider represented by
resource_provider.
- Returns:
The updated resource provider
- get_resource_provider(resource_provider)
Get a single resource_provider.
- Parameters:
resource_provider – The value can be either the ID of a resource provider or an
ResourceProvider, instance.- Returns:
An instance of
ResourceProvider- Raises:
NotFoundExceptionwhen no resource provider matching the criteria could be found.
- find_resource_provider(name_or_id, ignore_missing=True)
Find a single resource_provider.
- Parameters:
name_or_id – The name or ID of a resource provider.
ignore_missing – When set to
FalseNotFoundExceptionwill be raised when the resource does not exist. When set toTrue, None will be returned when attempting to find a nonexistent resource.
- Returns:
An instance of
ResourceProvider- Raises:
NotFoundExceptionwhen no resource provider matching the criteria could be found.
- resource_providers(**query)
Retrieve a generator of resource providers.
- Parameters:
query – Optional query parameters to be sent to restrict the resource providers to be returned.
- Returns:
A generator of resource provider instances.
- get_resource_provider_aggregates(resource_provider)
Get a list of aggregates for a resource provider.
Deprecated since version 4.14.0: Use
fetch_resource_provider_aggregates()instead.
- set_resource_provider_aggregates(resource_provider, *aggregates)
Update aggregates for a resource provider.
- Parameters:
resource_provider – The value can be either the ID of a resource provider or an
ResourceProvider, instance.aggregates – A list of aggregates. These aggregates will replace all aggregates currently present.
- Returns:
An instance of
ResourceProviderwith theaggregatesattribute populated with the updated value.- Raises:
NotFoundExceptionwhen no resource provider matching the criteria could be found.
- fetch_resource_provider_usages(resource_provider)
Fetch usages for a specific resource provider.
- Parameters:
resource_provider – The value can be either the ID of a resource provider or a
ResourceProviderinstance.- Returns:
An instance of
ResourceProviderwith theusagesattribute populated.- Raises:
NotFoundExceptionwhen no resource provider matching the criteria could be found.
Resource Provider Allocations¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- resource_provider_allocations(resource_provider, **query)
Retrieve a generator of resource provider allocations
- Parameters:
resource_provider – Either the ID of a resource provider or a
ResourceProviderinstance.query – Optional query parameters to be sent to limit the resources being returned.
- Returns:
A generator of resource provider inventory allocations.
Resource Provider Inventories¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- create_resource_provider_inventory(resource_provider, resource_class, *, total, **attrs)
Create a new resource provider inventory from attributes
- Parameters:
resource_provider – Either the ID of a resource provider or a
ResourceProviderinstance.resource_class – The value can be either the ID of a resource class or an
ResourceClass, instance.total – The actual amount of the resource that the provider can accommodate.
attrs – Keyword arguments which will be used to create a
ResourceProviderInventory, comprised of the properties on the ResourceProviderInventory class.
- Returns:
The results of resource provider inventory creation
- delete_resource_provider_inventory(resource_provider_inventory, resource_provider=None, ignore_missing=True)
Delete a resource provider inventory
- Parameters:
resource_provider_inventory – The value can be either the ID of a resource provider or an
ResourceProviderInventory, instance.resource_provider – Either the ID of a resource provider or a
ResourceProviderinstance. This value must be specified whenresource_provider_inventoryis an ID.ignore_missing – When set to
FalseNotFoundExceptionwill be raised when the resource provider inventory does not exist. When set toTrue, no exception will be set when attempting to delete a nonexistent resource provider inventory.
- Returns:
None
- update_resource_provider_inventory(resource_provider_inventory, resource_provider=None, *, resource_provider_generation=None, **attrs)
Update a resource provider’s inventory
- Parameters:
resource_provider_inventory – The value can be either the ID of a resource provider inventory or an
ResourceProviderInventory, instance.resource_provider – Either the ID of a resource provider or a
ResourceProviderinstance. This value must be specified whenresource_provider_inventoryis an ID.
- Attrs kwargs:
The attributes to update on the resource provider inventory represented by
resource_provider_inventory.- Returns:
The updated resource provider inventory
- get_resource_provider_inventory(resource_provider_inventory, resource_provider=None)
Get a single resource_provider_inventory
- Parameters:
resource_provider_inventory – The value can be either the ID of a resource provider inventory or an
ResourceProviderInventory, instance.resource_provider – Either the ID of a resource provider or a
ResourceProviderinstance. This value must be specified whenresource_provider_inventoryis an ID.
- Returns:
An instance of
ResourceProviderInventory- Raises:
NotFoundExceptionwhen no resource provider inventory matching the criteria could be found.
- resource_provider_inventories(resource_provider, **query)
Retrieve a generator of resource provider inventories
- Parameters:
resource_provider – Either the ID of a resource provider or a
ResourceProviderinstance.query – Optional query parameters to be sent to limit the resources being returned.
- Returns:
A generator of resource provider inventory instances.
- set_resource_provider_inventories(resource_provider, inventories, resource_provider_generation)
Replace all inventories for a resource provider in a single request.
- Parameters:
resource_provider – The value can be either the ID of a resource provider or a
ResourceProviderinstance.inventories – A dict mapping resource class names to inventory configuration dicts (keys:
total, and optionallyallocation_ratio,max_unit,min_unit,reserved,step_size). Pass an empty dict to remove all inventories.resource_provider_generation – The current generation of the resource provider, used to detect concurrent updates.
- Returns:
The resource provider with its
generationupdated to reflect the new state.- Raises:
ConflictExceptionif the generation does not match or allocations prevent removal.
- delete_resource_provider_inventories(resource_provider)
Delete all inventory records for a resource provider.
- Parameters:
resource_provider – The value can be either the ID of a resource provider or a
ResourceProviderinstance.- Returns:
None- Raises:
ConflictExceptionif there are active allocations against the resource provider.
Traits¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- create_trait(name)
Create a new trait
- Parameters:
name – The name of the new trait
- Returns:
The results of trait creation
- delete_trait(trait, ignore_missing=True)
Delete a trait
- Parameters:
trait – The value can be either the ID of a trait or an
Trait, instance.ignore_missing – When set to
FalseNotFoundExceptionwill be raised when the resource provider inventory does not exist. When set toTrue, no exception will be set when attempting to delete a nonexistent resource provider inventory.
- Returns:
None
- get_trait(trait)
Get a single trait
- Parameters:
trait – The value can be either the ID of a trait or an
Trait, instance.- Returns:
An instance of
ResourceProviderInventory- Raises:
NotFoundExceptionwhen no trait matching the criteria could be found.
- traits(**query)
Retrieve a generator of traits
- Parameters:
query – Optional query parameters to be sent to limit the resources being returned.
- Returns:
A generator of trait objects
Resource Provider Trait¶
- class openstack.placement.v1._proxy.Proxy(session, *, service_type=None, service_name=None, interface=None, region_name=None, endpoint_override=None, version=None, auth=None, user_agent=None, connect_retries=None, logger=None, allow=None, additional_headers=None, client_name=None, client_version=None, allow_version_hack=None, global_request_id=None, min_version=None, max_version=None, default_microversion=None, status_code_retries=None, retriable_status_codes=None, raise_exc=None, rate_limit=None, concurrency=None, connect_retry_delay=None, status_code_retry_delay=None, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None)
- get_resource_provider_trait(resource_provider)
Get a resource provier’s trait
- Parameters:
resource_provider – The value can be either the ID of a resource provider or an instance of
ResourceProviderTrait.- Returns:
An instance of
ResourceProviderTrait.
- set_resource_provider_trait(resource_provider_trait, **attrs)
Update a resource provider’s trait
- Parameters:
resource_provider_trait – An instance of
ResourceProviderTrait.- Attrs kwargs:
The attributes to update on the resource provider trait represented by
resource_provider_trait.- Returns:
The updated resource provider trait
- delete_resource_provider_trait(resource_provider, ignore_missing=True)
Dissociate all traits from a resource provider.
- Parameters:
resource_provider – The value can be either the ID of a resource provider or a
ResourceProviderinstance.ignore_missing – When set to
FalseNotFoundExceptionwill be raised when the resource provider does not exist. When set toTrue, no exception will be raised when attempting to delete traits for a nonexistent resource provider.
- Returns:
None