novaclient.utils module¶
- novaclient.utils.add_arg(func, *args, **kwargs)¶
Bind CLI arguments to a shell.py do_foo function.
- novaclient.utils.arg(*args, **kwargs)¶
Decorator for CLI args.
Example:
>>> @arg("name", help="Name of the new entity") ... def entity_create(args): ... pass
- novaclient.utils.do_action_on_many(action, resources, success_msg, error_msg)¶
Helper to run an action on many resources.
- novaclient.utils.env(*args, **kwargs)¶
Returns the first environment variable set.
If all are empty, defaults to ‘’ or keyword arg default.
- novaclient.utils.find_resource(manager, name_or_id, wrap_exception=True, **find_args)¶
Helper for the _find_* methods.
- novaclient.utils.flatten_dict(data)¶
Return a new dict whose sub-dicts have been merged into the original. Each of the parents keys are prepended to the child’s to prevent collisions. Any string elements will be JSON parsed before flattening.
>>> flatten_dict({'service': {'host':'cloud9@compute-068', 'id': 143}}) {'service_host': colud9@compute-068', 'service_id': 143}
- novaclient.utils.format_security_groups(groups)¶
- novaclient.utils.format_servers_list_networks(server)¶
- novaclient.utils.get_service_type(f)¶
Retrieves service type from function.
- novaclient.utils.get_url_with_filter(url, filters)¶
- novaclient.utils.is_integer_like(val)¶
Returns validation of a value as an integer.
- novaclient.utils.isunauthenticated(func)¶
Checks if the function does not require authentication.
Mark such functions with the @unauthenticated decorator.
- Returns
bool
- novaclient.utils.make_field_formatter(attr, filters=None)¶
Given an object attribute, return a formatted field name and a formatter suitable for passing to print_list.
Optionally pass a dict mapping attribute names to a function. The function will be passed the value of the attribute and should return the string to display.
- novaclient.utils.prepare_query_string(params)¶
Convert dict params to query string
- novaclient.utils.pretty_choice_dict(d)¶
Returns a formatted dict as ‘key=value’.
- novaclient.utils.pretty_choice_list(l)¶
- novaclient.utils.print_dict(d, dict_property='Property', dict_value='Value', wrap=0)¶
- novaclient.utils.print_list(objs, fields, formatters={}, sortby_index=None)¶
- novaclient.utils.record_time(times, enabled, *args)¶
Record the time of a specific action.
- Parameters
times – A list of tuples holds time data.
enabled – Whether timing is enabled.
args – Other data to be stored besides time data, these args will be joined to a string.
- 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.unauthenticated(func)¶
Adds ‘unauthenticated’ attribute to decorated function.
Usage:
>>> @unauthenticated ... def mymethod(f): ... pass
- novaclient.utils.validate_flavor_metadata_keys(keys)¶