openstackclient.common package¶
Submodules¶
openstackclient.common.clientmanager module¶
Manage access to the clients, including authenticating when needed.
-
class
openstackclient.common.clientmanager.ClientCache(factory)¶ Bases:
objectDescriptor class for caching created client handles.
-
class
openstackclient.common.clientmanager.ClientManager(cli_options=None, api_version=None, verify=True, pw_func=None)¶ Bases:
objectManages access to API clients, including authentication.
-
PLUGIN_INTERFACE_VERSION= '2'¶
-
auth_ref¶ Dereference will trigger an auth if it hasn’t already
-
get_configuration()¶
-
get_endpoint_for_service_type(service_type, region_name=None, interface='public')¶ Return the endpoint URL for the service type.
-
setup_auth()¶ Set up authentication
This is deferred until authentication is actually attempted because it gets in the way of things that do not require auth.
-
-
openstackclient.common.clientmanager.build_plugin_option_parser(parser)¶ Add plugin options to the parser
-
openstackclient.common.clientmanager.get_plugin_modules(group)¶ Find plugin entry points
openstackclient.common.commandmanager module¶
Modify cliff.CommandManager
-
class
openstackclient.common.commandmanager.CommandManager(namespace, convert_underscores=True)¶ Bases:
cliff.commandmanager.CommandManagerAdd additional functionality to cliff.CommandManager
Load additional command groups after initialization Add _command_group() methods
-
add_command_group(group=None)¶ Adds another group of command entrypoints
-
get_command_groups()¶ Returns a list of the loaded command groups
-
get_command_names(group=None)¶ Returns a list of commands loaded for the specified group
-
load_commands(namespace)¶
-
openstackclient.common.configuration module¶
Configuration action implementations
openstackclient.common.context module¶
Application logging
-
class
openstackclient.common.context.LogConfigurator(options)¶ Bases:
object-
configure(cloud_config)¶
-
-
openstackclient.common.context.log_level_from_config(config)¶
-
openstackclient.common.context.log_level_from_options(options)¶
-
openstackclient.common.context.set_warning_filter(log_level)¶
openstackclient.common.exceptions module¶
Exception definitions.
-
exception
openstackclient.common.exceptions.AuthorizationFailure¶ Bases:
exceptions.Exception
-
exception
openstackclient.common.exceptions.BadRequest(code, message=None, details=None)¶ Bases:
openstackclient.common.exceptions.ClientExceptionHTTP 400 - Bad request: you sent some malformed data.
-
http_status= 400¶
-
message= 'Bad request'¶
-
-
exception
openstackclient.common.exceptions.ClientException(code, message=None, details=None)¶ Bases:
exceptions.ExceptionThe base exception class for all exceptions this library raises.
-
exception
openstackclient.common.exceptions.CommandError¶ Bases:
exceptions.Exception
-
exception
openstackclient.common.exceptions.Conflict(code, message=None, details=None)¶ Bases:
openstackclient.common.exceptions.ClientExceptionHTTP 409 - Conflict
-
http_status= 409¶
-
message= 'Conflict'¶
-
-
exception
openstackclient.common.exceptions.EndpointNotFound¶ Bases:
exceptions.ExceptionCould not find Service or Region in Service Catalog.
-
exception
openstackclient.common.exceptions.Forbidden(code, message=None, details=None)¶ Bases:
openstackclient.common.exceptions.ClientExceptionHTTP 403 - Forbidden: not authorized to access to this resource.
-
http_status= 403¶
-
message= 'Forbidden'¶
-
-
exception
openstackclient.common.exceptions.HTTPNotImplemented(code, message=None, details=None)¶ Bases:
openstackclient.common.exceptions.ClientExceptionHTTP 501 - Not Implemented: server does not support this operation.
-
http_status= 501¶
-
message= 'Not Implemented'¶
-
-
exception
openstackclient.common.exceptions.NoTokenLookupException¶ Bases:
exceptions.ExceptionThis does not support looking up endpoints from an existing token.
-
exception
openstackclient.common.exceptions.NotFound(code, message=None, details=None)¶ Bases:
openstackclient.common.exceptions.ClientExceptionHTTP 404 - Not found
-
http_status= 404¶
-
message= 'Not found'¶
-
-
exception
openstackclient.common.exceptions.OverLimit(code, message=None, details=None)¶ Bases:
openstackclient.common.exceptions.ClientExceptionHTTP 413 - Over limit: reached the API limits for this time period.
-
http_status= 413¶
-
message= 'Over limit'¶
-
Bases:
openstackclient.common.exceptions.ClientExceptionHTTP 401 - Unauthorized: bad credentials.
-
exception
openstackclient.common.exceptions.UnsupportedVersion¶ Bases:
exceptions.ExceptionThe user is trying to use an unsupported version of the API
-
openstackclient.common.exceptions.from_response(response, body)¶ Return an instance of a ClientException based on an httplib2 response.
Usage:
resp, body = http.request(...) if resp.status != 200: raise exception_from_response(resp, body)
openstackclient.common.extension module¶
Extension action implementations
openstackclient.common.limits module¶
Limits Action Implementation
openstackclient.common.module module¶
Module action implementation
openstackclient.common.parseractions module¶
argparse Custom Actions
-
class
openstackclient.common.parseractions.KeyValueAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶ Bases:
argparse.ActionA custom action to parse arguments as key=value pairs
Ensures that
destis a dict
-
class
openstackclient.common.parseractions.RangeAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶ Bases:
argparse.ActionA custom action to parse a single value or a range of values
Parses single integer values or a range of integer values delimited by a colon and returns a tuple of integers: ‘4’ sets
destto (4, 4) ‘6:9’ setsdestto (6, 9)
openstackclient.common.quota module¶
Quota action implementations
openstackclient.common.session module¶
Subclass of keystoneclient.session
openstackclient.common.timing module¶
Timing Implementation
openstackclient.common.utils module¶
Common client utilities
-
openstackclient.common.utils.build_kwargs_dict(arg_name, value)¶ Return a dictionary containing arg_name if value is set.
-
openstackclient.common.utils.env(*vars, **kwargs)¶ Search for the first defined of possibly many env vars
Returns the first environment variable defined in vars, or returns the default defined in kwargs.
-
openstackclient.common.utils.find_resource(manager, name_or_id, **kwargs)¶ Helper for the _find_* methods.
Parameters: - manager – A client manager class
- name_or_id – The resource we are trying to find
- kwargs – To be used in calling .find()
Return type: The found resource
This method will attempt to find a resource in a variety of ways. Primarily .get() methods will be called with name_or_id as an integer value, and tried again as a string value.
If both fail, then a .find() is attempted, which is essentially calling a .list() function with a ‘name’ query parameter that is set to name_or_id.
Lastly, if any kwargs are passed in, they will be treated as additional query parameters. This is particularly handy in the case of finding resources in a domain.
-
openstackclient.common.utils.format_dict(data)¶ Return a formatted string of key value pairs
Parameters: - data – a dict
- format – optional formatting hints
Return type: a string formatted to key=’value’
-
openstackclient.common.utils.format_list(data)¶ Return a formatted strings
Parameters: data – a list of strings Return type: a string formatted to a,b,c
-
openstackclient.common.utils.get_client_class(api_name, version, version_map)¶ Returns the client class for the requested API version
Parameters: - api_name – the name of the API, e.g. ‘compute’, ‘image’, etc
- version – the requested API version
- version_map – a dict of client classes keyed by version
Return type: a client class for the requested API version
-
openstackclient.common.utils.get_dict_properties(item, fields, mixed_case_fields=[], formatters={})¶ Return a tuple containing the item properties.
Parameters: - item – a single dict resource
- fields – tuple of strings with the desired field names
- mixed_case_fields – tuple of field names to preserve case
- formatters – dictionary mapping field names to callables to format the values
-
openstackclient.common.utils.get_effective_log_level()¶ Returns the lowest logging level considered by logging handlers
Retrieve an return the smallest log level set among the root logger’s handlers (in case of multiple handlers).
-
openstackclient.common.utils.get_field(item, field)¶
-
openstackclient.common.utils.get_item_properties(item, fields, mixed_case_fields=[], formatters={})¶ Return a tuple containing the item properties.
Parameters: - item – a single item resource (e.g. Server, Project, etc)
- fields – tuple of strings with the desired field names
- mixed_case_fields – tuple of field names to preserve case
- formatters – dictionary mapping field names to callables to format the values
-
openstackclient.common.utils.get_password(stdin, prompt=None, confirm=True)¶
-
openstackclient.common.utils.log_method(log, level=10)¶ Logs a method and its arguments when entered.
-
openstackclient.common.utils.read_blob_file_contents(blob_file)¶
-
openstackclient.common.utils.sort_items(items, sort_str)¶ Sort items based on sort keys and sort directions given by sort_str.
Parameters: - items – a list or generator object of items
- sort_str – a string defining the sort rules, the format is ‘<key1>:[direction1],<key2>:[direction2]...’, direction can be ‘asc’ for ascending or ‘desc’ for descending, if direction is not given, it’s ascending by default
Returns: sorted items
-
openstackclient.common.utils.string_to_bool(arg)¶
-
openstackclient.common.utils.wait_for_delete(manager, res_id, status_field='status', sleep_time=5, timeout=300, callback=None)¶ Wait for resource deletion
Parameters: - res_id – the resource id to watch
- status_field – the status attribute in the returned resource object, this is used to check for error states while the resource is being deleted
- sleep_time – wait this long between checks (seconds)
- timeout – check until this long (seconds)
- callback – called per sleep cycle, useful to display progress; this function is passed a progress value during each iteration of the wait loop
Return type: True on success, False if the resource has gone to error state or the timeout has been reached
-
openstackclient.common.utils.wait_for_status(status_f, res_id, status_field='status', success_status=['active'], sleep_time=5, callback=None)¶ Wait for status change on a resource during a long-running operation
Parameters: - status_f – a status function that takes a single id argument
- res_id – the resource id to watch
- success_status – a list of status strings for successful completion
- status_field – the status attribute in the returned resource object
- sleep_time – wait this long (seconds)
- callback – called per sleep cycle, useful to display progress
Return type: True on success