The magnumclient.common.cliutils Module¶
- 
exception magnumclient.common.cliutils.DuplicateArgs(param, dupes)¶
- Bases: - exceptions.Exception- More than one of the same argument type was passed. 
- 
exception magnumclient.common.cliutils.MissingArgs(missing)¶
- Bases: - exceptions.Exception- Supplied arguments are not sufficient for calling a function. 
- 
magnumclient.common.cliutils.add_arg(func, *args, **kwargs)¶
- Bind CLI arguments to a shell.py do_foo function. 
- 
magnumclient.common.cliutils.arg(*args, **kwargs)¶
- Decorator for CLI args. - Example: - >>> @arg("name", help="Name of the new entity") ... def entity_create(args): ... pass 
- 
magnumclient.common.cliutils.deprecated(message)¶
- Decorator for marking a call as deprecated by printing a given message. - Example: >>> @deprecated(“Bay functions are deprecated and should be replaced by ” … “calls to cluster”) … def bay_create(args): … pass 
- 
magnumclient.common.cliutils.deprecation_map(dep_map)¶
- Decorator for applying a map of deprecating arguments to a function. - The map connects deprecating arguments and their replacements. The shell.py script uses this map to create mutually exclusive argument groups in argparse and also prints a deprecation warning telling the user to switch to the updated argument. - NOTE: This decorator MUST be the outermost in the chain of argument decorators to work correctly. - Example usage: >>> @deprecation_map({ “old-argument”: “new-argument” }) … @args(“old-argument”, required=True) … @args(“new-argument”, required=True) … def do_command_line_stuff(): … pass 
- 
magnumclient.common.cliutils.deprecation_message(preamble, new_name)¶
- 
magnumclient.common.cliutils.env(*args, **kwargs)¶
- Returns the first environment variable set. - If all are empty, defaults to ” or keyword arg default. 
- 
magnumclient.common.cliutils.exit(msg=”)¶
- 
magnumclient.common.cliutils.get_password(max_password_prompts=3)¶
- Read password from TTY. 
- 
magnumclient.common.cliutils.get_service_type(f)¶
- Retrieves service type from function. 
- 
magnumclient.common.cliutils.isunauthenticated(func)¶
- Checks if the function does not require authentication. - Mark such functions with the @unauthenticated decorator. - Returns: - bool 
- 
magnumclient.common.cliutils.keys_and_vals_to_strs(dictionary)¶
- Recursively convert a dictionary’s keys and values to strings. - Parameters: - dictionary – dictionary whose keys/vals are to be converted to strs 
- 
magnumclient.common.cliutils.make_field_formatter(attr, filters=None)¶
- Given an object attribute. - Return a formatted field name and a formatter suitable for passing to print_list. Optionally pass a dict mapping attribute names to a function. The function will be passed the value of the attribute and should return the string to display. 
- 
magnumclient.common.cliutils.pretty_choice_list(l)¶
- 
magnumclient.common.cliutils.print_dict(dct, dict_property=’Property’, wrap=0)¶
- Print a dict as a table of two columns. - Parameters: - dct – dict to print
- dict_property – name of the first column
- wrap – wrapping for the second column
 
- 
magnumclient.common.cliutils.print_list(objs, fields, formatters=None, sortby_index=0, mixed_case_fields=None, field_labels=None)¶
- Print a list or objects as a table, one row per object. - Parameters: - objs – iterable of Resource
- fields – attributes that correspond to columns, in order
- formatters – dict 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.
 
- objs – iterable of 
- 
magnumclient.common.cliutils.service_type(stype)¶
- Adds ‘service_type’ attribute to decorated function. - Usage: - @service_type('volume') def mymethod(f): ... 
- 
magnumclient.common.cliutils.unauthenticated(func)¶
- Adds ‘unauthenticated’ attribute to decorated function. - Usage: - >>> @unauthenticated ... def mymethod(f): ... pass 
- 
magnumclient.common.cliutils.validate_args(fn, *args, **kwargs)¶
- 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
- arg – the positional arguments supplied
- kwargs – the keyword arguments supplied
 
- 
magnumclient.common.cliutils.validate_name_args(positional_name, optional_name)¶