The novaclient.utils Module

class novaclient.utils.HookableMixin

Bases: object

Mixin so classes can register and run hooks.

classmethod add_hook(hook_type, hook_func)
classmethod run_hooks(hook_type, *args, **kwargs)
novaclient.utils.add_arg(f, *args, **kwargs)

Bind CLI arguments to a shell.py do_foo function.

novaclient.utils.add_resource_manager_extra_kwargs_hook(f, hook)

Adds hook to bind CLI arguments to ResourceManager calls.

The do_foo calls in shell.py will receive CLI args and then in turn pass them through to the ResourceManager. Before passing through the args, the hooks registered here will be called, giving us a chance to add extra kwargs (taken from the command-line) to what’s passed to the ResourceManager.

novaclient.utils.arg(*args, **kwargs)

Decorator for CLI args.

novaclient.utils.bool_from_str(val)

Convert a string representation of a bool into a bool value

novaclient.utils.env(*args, **kwargs)

returns the first environment variable set if none are non-empty, defaults to ‘’ or keyword arg default

novaclient.utils.find_resource(manager, name_or_id)

Helper for the _find_* methods.

novaclient.utils.get_resource_manager_extra_kwargs(f, args, allow_conflicts=False)

Return extra_kwargs by calling resource manager kwargs hooks.

novaclient.utils.get_service_type(f)

Retrieves service type from function

novaclient.utils.import_class(import_str)

Returns a class from a string including module and class.

novaclient.utils.isunauthenticated(f)

Checks to see if the function is marked as not requiring authentication with the @unauthenticated decorator. Returns True if decorator is set to True, False otherwise.

novaclient.utils.pretty_choice_list(l)
novaclient.utils.print_dict(d, dict_property='Property')
novaclient.utils.print_list(objs, fields, formatters={}, sortby_index=0)
novaclient.utils.safe_issubclass(*args)

Like issubclass, but will just return False if not a class.

novaclient.utils.service_type(stype)

Adds ‘service_type’ attribute to decorated function. Usage:

@service_type(‘volume’) def mymethod(f):

...
novaclient.utils.slugify(value)

Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens.

From Django’s “django/template/defaultfilters.py”.

novaclient.utils.unauthenticated(f)

Adds ‘unauthenticated’ attribute to decorated function. Usage:

@unauthenticated def mymethod(f):

...

This Page