The ironicclient.common.cliutils Module

exception ironicclient.common.cliutils.MissingArgs(missing)[source]

Bases: exceptions.Exception

Supplied arguments are not sufficient for calling a function.

ironicclient.common.cliutils.add_arg(func, *args, **kwargs)[source]

Bind CLI arguments to a shell.py do_foo function.

ironicclient.common.cliutils.arg(*args, **kwargs)[source]

Decorator for CLI args.

Example:

>>> @arg("name", help="Name of the new entity")
... def entity_create(args):
...     pass
ironicclient.common.cliutils.env(*args, **kwargs)[source]

Returns the first environment variable set.

If all are empty, defaults to ‘’ or keyword arg default.

ironicclient.common.cliutils.exit(msg='')[source]
ironicclient.common.cliutils.get_password(max_password_prompts=3)[source]

Read password from TTY.

ironicclient.common.cliutils.get_service_type(f)[source]

Retrieves service type from function.

ironicclient.common.cliutils.isunauthenticated(func)[source]

Checks if the function does not require authentication.

Mark such functions with the @unauthenticated decorator.

Returns:bool
ironicclient.common.cliutils.pretty_choice_list(l)[source]
ironicclient.common.cliutils.print_dict(dct, dict_property='Property', wrap=0, dict_value='Value', json_flag=False)[source]

Print a dict as a table of two columns.

Parameters:
  • dctdict to print
  • dict_property – name of the first column
  • wrap – wrapping for the second column
  • dict_value – header label for the value (second) column
  • json_flag – print dict as JSON instead of table
ironicclient.common.cliutils.print_list(objs, fields, formatters=None, sortby_index=0, mixed_case_fields=None, field_labels=None, json_flag=False)[source]

Print a list of objects or dict as a table, one row per object or dict.

Parameters:
  • objs – iterable of Resource
  • fields – attributes that correspond to columns, in order
  • formattersdict of callables for field formatting
  • sortby_index – index of the field for sorting table rows
  • mixed_case_fields – fields corresponding to object attributes that have mixed case names (e.g., ‘serverId’)
  • field_labels – Labels to use in the heading of the table, default to fields.
  • json_flag – print the list as JSON instead of table
ironicclient.common.cliutils.service_type(stype)[source]

Adds ‘service_type’ attribute to decorated function.

Usage:

@service_type('volume')
def mymethod(f):
...
ironicclient.common.cliutils.unauthenticated(func)[source]

Adds ‘unauthenticated’ attribute to decorated function.

Usage:

>>> @unauthenticated
... def mymethod(f):
...     pass
ironicclient.common.cliutils.validate_args(fn, *args, **kwargs)[source]

Check that the supplied args are sufficient for calling a function.

>>> validate_args(lambda a: None)
Traceback (most recent call last):
    ...
MissingArgs: Missing argument(s): a
>>> validate_args(lambda a, b, c, d: None, 0, c=1)
Traceback (most recent call last):
    ...
MissingArgs: Missing argument(s): b, d
Parameters:
  • fn – the function to check
  • args – the positional arguments supplied
  • kwargs – the keyword arguments supplied

Previous topic

The ironicclient.common.base Module

Next topic

The ironicclient.common.filecache Module

Project Source

This Page