Python CIM Providers With Pywbem: Bart Whiteley
Python CIM Providers With Pywbem: Bart Whiteley
• Motivation
• Design Goals
• Benefits
• Architecture
• Interface Details
• Demonstration
• References
Motivation
CIMOM
(OpenWBEM or Pegasus)
pywbem/cim_provider.py
11
get_instance
• MOF:
uint32 RequestStateChange([IN] RequestedState,
[IN(false), OUT] CIM_ConcreteJob REF Job,
[IN] datetime TimeoutPeriod);
• Python:
def cim_method_requeststatechange(self, env,
object_name, method, param_requestedstate,
param_timeoutperiod):
– object_name – A pywbem.CIMInstanceName or
pywbem.CIMClassName indicating the target object.
– method – A pywbem.CIMMethod representing the CIM method
definition.
– param_requestedstate and param_timeoutperiod are the IN
parameters.
– Return a 2-tuple containing the return value (pywbem.Uint32) and
the dictionary
{'job':pywbem.CIMInstanceName('CIM_ConcreteJob', ...)}
Module Functions
• Required:
– get_providers(env)
• Returns a dictionary mapping CIM class names to instaces of Python
provider classes.
• Optional:
– init(env)
• Optional. First method called.
– shutdown(env)
• Called when the provider is unloaded.
– can_unload(env)
• Return True if the provider can be unloaded.
– Indication related methods.
• handle_indication, consume_indication, activate_filter, deactivate_filter.
• Not covered in this presentation.
Provider Environment
logger = env.get_logger()
logger.log_debug('Debug Info')
ch = env.get_cimom_handle()
other_inst = ch.GetInstance(inst_path,
LocalOnly=False, IncludeQualifiers=False,
IncludeClassOrigin=False)
Code Generation
codegen(cim_class)
• cim_class is a pywbem.CIMClass
– Make sure it has all of the properties, methods, and qualifiers.
• Returns a 2-tuple containing:
– Syntactically correct Python provider module code, ready to
run (though it won't do much).
– Provider registration MOF.
Debugging
• http://pywbem.sourceforge.net/
• http://pywbem.wiki.sourceforge.net/
• http://pywbem.wiki.sourceforge.net/Provider+QuickStart
• http://omc.svn.sourceforge.net/viewvc/omc/pybase/trunk/
• http://omc.svn.sourceforge.net/viewvc/omc/pyprofiles/
• http://www.dmtf.org/standards/published_documents/DSP200.html
• http://www.python.org/dev/peps/pep-0008/