Python Data Model for CIM

One of the goals of PyWBEM is to have an understandable, well-integrated, and easy to use interface to CIM objects and operations. This is achieved by the thoughtful mapping of CIM objects such as instances, instance names, properties, classes, etc. to Python objects. There is no need to worry about the representation of CIM objects in XML, or anything related to HTTP/HTTPS.

PyWBEM represents CIM objects in a generic way. For example, CIM instances are represented as objects of the Python class pywbem.CIMInstance, and CIM classes as objects of the Python class pywbem.CIMClass. Thus, a CIM instance of class "CIM_Person" is represented as a Python object of type CIMInstance whose classname attribute is set to "CIM_Person".

This approach is simple and straight forward. However, first-class object aficionados might prefer Python objects of type CIM_Person for CIM instances of class "CIM_Person", instead. Such a first-class object representation has its own complexities, however, and is not currently supported by PyWBEM.

CIM Instances and Instance Names

The two fundamental Python classes in PyWBEM are pywbem.CIMInstance and pywbem.CIMInstanceName.

A CIMInstance object is a representation of a CIM instance in a WBEM server, which in turn represents a physical or logical resource that is under management, or an aspect thereof. Examples for such managed resources are disk drives, temperature sensors, or network cards. The most interesting part of a CIM instance is the properties and values those properties take. The properties of a CIMInstance object can be accessed by treating the object as a Python dictionary:

In [ ]:
import pywbem

inst = pywbem.CIMInstance('CIM_Person')
inst['Firstname'] = 'Tim'
inst['Lastname'] = 'Potter'

print(inst.items())
print(inst['firstname'])

Note that the second print() specifies the CIM property name in a different lexical case compared to how it was created. PyWBEM supports case-insensitive access to all CIM element names, as required by the CIM standards.

A CIMInstanceName object is a reference to a CIM instance in a WBEM server. It may specify the location of the WBEM server, the CIM namespace within the server, the CIM class within the namespace, and identifies the CIM instance within the class by means of its key property values. These key property values are called key bindings in CIM.

Similar to CIMInstance, the key bindings of a CIMInstanceName object can also be accessed by treating the object as a Python dictionary.

CIM Data Types

CIM has a number of data types that are mostly mapped to specific Python classes, and in some cases to built-in Python types such as bool, str/unicode or list.

See CIM data types for details about the Python representation of CIM data types.