Meta classes simplifying declaration of user commands.
Each command is defined as a class with a set of properties. Some are mandatory, the others have some default values. Each of them is transformed by metaclasse to some function, class method or other property depending on command type and semantic of property. Property itself is removed from resulting class after being processed by meta class.
Meta class for end-point command “check result”. Additional handled properties:
- EXPECT :
- Value to compare against the return value. Mandatory property.
EXPECT property is transformed into a checkresult.LmiCheckResult.check_result() method taking two arguments (options, result) and returning a boolean.
End point command does not have any subcommands. It’s a leaf of command tree. It wraps some function in command library being referred to as an associated function. It handles following class properties:
- CALLABLE : str or callable
- An associated function. Mandatory property.
- OWN_USAGE : bool or str
- Usage string. Optional property.
- ARG_ARRAY_SUFFIX : str
- Suffix added to argument names containing array of values. Optional property.
Meta class for instance lister command handling the same properties as ShowInstanceMetaClass.
Meta class for end-point lister commands. Handles following class properties:
- COLUMNS : tuple
- List of column names. Optional property.
Meta class for node command (not an end-point command). It handles following class properties:
- COMMANDS : dict
- Command names with assigned command classes. Each of them is a direct subcommands of command with this property. Mandatory property.
- FALLBACK_COMMAND : LmiEndPointCommand
- Command factory to use in case that no command is passed on command line.
Meta class for commands operating upon a session object. All associated functions take as first argument an namespace abstraction of type lmi.shell.
Handles following class properties:
- NAMESPACE : str
- CIM namespace abstraction that will be passed to associated function. Defaults to "root/cimv2". If False, raw lmi.shell.LMIConnection object will be passed to associated function.
Meta class for end-point show instance commands. Additional handled properties:
- DYNAMIC_PROPERTIES : bool
- Whether the associated function itself provides list of properties. Optional property.
- PROPERTIES : tuple
- List of instance properties to print. Optional property.
These are translated in a render(), which should be marked as abstract in base lister class.