osc_lib package¶
Subpackages¶
- osc_lib.api package
- osc_lib.cli package
- osc_lib.command package
- osc_lib.utils package
- Submodules
- osc_lib.utils.columns module
- osc_lib.utils.tags module
- Module contents
backward_compat_col_lister()
backward_compat_col_showone()
build_kwargs_dict()
calculate_header_and_attrs()
env()
find_min_match()
find_resource()
format_dict()
format_dict_of_list()
format_list()
format_list_of_dicts()
format_size()
get_client_class()
get_dict_properties()
get_effective_log_level()
get_field()
get_item_properties()
get_osc_show_columns_for_sdk_resource()
get_password()
is_ascii()
read_blob_file_contents()
sort_items()
wait_for_delete()
wait_for_status()
Submodules¶
osc_lib.clientmanager module¶
Manage access to the clients, including authenticating when needed.
- class osc_lib.clientmanager.ClientCache(factory: Any)¶
Bases:
object
Descriptor class for caching created client handles.
- class osc_lib.clientmanager.ClientManager(cli_options: CloudRegion, api_version: dict[str, str] | None, pw_func: _PasswordHelper | None = None, app_name: str | None = None, app_version: str | None = None)¶
Bases:
object
Manages access to API clients, including authentication.
- property auth_ref: AccessInfo | None¶
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: str | None = None, interface: str = 'public') str | None ¶
Return the endpoint URL for the service type.
- is_service_available(service_type: str) bool | None ¶
Check if a service type is in the current Service Catalog
- 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 ¶
osc_lib.exceptions module¶
Exception definitions.
- exception osc_lib.exceptions.AuthorizationFailure¶
Bases:
Exception
- exception osc_lib.exceptions.BadRequest(code: int | str, message: str | None = None, details: str | None = None)¶
Bases:
ClientException
HTTP 400 - Bad request: you sent some malformed data.
- http_status: int = 400¶
- message: str = 'Bad request'¶
- exception osc_lib.exceptions.ClientException(code: int | str, message: str | None = None, details: str | None = None)¶
Bases:
Exception
The 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: int | str, message: str | None = None, details: str | None = None)¶
Bases:
ClientException
HTTP 409 - Conflict
- http_status: int = 409¶
- message: str = 'Conflict'¶
- exception osc_lib.exceptions.EndpointNotFound¶
Bases:
Exception
Could not find Service or Region in Service Catalog.
- exception osc_lib.exceptions.Forbidden(code: int | str, message: str | None = None, details: str | None = None)¶
Bases:
ClientException
HTTP 403 - Forbidden: not authorized to access to this resource.
- http_status: int = 403¶
- message: str = 'Forbidden'¶
- exception osc_lib.exceptions.HTTPNotImplemented(code: int | str, message: str | None = None, details: str | None = None)¶
Bases:
ClientException
HTTP 501 - Not Implemented: server does not support this operation.
- http_status: int = 501¶
- message: str = 'Not Implemented'¶
- exception osc_lib.exceptions.InvalidValue¶
Bases:
Exception
An argument value is not valid: wrong type, out of range, etc
- message = 'Supplied value is not valid'¶
- exception osc_lib.exceptions.NoTokenLookupException¶
Bases:
Exception
This does not support looking up endpoints from an existing token.
- exception osc_lib.exceptions.NotFound(code: int | str, message: str | None = None, details: str | None = None)¶
Bases:
ClientException
HTTP 404 - Not found
- http_status: int = 404¶
- message: str = 'Not found'¶
- exception osc_lib.exceptions.OverLimit(code: int | str, message: str | None = None, details: str | None = None)¶
Bases:
ClientException
HTTP 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:
Exception
A plugin threw an AttributeError while being lazily loaded.
- exception osc_lib.exceptions.Unauthorized(code: int | str, message: str | None = None, details: str | None = None)¶
Bases:
ClientException
HTTP 401 - Unauthorized: bad credentials.
- http_status: int = 401¶
- message: str = 'Unauthorized'¶
- exception osc_lib.exceptions.UnsupportedVersion¶
Bases:
Exception
The 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: Namespace)¶
Bases:
object
- configure(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: 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: str | None = None, version: str | None = None, command_manager: CommandManager | None = None, stdin: TextIO | None = None, stdout: TextIO | None = None, stderr: TextIO | None = None, interactive_app_factory: type[InteractiveApp] | None = None, deferred_help: bool = False)¶
Bases:
App
- CONSOLE_MESSAGE_FORMAT = '%(levelname)s: %(name)s %(message)s'¶
- build_option_parser(description: str | None, version: str | None, argparse_kwargs: dict[str, Any] | None = None) 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: Command, result: int, err: BaseException | None) 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: 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: 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: list[str] | None = None) int ¶
- osc_lib.shell.prompt_for_password(prompt: str | None = None) str ¶
Prompt user for a password
Prompt for a password if stdin is a tty.