osc_lib.cli package¶
Submodules¶
osc_lib.cli.client_config module¶
OpenStackConfig subclass for argument compatibility
-
class
osc_lib.cli.client_config.
OSC_Config
(config_files: Optional[list] = None, vendor_files: Optional[list] = None, override_defaults: Optional[dict] = None, force_ipv4: Optional[bool] = None, envvar_prefix: Optional[str] = None, secure_files: Optional[list] = None, pw_func: Optional[openstack.config.cloud_region._PasswordCallback] = None, session_constructor: Optional[type] = None, app_name: Optional[str] = None, app_version: Optional[str] = None, load_yaml_config: bool = True, load_envvars: bool = True, statsd_host: Optional[str] = None, statsd_port: Optional[str] = None, statsd_prefix: Optional[str] = None, influxdb_config: Optional[dict] = None)¶ Bases:
openstack.config.loader.OpenStackConfig
-
auth_config_hook
(config: Dict[str, Any]) → Dict[str, Any]¶ Allow examination of config values before loading auth plugin
OpenStackClient will override this to perform additional checks on auth_type.
-
load_auth_plugin
(config: Dict[str, Any]) → Any¶ Get auth plugin and validate args
-
osc_lib.cli.format_columns module¶
Formattable column for specify content type
-
class
osc_lib.cli.format_columns.
DictColumn
(value: _T)¶ Bases:
Generic
[cliff.columns._T
]Format column for dict content
-
human_readable
() → str¶ Return a basic human readable version of the data.
-
machine_readable
() → Dict[str, Any]¶ Return a raw data structure using only Python built-in types.
It must be possible to serialize the return value directly using a formatter like JSON, and it will be up to the formatter plugin to decide how to make that transformation.
-
-
class
osc_lib.cli.format_columns.
DictListColumn
(value: _T)¶ Bases:
Generic
[cliff.columns._T
]Format column for dict, key is string, value is list
-
human_readable
() → str¶ Return a basic human readable version of the data.
-
machine_readable
() → Dict[str, List[Any]]¶ Return a raw data structure using only Python built-in types.
It must be possible to serialize the return value directly using a formatter like JSON, and it will be up to the formatter plugin to decide how to make that transformation.
-
-
class
osc_lib.cli.format_columns.
ListColumn
(value: _T)¶ Bases:
Generic
[cliff.columns._T
]Format column for list content
-
human_readable
() → str¶ Return a basic human readable version of the data.
-
machine_readable
() → List[Any]¶ Return a raw data structure using only Python built-in types.
It must be possible to serialize the return value directly using a formatter like JSON, and it will be up to the formatter plugin to decide how to make that transformation.
-
-
class
osc_lib.cli.format_columns.
ListDictColumn
(value: _T)¶ Bases:
Generic
[cliff.columns._T
]Format column for list of dict content
-
human_readable
() → str¶ Return a basic human readable version of the data.
-
machine_readable
() → List[Dict[str, Any]]¶ Return a raw data structure using only Python built-in types.
It must be possible to serialize the return value directly using a formatter like JSON, and it will be up to the formatter plugin to decide how to make that transformation.
-
osc_lib.cli.identity module¶
-
osc_lib.cli.identity.
add_project_owner_option_to_parser
(parser: argparse.ArgumentParser) → None¶ Register project and project domain options.
- Parameters
parser – argparse.Argument parser object.
-
osc_lib.cli.identity.
find_project
(sdk_connection: openstack.connection.Connection, name_or_id: str, domain_name_or_id: Optional[str] = None) → openstack.identity.v3.project.Project¶ Find a project by its name name or ID.
If Forbidden to find the resource (a common case if the user does not have permission), then return the resource by creating a local instance of openstack.identity.v3.Project resource.
- Parameters
sdk_connection (openstack.connection.Connection) – Connection object of OpenStack SDK.
name_or_id (string) – Name or ID of the project
domain_name_or_id – Domain name or ID of the project. This can be used when there are multiple projects with a same name.
- Returns
the project object found
- Return type
openstack.identity.v3.project.Project
osc_lib.cli.pagination module¶
-
osc_lib.cli.pagination.
add_marker_pagination_option_to_parser
(parser: argparse.ArgumentParser) → None¶ Add marker-based pagination options to the parser.
APIs that use marker-based paging use the marker and limit query parameters to paginate through items in a collection.
Marker-based pagination is often used in cases where the length of the total set of items is either changing frequently, or where the total length might not be known upfront.
-
osc_lib.cli.pagination.
add_offset_pagination_option_to_parser
(parser: argparse.ArgumentParser) → None¶ Add offset-based pagination options to the parser.
APIs that use offset-based paging use the offset and limit query parameters to paginate through items in a collection.
Offset-based pagination is often used where the list of items is of a fixed and predetermined length.
osc_lib.cli.parseractions module¶
argparse Custom Actions
-
class
osc_lib.cli.parseractions.
KeyValueAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶ Bases:
argparse.Action
A custom action to parse arguments as key=value pairs
Ensures that
dest
is a dict and values are strings.
-
class
osc_lib.cli.parseractions.
KeyValueAppendAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶ Bases:
argparse.Action
A custom action to parse arguments as key=value pairs
Ensures that
dest
is a dict and values are lists of strings.
-
class
osc_lib.cli.parseractions.
MultiKeyValueAction
(option_strings: Sequence[str], dest: str, nargs: Optional[Union[int, str]] = None, required_keys: Optional[Sequence[str]] = None, optional_keys: Optional[Sequence[str]] = None, const: Optional[_T] = None, default: Optional[Union[_T, str]] = None, type: Optional[Callable[[str], _T]] = None, choices: Optional[Iterable[_T]] = None, required: bool = False, help: Optional[str] = None, metavar: Optional[Union[str, Tuple[str, …]]] = None)¶ Bases:
argparse.Action
A custom action to parse arguments as key1=value1,key2=value2 pairs
Ensure that
dest
is a list. The list will finally contain multiple dicts, with key=value pairs in them.NOTE: The arguments string should be a comma separated key-value pairs. And comma(‘,’) and equal(‘=’) may not be used in the key or value.
-
validate_keys
(keys: Sequence[str]) → None¶ Validate the provided keys.
- Parameters
keys – A list of keys to validate.
-
-
class
osc_lib.cli.parseractions.
MultiKeyValueCommaAction
(option_strings: Sequence[str], dest: str, nargs: Optional[Union[int, str]] = None, required_keys: Optional[Sequence[str]] = None, optional_keys: Optional[Sequence[str]] = None, const: Optional[_T] = None, default: Optional[Union[_T, str]] = None, type: Optional[Callable[[str], _T]] = None, choices: Optional[Iterable[_T]] = None, required: bool = False, help: Optional[str] = None, metavar: Optional[Union[str, Tuple[str, …]]] = None)¶ Bases:
osc_lib.cli.parseractions.MultiKeyValueAction
Custom action to parse arguments from a set of key=value pair
Ensures that
dest
is a dict. Parses dict by separating comma separated string into individual values Ex. key1=val1,val2,key2=val3 => {“key1”: “val1,val2”, “key2”: “val3”}
-
class
osc_lib.cli.parseractions.
NonNegativeAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶ Bases:
argparse.Action
A custom action to check whether the value is non-negative or not
Ensures the value is >= 0.
-
class
osc_lib.cli.parseractions.
RangeAction
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶ Bases:
argparse.Action
A 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
dest
to (4, 4) ‘6:9’ setsdest
to (6, 9)