common

Package with client-side python modules and command line utilities.

lmi.scripts.common.get_computer_system(ns)[source]

Obtain an instance of CIM_ComputerSystem or its subclass. Preferred class name can be configured in configuration file. If such class does not exist, a base class (CIM_ComputerSystem) is enumerated instead. First feasible instance is cached and returned.

Parameters:ns (lmi.shell.LMINamespace) – Namespace object where to look for computer system class.
Returns:Instance of CIM_ComputerSystem.
Return type:lmi.shell.LMIInstance.
lmi.scripts.common.get_logger(module_name)[source]

Convenience function for getting callable returning logger for particular module name. It’s supposed to be used at module’s level to assign its result to global variable like this:

from lmi.scripts import common

LOG = common.get_logger(__name__)

This can be used in module’s functions and classes like this:

def module_function(param):
    LOG().debug("this is debug statement logging param: %s", param)

Thanks to LOG being a callable, it always returns valid logger object with current configuration, which may change overtime.

Parameters:module_name (string) – Absolute dotted module path.
Return type:logging.Logger

Previous topic

OpenLMI Scripts API

Next topic

common.command

This Page