neutron_lib.placement.client module

class neutron_lib.placement.client.NoAuthClient(url)

Bases: object

Placement NoAuthClient for fullstack testing

delete(url, endpoint_filter, **kwargs)
get(url, endpoint_filter, **kwargs)
post(url, json, endpoint_filter, **kwargs)
put(url, json, endpoint_filter, **kwargs)
request(url, method, body=None, headers=None, **kwargs)
class neutron_lib.placement.client.PlacementAPIClient(conf, openstack_api_version='placement 1.37')

Bases: object

Client class for placement ReST API.

associate_aggregates(resource_provider_uuid, aggregates)

Associate a list of aggregates with a resource provider.

Parameters
  • resource_provider_uuid – UUID of the resource provider.

  • aggregates – aggregates to be associated to the resource provider.

Returns

All aggregates associated with the resource provider.

create_resource_class(name)

Create a custom resource class

Parameters

name – the name of the resource class

Returns

None.

create_resource_provider(resource_provider)

Create a resource provider.

Parameters

resource_provider – The resource provider. A dict with the uuid (required), the name (required) and the parent_provider_uuid (optional).

Returns

The resource provider created.

delete_resource_class(name)

Delete a custom resource class.

Parameters

name – The name of the resource class to be deleted.

Raises

PlacementResourceClassNotFound – If the resource class is not found.

Returns

None.

delete_resource_provider(resource_provider_uuid)

Delete a resource provider.

Parameters

resource_provider_uuid – UUID of the resource provider.

delete_resource_provider_inventories(resource_provider_uuid)

Delete all inventory records for the resource provider.

Parameters

resource_provider_uuid – UUID of the resource provider.

Raises

PlacementResourceProviderNotFound – If the resource provider is not found.

Returns

None.

delete_resource_provider_inventory(resource_provider_uuid, resource_class)

Delete inventory of the resource class for a resource provider.

Parameters
  • resource_provider_uuid – UUID of the resource provider.

  • resource_class – The name of the resource class

Raises
Returns

None.

delete_resource_provider_traits(resource_provider_uuid)

Delete resource provider traits.

Parameters

resource_provider_uuid – The UUID of the resource provider for which to delete all the traits.

Raises

PlacementResourceProviderNotFound – If the resource provider is not found.

Returns

None.

delete_trait(name)

Delete the specified trait.

Parameters

name – the name of the trait to be deleted.

Raises

PlacementTraitNotFound – If the trait did not exist.

Returns

None.

ensure_resource_provider(resource_provider)

Ensure a resource provider exists by updating or creating it.

Parameters

resource_provider – The resource provider. A dict with the uuid (required), the name (required) and the parent_provider_uuid (optional).

Returns

The Resource Provider updated or created.

Beware, this is not an atomic operation of the API.

get_inventory(resource_provider_uuid, resource_class)

Get resource provider inventory.

Parameters
  • resource_provider_uuid – UUID of the resource provider.

  • resource_class – Resource class name of the inventory to be returned.

Raises
Returns

The inventory of the resource class as a dict.

get_resource_class(name)

Show resource class.

Parameters

name – The name of the resource class to show

Raises

PlacementResourceClassNotFound – If the resource class is not found.

Returns

The name of resource class and its set of links.

get_resource_provider(resource_provider_uuid)

Get resource provider by UUID.

Parameters

resource_provider_uuid – UUID of the resource provider.

Raises

PlacementResourceProviderNotFound – For failure to find resource

Returns

The Resource Provider matching the UUID.

get_trait(name)

Check if a given trait exists

Parameters

name – name of the trait to check.

Raises

PlacementTraitNotFound – If the trait name not found.

Returns

Evaluates to True if the trait exists.

list_aggregates(resource_provider_uuid)

List resource provider aggregates.

Parameters

resource_provider_uuid – UUID of the resource provider.

Raises

PlacementAggregateNotFound – For failure to the aggregates of a resource provider.

Returns

The list of aggregates together with the resource provider generation.

list_allocations(consumer_uuid)

List allocations for the consumer

Parameters

consumer_uuid – The uuid of the consumer, in case of bound port owned by a VM, the VM uuid.

Returns

All allocation records for the consumer.

list_resource_classes()

List resource classes

list_resource_provider_traits(resource_provider_uuid)

List all traits associated with a resource provider

Parameters

resource_provider_uuid – UUID of the resource provider for which the traits will be listed

Raises

PlacementResourceProviderNotFound – If the resource provider is not found.

Returns

The associated traits of the resource provider together with the resource provider generation.

list_resource_providers(name=None, member_of=None, resources=None, in_tree=None, uuid=None)

Get a list of resource providers.

Parameters
  • name – Name of the resource providers.

  • member_of – List of aggregate UUID to get those resource providers that are associated with. NOTE: placement 1.3 needed.

  • resources – Dictionary of resource classes and requested values.

  • in_tree – UUID of a resource provider that the caller wants to limit the returned providers to those within its ‘provider tree’. The returned list will contain only resource providers with the root_provider_id of the resource provider with UUID == tree_uuid. NOTE: placement 1.14 needed.

  • uuid – UUID of the resource provider.

Raises

PlacementAPIVersionIncorrect – If placement API target version is too low

Returns

A list of Resource Provider matching the filters.

list_traits()

List all traits.

update_allocation(consumer_uuid, allocations)

Update allocation record for given consumer and rp

Parameters
update_qos_allocation(consumer_uuid, alloc_diff)

Update allocation for QoS minimum bandwidth consumer

Parameters
  • consumer_uuid – The uuid of the consumer, in case of bound port owned by a VM, the VM uuid.

  • alloc_diff – A dict which contains RP UUIDs as keys and corresponding fields to update for the allocation under the given resource provider.

update_resource_class(name)

Create or validate the existence of the resource custom class.

Parameters

name – the name of the resource class to be updated or validated

Returns

None.

update_resource_provider(resource_provider)

Update the resource provider identified by uuid.

Parameters

resource_provider – The resource provider. A dict with the uuid (required), the name (required) and the parent_provider_uuid (optional).

Raises
Returns

The updated resource provider.

update_resource_provider_inventories(resource_provider_uuid, inventories, resource_provider_generation=None)

Replaces the set of inventory records for a resource provider.

Parameters
  • resource_provider_uuid – UUID of the resource provider.

  • inventories – The inventories. A dict in the format (see: Placement API ref: https://goo.gl/F22mtk) {resource_class(required): {allocation_ratio(required): total(required): max_unit(required): min_unit(required): reserved(required): step_size(required): }}

  • resource_provider_generation – The generation of the resource provider. Optional.

Raises
Returns

The updated set of inventory records.

update_resource_provider_inventory(resource_provider_uuid, inventory, resource_class, resource_provider_generation=None)

Update resource provider inventory.

Parameters
  • resource_provider_uuid – UUID of the resource provider.

  • inventory – The inventory to be updated for the resource class.

  • resource_class – The name of the resource class.

  • resource_provider_generation – The generation of the resource provider. Optional.

Raises
Returns

The updated inventory of the resource class as a dict.

update_resource_provider_traits(resource_provider_uuid, traits, resource_provider_generation=None)

Replace all associated traits of a resource provider.

Parameters
  • resource_provider_uuid – UUID of the resource provider for which to set the traits

  • traits – a list of traits.

  • resource_provider_generation – The generation of the resource provider. Optional. If not supplied by the caller, handle potential generation conflict by retrying the call. If supplied we assume the caller handles generation conflict.

Raises
Returns

The new traits of the resource provider together with the resource provider generation.

update_trait(name)

Insert a single custom trait.

Parameters

name – name of the trait to create.

Returns

The Response object so you may access response headers.

class neutron_lib.placement.client.UUIDEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: json.encoder.JSONEncoder

default(o)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)