novaclient.base module

novaclient.base module

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

class novaclient.base.BootingManagerWithFind(api)

Bases: novaclient.base.ManagerWithFind

Like a ManagerWithFind, but has the ability to boot servers.

class novaclient.base.BytesWithMeta(values, resp)

Bases: bytes, novaclient.base.RequestIdMixin

class novaclient.base.DictWithMeta(values, resp)

Bases: dict, novaclient.base.RequestIdMixin

class novaclient.base.HookableMixin

Bases: object

Mixin so classes can register and run hooks.

classmethod add_hook(hook_type, hook_func)

Add a new hook of specified type.

Parameters:
  • cls – class that registers hooks
  • hook_type – hook type, e.g., ‘__pre_parse_args__’
  • hook_func – hook function
classmethod run_hooks(hook_type, *args, **kwargs)

Run all hooks of specified type.

Parameters:
  • cls – class that registers hooks
  • hook_type – hook type, e.g., ‘__pre_parse_args__’
  • args – args to be passed to every hook function
  • kwargs – kwargs to be passed to every hook function
class novaclient.base.ListWithMeta(values, resp)

Bases: list, novaclient.base.RequestIdMixin

class novaclient.base.Manager(api)

Bases: novaclient.base.HookableMixin

Manager for API service.

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

alternate_service_type(default, allowed_types=())
api_version
cache_lock = <unlocked _thread.RLock object owner=0 count=0>
client
completion_cache(cache_type, obj_class, mode)

The completion cache for bash autocompletion.

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.

convert_into_with_meta(item, resp)
resource_class = None
write_to_completion_cache(cache_type, val)
class novaclient.base.ManagerWithFind(api)

Bases: novaclient.base.Manager

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

find(**kwargs)

Find a single item with attributes matching **kwargs.

findall(**kwargs)

Find all items with attributes matching **kwargs.

list()
class novaclient.base.RequestIdMixin

Bases: object

Wrapper class to expose x-openstack-request-id to the caller.

append_request_ids(resp)

Add request_ids as an attribute to the object

Parameters:resp – Response object or list of Response objects
request_ids
request_ids_setup()
class novaclient.base.Resource(manager, info, loaded=False, resp=None)

Bases: novaclient.base.RequestIdMixin

Base class for OpenStack resources (tenant, user, etc.).

This is pretty much just a bag for attributes.

Populate and bind to a manager.

Parameters:
  • manager – BaseManager object
  • info – dictionary representing resource attributes
  • loaded – prevent lazy-loading if set to True
  • resp – Response or list of Response objects
HUMAN_ID = False
NAME_ATTR = 'name'
api_version
get()

Support for lazy loading details.

Some clients, such as novaclient have the option to lazy load the details, details which can be loaded with this function.

human_id

Human-readable ID which can be used for bash completion.

is_loaded()
set_info(key, value)
set_loaded(val)
to_dict()
class novaclient.base.StrWithMeta(values, resp)

Bases: str, novaclient.base.RequestIdMixin

class novaclient.base.TupleWithMeta(values, resp)

Bases: tuple, novaclient.base.RequestIdMixin

novaclient.base.getid(obj)

Get object’s ID or object.

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

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.