troveclient.compat.base module

Base utilities to build API operation managers and objects on top of.

class troveclient.compat.base.Manager(api)

Bases: HookableMixin

Manager defining CRUD operations for API.

Managers interact with a particular type of API (servers, flavors, images, etc.) and provide CRUD operations for them.

completion_cache(cache_type, obj_class, mode)

Bash-completion cache.

The completion cache store items that can be used for bash autocompletion, like UUIDs or human-friendly IDs.

A resource listing will clear and repopulate the cache.

A resource create will append to the cache.

Delete is not handled because listings are assumed to be performed often enough to keep the cache reasonably up-to-date.

resource_class = None
write_to_completion_cache(cache_type, val)
class troveclient.compat.base.ManagerWithFind(api)

Bases: Manager

Like a Manager, but with additional find()/findall() methods.

find(**kwargs)

Find a single item with attributes matching **kwargs.

This isn’t very efficient: it loads the entire list then filters on the Python side.

findall(**kwargs)

Find all items with attributes matching **kwargs.

This isn’t very efficient: it loads the entire list then filters on the Python side.

list()
class troveclient.compat.base.Resource(manager, info, loaded=False)

Bases: object

A resource represents a particular instance of an object like server.

This is pretty much just a bag for attributes. :param manager: Manager object :param info: dictionary representing resource attributes :param loaded: prevent lazy-loading if set to True

HUMAN_ID = False
get()
property human_id

Provides a pretty ID which can be used for bash completion.

is_loaded()
set_loaded(val)
troveclient.compat.base.getid(obj)

Retrives an id from object or integer.

Abstracts the common pattern of allowing both an object or an object’s ID as a parameter when dealing with relationships.