osc_lib package¶
Submodules¶
osc_lib.clientmanager module¶
Manage access to the clients, including authenticating when needed.
-
class
osc_lib.clientmanager.ClientCache(factory: Any)¶ Bases:
objectDescriptor class for caching created client handles.
-
class
osc_lib.clientmanager.ClientManager(cli_options: openstack.config.cloud_region.CloudRegion, api_version: Optional[Dict[str, str]], pw_func: Optional[osc_lib.clientmanager._PasswordHelper] = None, app_name: Optional[str] = None, app_version: Optional[str] = None)¶ Bases:
objectManages access to API clients, including authentication.
-
property
auth_ref¶ Dereference will trigger an auth if it hasn’t already
-
get_configuration() → Dict[str, Any]¶
-
get_endpoint_for_service_type(service_type: str, region_name: Optional[str] = None, interface: str = 'public') → Optional[str]¶ Return the endpoint URL for the service type.
-
is_service_available(service_type: str) → Optional[bool]¶ Check if a service type is in the current Service Catalog
-
session: keystoneauth1.session.Session¶
-
setup_auth() → None¶ Set up authentication
This is deferred until authentication is actually attempted because it gets in the way of things that do not require auth.
-
validate_scope() → None¶
-
property
osc_lib.exceptions module¶
Exception definitions.
-
exception
osc_lib.exceptions.AuthorizationFailure¶ Bases:
Exception
-
exception
osc_lib.exceptions.BadRequest(code: Union[int, str], message: Optional[str] = None, details: Optional[str] = None)¶ Bases:
osc_lib.exceptions.ClientExceptionHTTP 400 - Bad request: you sent some malformed data.
-
http_status: int = 400¶
-
message: str = 'Bad request'¶
-
-
exception
osc_lib.exceptions.ClientException(code: Union[int, str], message: Optional[str] = None, details: Optional[str] = None)¶ Bases:
ExceptionThe base exception class for all exceptions this library raises.
-
http_status: int¶
-
message: str¶
-
-
exception
osc_lib.exceptions.CommandError¶ Bases:
Exception
-
exception
osc_lib.exceptions.Conflict(code: Union[int, str], message: Optional[str] = None, details: Optional[str] = None)¶ Bases:
osc_lib.exceptions.ClientExceptionHTTP 409 - Conflict
-
http_status: int = 409¶
-
message: str = 'Conflict'¶
-
-
exception
osc_lib.exceptions.EndpointNotFound¶ Bases:
ExceptionCould not find Service or Region in Service Catalog.
-
exception
osc_lib.exceptions.Forbidden(code: Union[int, str], message: Optional[str] = None, details: Optional[str] = None)¶ Bases:
osc_lib.exceptions.ClientExceptionHTTP 403 - Forbidden: not authorized to access to this resource.
-
http_status: int = 403¶
-
message: str = 'Forbidden'¶
-
-
exception
osc_lib.exceptions.HTTPNotImplemented(code: Union[int, str], message: Optional[str] = None, details: Optional[str] = None)¶ Bases:
osc_lib.exceptions.ClientExceptionHTTP 501 - Not Implemented: server does not support this operation.
-
http_status: int = 501¶
-
message: str = 'Not Implemented'¶
-
-
exception
osc_lib.exceptions.InvalidValue¶ Bases:
ExceptionAn argument value is not valid: wrong type, out of range, etc
-
message= 'Supplied value is not valid'¶
-
-
exception
osc_lib.exceptions.NoTokenLookupException¶ Bases:
ExceptionThis does not support looking up endpoints from an existing token.
-
exception
osc_lib.exceptions.NotFound(code: Union[int, str], message: Optional[str] = None, details: Optional[str] = None)¶ Bases:
osc_lib.exceptions.ClientExceptionHTTP 404 - Not found
-
http_status: int = 404¶
-
message: str = 'Not found'¶
-
-
exception
osc_lib.exceptions.OverLimit(code: Union[int, str], message: Optional[str] = None, details: Optional[str] = None)¶ Bases:
osc_lib.exceptions.ClientExceptionHTTP 413 - Over limit: reached the API limits for this time period.
-
http_status: int = 413¶
-
message: str = 'Over limit'¶
-
-
exception
osc_lib.exceptions.PluginAttributeError¶ Bases:
ExceptionA plugin threw an AttributeError while being lazily loaded.
Bases:
osc_lib.exceptions.ClientExceptionHTTP 401 - Unauthorized: bad credentials.
-
exception
osc_lib.exceptions.UnsupportedVersion¶ Bases:
ExceptionThe user is trying to use an unsupported version of the API
osc_lib.i18n module¶
osc_lib.logs module¶
Application logging
-
class
osc_lib.logs.LogConfigurator(options: argparse.Namespace)¶ Bases:
object-
configure(cloud_config: openstack.config.cloud_config.CloudConfig) → None¶
-
-
osc_lib.logs.get_loggers() → Dict[str, str]¶
-
osc_lib.logs.log_level_from_config(config: Mapping[str, Any]) → int¶
-
osc_lib.logs.log_level_from_options(options: argparse.Namespace) → int¶
-
osc_lib.logs.log_level_from_string(level_string: str) → int¶
-
osc_lib.logs.set_warning_filter(log_level: int) → None¶
osc_lib.shell module¶
Command-line interface to the OpenStack APIs
-
class
osc_lib.shell.OpenStackShell(description: Optional[str] = None, version: Optional[str] = None, command_manager: Optional[cliff.commandmanager.CommandManager] = None, stdin: Optional[TextIO] = None, stdout: Optional[TextIO] = None, stderr: Optional[TextIO] = None, interactive_app_factory: Optional[Type[cliff.interactive.InteractiveApp]] = None, deferred_help: bool = False)¶ Bases:
cliff.app.App-
CONSOLE_MESSAGE_FORMAT= '%(levelname)s: %(name)s %(message)s'¶
-
build_option_parser(description: Optional[str], version: Optional[str], argparse_kwargs: Optional[Dict[str, Any]] = None) → cliff._argparse.ArgumentParser¶ Return an argparse option parser for this application.
Subclasses may override this method to extend the parser with more global options.
- Parameters
description (str) – full description of the application
version (str) – version number for the application
argparse_kwargs – extra keyword argument passed to the ArgumentParser constructor
-
clean_up(cmd: cliff.command.Command, result: int, err: Optional[BaseException]) → None¶ Hook run after a command is done to shutdown the app.
- Parameters
cmd (cliff.command.Command) – command processor being invoked
result (int) – return value of cmd
err (Exception) – exception or None
-
client_manager: osc_lib.clientmanager.ClientManager¶
-
close_profile() → None¶
-
configure_logging() → None¶ Configure logging for the app.
-
init_profile() → None¶
-
initialize_app(argv: List[str]) → None¶ Global app init bits:
set up API versions
validate authentication info
authenticate against Identity if requested
-
interact() → None¶
-
log= <Logger osc_lib.shell (WARNING)>¶
-
prepare_to_run_command(cmd: cliff.command.Command) → None¶ Set up auth and API versions
-
run(argv: List[str]) → int¶ Equivalent to the main program for the application.
- Parameters
argv (list of str) – input arguments and options
-
run_subcommand(argv: List[str]) → int¶
-
timing_data: List[Any] = []¶
-
-
osc_lib.shell.main(argv: Optional[List[str]] = None) → int¶
-
osc_lib.shell.prompt_for_password(prompt: Optional[str] = None) → str¶ Prompt user for a password
Prompt for a password if stdin is a tty.