This module defines LmiCheckResult command class and related utilities.

class lmi.scripts.common.command.checkresult.LmiCheckResult(*args, **kwargs)

Run an associated action and check its result. It implicitly makes no output if the invocation is successful and expected result matches.

List of additional recognized properties:


Value, that is expected to be returned by invoked associated function. This can also be a callable taking two arguments:

  1. options - Dictionary with parsed command line options returned by docopt.
  2. result - Return value of associated function.

Using metaclass: CheckResultMetaClass.

check_result(options, result)

Check the returned value of associated function.

  • options (dictionary) – Dictionary as returned by docopt parser after running transform_options().
  • result – Any return value that will be compared against what is expected.

Whether the result is expected value or not. If tuple is returned, it contains (passed_flag, error_description).

Return type:

boolean or tuple.

take_action(connection, args, kwargs)

Invoke associated method and check its return value for single host.

  • args (list) – List of arguments to pass to the associated function.
  • kwargs (dictionary) – Keyword arguments to pass to the associated function.

Exit code (0 on success).

Return type:


exception lmi.scripts.common.command.checkresult.LmiResultFailed

Exception raised when associated function returns unexpected result. This is evaluated by LmiCheckResult.check_result() method.