CIMInstanceName objects are required as parameters for most PyWBEM calls as they uniquely identify a CIM instance on the managed node.
The following code enumerates the instance paths of instances of the specified CIM class and prints their instance paths in WBEM URI format (see
CIMInstanceName.__str__()), and their key bindings (= key property values) (see
from __future__ import print_function import pywbem username = 'user' password = 'password' classname = 'CIM_ComputerSystem' namespace = 'root/cimv2' server = 'http://localhost' conn = pywbem.WBEMConnection(server, (username, password), no_verification=True) try: paths = conn.EnumerateInstanceNames(classname, namespace) except pywbem.Error as exc: print('Operation failed: %s' % exc) else: print('Retrieved %s instance paths' % (len(paths))) for path in paths: print('instance path: %s' % path) print('keybindings: %s' % path.items())
In this example, the connection has no default CIM namespace set, so we supply it in the operation method.
Note that you cannot assume that the ordering of the returned instance paths is the same as the ordering of the instances returned by
EnumerateInstances(). The CIM standards do not require to maintain the same order between these operations. For this reason, PyWBEM did not bother to maintain the order of entities it receives in the protocol, but uses the standard Python semantic for dictionaries, namely to be unordered.