command.checkresult¶
This module defines LmiCheckResult command class and related utilities.
- class lmi.scripts.common.command.checkresult.LmiCheckResult(*args, **kwargs)[source]¶
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:
- EXPECT :
Value, that is expected to be returned by invoked associated function. This can also be a callable taking two arguments:
- options - Dictionary with parsed command line options returned by docopt.
- result - Return value of associated function.
Using metaclass: CheckResultMetaClass.
- check_result(options, result)[source]¶
Check the returned value of associated function.
Parameters: - options (dictionary) – Dictionary as returned by docopt parser after running transform_options().
- result – Any return value that will be compared against what is expected.
Returns: 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)[source]¶
Invoke associated method and check its return value for single host.
Parameters: - args (list) – List of arguments to pass to the associated function.
- kwargs (dictionary) – Keyword arguments to pass to the associated function.
Returns: Exit code (0 on success).
Return type: integer
- exception lmi.scripts.common.command.checkresult.LmiResultFailed[source]¶
Exception raised when associated function returns unexpected result. This is evaluated by LmiCheckResult.check_result() method.