command.lister¶
Defines command classes producing tablelike output.
- class lmi.scripts.common.command.lister.LmiBaseListerCommand(*args, **kwargs)[source]¶
Base class for all lister commands.
- classmethod get_columns()[source]¶
Returns: Column names for resulting table. COLUMNS property will be converted to this class method. If None, the associated function shall return column names as the first tuple of returned list. If empty tuple or list, no header shall be printed and associated function returns just data rows. Return type: list or tuple or None
- class lmi.scripts.common.command.lister.LmiInstanceLister(*args, **kwargs)[source]¶
End point command outputting a table of instances for each host. Associated function shall return a list of instances. They may be prepended with column names depending on value of DYNAMIC_PROPERTIES. Each instance will occupy single row of table with property values being a content of cells.
List of additional recognized properties is the same as for LmiShowInstance. There is just one difference. Either DYNAMIC_PROPERTIES must be True or PROPERTIES must be filled.
Using metaclass: InstanceListerMetaClass.
- classmethod render(_self, inst)[source]¶
Return tuple of (column_names, values) ready for output by formatter.
- take_action(connection, args, kwargs)[source]¶
Collects results of single host.
Parameters: - connection (lmi.shell.LMIConnection) – Connection to a single host.
- args (list) – Positional arguments for associated function.
- kwargs (dictionary) – Keyword arguments for associated function.
Returns: Column names and item list as a pair.
Return type: tuple
- class lmi.scripts.common.command.lister.LmiLister(*args, **kwargs)[source]¶
End point command outputting a table for each host. Associated function shall return a list of rows. Each row is represented as a tuple holding column values.
List of additional recognized properties:
- COLUMNS : tuple
- Column names. It’s a tuple with name for each column. Each row shall then contain the same number of items as this tuple. If omitted, associated function is expected to provide them in the first row of returned list. It’s translated to get_columns() class method.
Using metaclass: ListerMetaClass.
- take_action(connection, args, kwargs)[source]¶
Collects results of single host.
Parameters: - connection (lmi.shell.LMIConnection) – Connection to a single host.
- args (list) – Positional arguments for associated function.
- kwargs (dictionary) – Keyword arguments for associated function.
Returns: Column names and item list as a pair.
Return type: tuple