# osc_lib package

## Subpackages

- osc_lib.api package
  - Submodules
  - osc_lib.api.api module
    - `BaseAPI`
      - `BaseAPI.HEADER_NAME`
      - `BaseAPI.SERVICE_TYPE`
      - `BaseAPI.create()`
      - `BaseAPI.delete()`
      - `BaseAPI.find()`
      - `BaseAPI.find_attr()`
      - `BaseAPI.find_bulk()`
      - `BaseAPI.find_one()`
      - `BaseAPI.list()`
  - osc_lib.api.auth module
    - `build_auth_plugins_option_parser()`
    - `check_valid_authentication_options()`
    - `check_valid_authorization_options()`
    - `get_keystone2keystone_auth()`
    - `get_options_list()`
    - `get_plugin_list()`
  - osc_lib.api.utils module
    - `simple_filter()`
  - Module contents
- osc_lib.cli package
  - Submodules
  - osc_lib.cli.client_config module
    - `OSC_Config`
      - `OSC_Config.auth_config_hook()`
      - `OSC_Config.load_auth_plugin()`
  - osc_lib.cli.format_columns module
    - `DictColumn`
      - `DictColumn.human_readable()`
      - `DictColumn.machine_readable()`
    - `DictListColumn`
      - `DictListColumn.human_readable()`
      - `DictListColumn.machine_readable()`
    - `ListColumn`
      - `ListColumn.human_readable()`
      - `ListColumn.machine_readable()`
    - `ListDictColumn`
      - `ListDictColumn.human_readable()`
      - `ListDictColumn.machine_readable()`
    - `SizeColumn`
      - `SizeColumn.human_readable()`
  - osc_lib.cli.identity module
    - `add_project_owner_option_to_parser()`
    - `find_project()`
  - osc_lib.cli.pagination module
    - `add_marker_pagination_option_to_parser()`
    - `add_offset_pagination_option_to_parser()`
  - osc_lib.cli.parseractions module
    - `KeyValueAction`
    - `KeyValueAppendAction`
    - `MultiKeyValueAction`
      - `MultiKeyValueAction.validate_keys()`
    - `MultiKeyValueCommaAction`
    - `NonNegativeAction`
    - `RangeAction`
  - Module contents
- osc_lib.command package
  - Submodules
  - osc_lib.command.command module
    - `Command`
      - `Command.app`
      - `Command.deprecated_option_warning()`
      - `Command.log`
      - `Command.run()`
      - `Command.validate_os_beta_command_enabled()`
    - `CommandMeta`
    - `Lister`
      - `Lister.log`
    - `ShowOne`
      - `ShowOne.log`
  - osc_lib.command.commandmanager module
    - `CommandManager`
  - osc_lib.command.timing module
    - `Timing`
      - `Timing.log`
      - `Timing.take_action()`
  - Module contents
- osc_lib.test package
  - Submodules
  - osc_lib.test.base module
    - `ParserException`
    - `TestCase`
      - `TestCase.assertNotCalled()`
      - `TestCase.maxDiff`
      - `TestCase.setUp()`
    - `TestCommand`
      - `TestCommand.assertItemEqual()`
      - `TestCommand.assertListItemEqual()`
      - `TestCommand.check_parser()`
      - `TestCommand.setUp()`
  - osc_lib.test.fakes module
    - `FakeApp`
      - `FakeApp.client_manager`
    - `FakeClientManager`
      - `FakeClientManager.get_configuration()`
    - `FakeLog`
      - `FakeLog.critical()`
      - `FakeLog.debug()`
      - `FakeLog.error()`
      - `FakeLog.info()`
      - `FakeLog.warning()`
    - `FakeModule`
    - `FakeOptions`
    - `FakeResource`
      - `FakeResource.get()`
      - `FakeResource.info`
      - `FakeResource.keys()`
      - `FakeResource.pop()`
      - `FakeResource.to_dict()`
    - `FakeResponse`
    - `FakeStdout`
      - `FakeStdout.make_string()`
      - `FakeStdout.write()`
    - `IOWriterProtocol`
      - `IOWriterProtocol.write()`
    - `LoggerProtocol`
      - `LoggerProtocol.critical()`
      - `LoggerProtocol.debug()`
      - `LoggerProtocol.error()`
      - `LoggerProtocol.info()`
      - `LoggerProtocol.warning()`
  - osc_lib.test.utils module
    - `CompareBySet`
  - Module contents
- osc_lib.utils package
  - Submodules
  - osc_lib.utils.columns module
    - `get_column_definitions()`
    - `get_columns()`
  - osc_lib.utils.tags module
    - `add_tag_filtering_option_to_parser()`
    - `add_tag_option_to_parser_for_create()`
    - `add_tag_option_to_parser_for_set()`
    - `add_tag_option_to_parser_for_unset()`
    - `get_tag_filtering_args()`
    - `update_tags_for_set()`
    - `update_tags_for_unset()`
  - 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()`
    - `is_uuid_like()`
    - `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], 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: CloudRegion) → 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 = True)

  Bases: `App`

  CONSOLE_MESSAGE_FORMAT = '%(levelname)s: %(name)s %(message)s'
  api_version: dict[str, str]
  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.

## osc_lib.version module

## Module contents

this page last updated: 2026-02-24 14:35:42

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.

found an error? report a bug