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.
- class lmi.scripts.common.command.meta.CheckResultMetaClass¶
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.
- class lmi.scripts.common.command.meta.EndPointCommandMetaClass¶
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.
- FMT_NO_HEADINGS : bool
- Allows to force printing of table headers on and off for this command. Default is to print them.
- FMT_HUMAN_FRIENDLY : bool
- Tells formatter to make the output more human friendly. The result is dependent on the type of formatter used.
- class lmi.scripts.common.command.meta.InstanceListerMetaClass¶
Meta class for instance lister command handling the same properties as ShowInstanceMetaClass.
- class lmi.scripts.common.command.meta.ListerMetaClass¶
Meta class for end-point lister commands. Handles following class properties:
- COLUMNS : tuple
List of column names. Optional property. There are special values such as:
- None or omitted
- Associated function provides column names in a first row of returned list or generator.
- empty list, empty tuple or False
- They mean that no headers shall be printed. It is simalar to using FMT_NO_HEADINGS = True. But in this case all the rows returned from associated functions are treated as data.
- class lmi.scripts.common.command.meta.MultiplexerMetaClass¶
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.
Formatting options (starting with FMT_ are also accepted, and may used to set defaults for all subcommands.
- class lmi.scripts.common.command.meta.SelectMetaClass¶
Meta class for select commands with guarded commands. Additional handled properties:
- SELECT : list
- List of commands guarded with expressions representing requirements on server’s side that need to be met.
- DEFAULT : str or LmiBaseCommand
- Defines fallback command used in case no condition can is satisfied.
- class lmi.scripts.common.command.meta.SessionCommandMetaClass¶
Meta class for commands operating upon a session object. All associated functions take as first argument a 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.
- CONNECTION_TIMEOUT : int
- Maximum number of seconds to wait for broker’s response. If reached, ConnectionError will be raised.
- class lmi.scripts.common.command.meta.ShowInstanceMetaClass¶
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.