WBEMConnection

class lmiwbem.lmiwbem_core.WBEMConnection

WBEMConnection(url=None, creds=None, x509=None, default_namespace=None, no_verification=False, connect_locally=False)

Parameters:
  • url (str) – URL of CIMOM instance
  • creds (tuple) – (username, password)
  • x509 (dict) – ‘cert_file’: ‘path_to_cert_file’, ‘key_file’ : ‘path_to_key_file’
  • default_namespace (str) – Default namespace used for CIM operations
  • no_verification (bool) – If True, CIMOM’s X509 certificate shall not be verified
  • connect_locally (bool) – If True, Unix socket will be used
AssociatorNames(ObjectName, AssocClass=None, ResultClass=None, Role=None, ResultRole=None, namespace=None)

Returns a list of associated CIMInstanceName objects with an input object path.

Parameters:
  • ObjectName (CIMInstanceName) – Object path that is the basis for the enumeration
  • AssocClass (str) – See DMTF
  • ResultClass (str) – See DMTF
  • Role (str) – See DMTF
  • ResultRole (str) – See DMTF
  • namespace (str) – See DMTF
Returns:

List of associated CIMInstanceName objects with an input object path

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of AssociatorNames.

Associators(ObjectName, AssocClass=None, ResultClass=None, Role=None, ResultRole=None, IncludeQualifiers=False, IncludeClassOrigin=False, PropertyList=None, namespace=None)

Returns a list of associated CIMInstance objects with an input object path.

Parameters:
  • ObjectName (CIMInstanceName) – Object path that is the basis for the enumeration
  • AssocClass (str) – See DMTF
  • ResultClass (str) – See DMTF
  • Role (str) – See DMTF
  • ResultRole (str) – See DMTF
  • IncludeQualifiers (bool) – See DMTF
  • IncludeClassOrigin (bool) – See DMTF
  • PropertyList (list) – See DMTF
  • namespace (str) – See DMTF
Returns:

List of associated CIMInstance objects with an input object path

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of Associators.

CloseEnumeration(Context)

Closes an enumeration sequence.

Parameters:

Context (CIMEnumerationContext) – Enumeration context to close.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
CreateInstance(NewInstance, ns=None)

Creates a new CIM instance and returns its CIMInstanceName.

Parameters:
  • NewInstance (CIMInstance) – New local CIM instance
  • ns (str) – Namespace in which the CIMInstance will be created. If ns is None, namespace will be used from NewInstance.path.namespace.
Returns:

CIMInstanceName of new CIMInstance

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of CreateInstance.

DeleteInstance(InstanceName)

Deletes a CIM instance identified by CIMInstanceName.

Parameters:

InstanceName (CIMInstanceName) – Object path of CIM instance

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of DeleteInstance.

EnumerateClassNames(namespace=None, ClassName=None, DeepInheritance=False)

Enumerates class names managed by the CIMOM.

Parameters:
  • namespace (str) – Namespace name, from which the classes will be retrieved
  • ClassName (str) – Class name, which defines the class that is the basis for the enumeration
  • DeepInheritance (bool) – See DMTF
Returns:

List of strings of class names

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of EnumerateClassNames.

EnumerateClasses(namespace=None, ClassName=None, DeepInheritance=False, LocalOnly=True, IncludeQualifiers=True, IncludeClassOrigin=False)

Enumerates classes managed by the CIMOM.

Parameters:
  • namespace (str) – Namespace name, from which the classes will be retrieved
  • ClassName (str) – Class name, which defines the class that is the basis for the enumeration
  • DeepInheritance (bool) – See DMTF
  • LocalOnly (bool) – See DMTF
  • IncludeQualifiers (bool) – See DMTF
  • IncludeClassOrigin (bool) – See DMTF
Returns:

List of CIMClass objects

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of :EnumerateClasses.

EnumerateInstanceNames(ClassName, namespace=None)

Enumerates instance names of a given class name.

Parameters:
  • ClassName (str) – Class name of instance names to be retrieved
  • namespace (str) – Namespace name, from which the instance names will be retrieved
Returns:

List of CIMInstanceName objects.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of EnumerateInstanceNames.

EnumerateInstances(ClassName, namespace=None, LocalOnly=True, DeepInheritance=True, IncludeQualifiers=False, IncludeClassOrigin=False, PropertyList=None)

Enumerates instances of a given class name.

Parameters:
  • ClassName (str) – String containing class name of instances to be retrieved.
  • namespace (str) – String containing namespace, from which the instances should be retrieved.
  • LocalOnly (bool) – See DMTF
  • IncludeQualifiers (bool) – See DMTF
  • IncludeClassOrigin (bool) – See DMTF
  • PropertyList (list) – See DMTF
Returns:

List of CIMInstance objects

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of EnumerateInstances.

ExecQuery(QueryLanguage, Query, namespace=None)

Executes a query and returns a list of CIMInstance objects.

Parameters:
  • query_lang (str) – Query language
  • query (str) – Query to execute
  • namespace (str) – Target namespace for the query
Returns:

List of CIMInstance objects

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also ExecQuery example

GetClass(ClassName, namespace=None, LocalOnly=True, IncludeQualifiers=True, IncludeClassOrigin=False, PropertyList=None)

Returns a CIMClass representing the named class.

Parameters:
  • ClassName (str) – Class name of class to be retrieved
  • namespace (str) – Namespace name, from which the class will be retrieved
  • LocalOnly (bool) – See DMTF
  • IncludeQualifiers (bool) – See DMTF
  • IncludeClassOrigin (bool) – See DMTF
  • PropertyList (list) – See DMTF
Returns:

CIMClass object

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of GetClass.

GetInstance(InstanceName, namespace=None, LocalOnly=True, IncludeQualifiers=False, IncludeClassOrigin=False, PropertyList=None)

Fetches a CIMInstance from CIMOM identified by CIMInstanceName.

Parameters:
  • InstanceName (CIMInstanceName) – Identifies a CIMInstance
  • namespace (str) – Namespace name, from which the instance will be retrieved
  • LocalOnly (bool) – See DMTF
  • IncludeQualifiers (bool) – See DMTF
  • IncludeClassOrigin (bool) – See DMTF
  • PropertyList (list) – See DMTF
Returns:

CIMInstance object

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of GetInstance.

InvokeMethod(MethodName, ObjectName, **params)

Executes a method within a given instance.

Parameters:
  • MethodName (str) – method name
  • ObjectName (CIMInstanceName) – specifies CIM object within which the method will be called
  • params (dict) – parameters passed to the method call
Returns:

Tuple containing method’s return value and output parameters

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of InvokeMethod.

ModifyInstance(ModifiedInstance, IncludeQualifiers=True, PropertyList=None)

Modifies properties of a existing instance.

Parameters:
  • ModifiedInstance (CIMInstance) – Modified CIM instance
  • IncludeQualifiers (bool) – see DMTF
  • PropertyList (list) – See DMTF
Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of ModifyInstance.

OpenAssociatorNames(ObjectName, namespace=None, AssocClass=None, ResultClass=None, Role=None, ResultRole=None, QueryLanguage=None, Query=None, OperationTimeout=None, ContinueOnError=False, MaxObjectCnt=0)

Opens an enumeration for associated CIMInstanceName objects with an input object path.

Parameters:
  • ObjectName (CIMInstanceName) – Object path that is the basis for the enumeration
  • namespace (str) – Namespace name, from which the elements should be retrieved
  • AssocClass (str) – See DMTF
  • ResultClass (str) – See DMTF
  • Role (str) – See DMTF
  • ResultRole (str) – See DMTF
  • QueryLanguage (str) – Query language to be used with the Query.
  • Query (str) – Filter query to be applied to the enumeration
  • OperationTimeout (int) – Defines the interoperation timeout in seconds between the response and subsequent request operations of an enumeration sequence.
  • ContinueOnError (bool) – Defines whether the server should continue to return elements subsequent to a CIMError occurring in the server.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing list of retrieved CIMInstanceName objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
OpenAssociators(ObjectName, namespace=None, AssocClass=None, ResultClass=None, Role=None, ResultRole=None, IncludeQualifiers=False, IncludeClassOrigin=False, PropertyList=None, QueryLanguage=None, Query=None, OperationTimeout=None, ContinueOnError=False, MaxObjectCnt=0)

Opens an enumeration for associated CIMInstance objects with an input object path.

Parameters:
  • ObjectName (CIMInstanceName) – Object path that is the basis for the enumeration
  • namespace (str) – Namespace name, from which the elements should be retrieved
  • AssocClass (str) – See DMTF
  • ResultClass (str) – See DMTF
  • Role (str) – See DMTF
  • ResultRole (str) – See DMTF
  • IncludeQualifiers (bool) – See DMTF
  • IncludeClassOrigin (bool) – See DMTF
  • PropertyList (list) – See DMTF
  • QueryLanguage (str) – Query language to be used with the Query
  • Query (str) – Filter query to be applied to the enumeration
  • OperationTimeout (int) – Defines the interoperation timeout in seconds between the response and subsequent request operations of an enumeration sequence.
  • ContinueOnError (bool) – Defines whether the server should continue to return elements subsequent to a CIMError occurring in the server.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing list of retrieved CIMInstance objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
OpenEnumerateInstanceNames(ClassName, namespace=None, QueryLanguage=None, Query=None, OperationTimeout=None, ContinueOnError=False, MaxObjectCnt=0)

Opens an enumeration sequence of CIMInstanceName.

Parameters:
  • ClassName (str) – Class name of elements to be retrieved
  • namespace (str) – String containing namespace, from which the elements should be retrieved.
  • QueryLanguage (str) – Query language to be used with the Query
  • Query (str) – Filter query to be applied to the enumeration
  • OperationTimeout (int) – Defines the interoperation timeout in seconds between the response and subsequent request operations of an enumeration sequence.
  • ContinueOnError (bool) – Defines whether the server should continue to return elements subsequent to a CIMError occurring in the server.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing list of retrieved CIMInstanceName objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
OpenEnumerateInstances(ClassName, namespace=None, LocalOnly=True, DeepInheritance=True, IncludeQualifiers=False, IncludeClassOrigin=False, PropertyList=None, QueryLang=None, Query=None, OperationTimeout=None, ContinueOnError=False, MaxObjectCnt=0)

Opens an enumeration sequence of CIMInstance.

Parameters:
  • ClassName (str) – String containing class name of instances to be retrieved.
  • namespace (str) – Namespace name, from which the instances should be retrieved
  • LocalOnly (bool) – Unused
  • DeepInheritance (bool) – See DMTF
  • IncludeQualifiers (bool) – Unused
  • IncludeClassOrigin (bool) – See DMTF
  • PropertyList (list) – See DMTF
  • QueryLanguage (str) – Query language to be used with the Query
  • Query (str) – Filter query to be applied to the enumeration
  • OperationTimeout (int) – Defines the interoperation timeout in seconds between the response and subsequent request operations of an enumeration sequence.
  • ContinueOnError (bool) – Defines whether the server should continue to return instances subsequent to a CIMError occurring in the server.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing list of retrieved CIMInstance objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
OpenExecQuery(QueryLanguage, Query, namespace=None, OperationTimeout=None, ContinueOnError=False, MaxObjectCnt=0)

Opens an enumeration for Query.

Parameters:
  • QueryLanguage (str) – Query language in which the query parameter is expressed
  • Query (str) – Specified the query to be executed
  • namespace (str) – Namespace name, from which the elements should be retrieved.
  • OperationTimeout (int) – Defines the interoperation timeout in seconds between the response and subsequent request operations of an enumeration sequence.
  • ContinueOnError (bool) – Defines whether the server should continue to return elements subsequent to a CIMError occurring in the server.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing list of retrieved CIMInstance objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
OpenReferenceNames(ObjectName, namespace=None, ResultClass=None, Role=None, QueryLanguage=None, Query=None, OperationTimeout=None, ContinueOnError=False, MaxObjectCnt=0)

Opens an enumeration for association CIMInstanceName objects with an input object path.

Parameters:
  • ObjectName (CIMInstanceName) – Object path that is the basis for the enumeration.
  • namespace (str) – Namespace name, from which the elements should be retrieved.
  • ResultClass (str) – See DMTF
  • Role (str) – See DMTF
  • QueryLanguage (str) – Query language to be used with the Query.
  • Query (str) – Filter query to be applied to the enumeration.
  • OperationTimeout (int) – Defines the interoperation timeout in seconds between the response and subsequent request operations of an enumeration sequence.
  • ContinueOnError (bool) – Defines whether the server should continue to return elements subsequent to a CIMError occurring in the server.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing list of retrieved CIMInstanceName objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
OpenReferences(ObjectName, ns=None, ResultClass=None, Role=None, IncludeQualifiers=False, IncludeClassOrigin=False, PropertyList=None, QueryLanguage=None, Query=None, OperationTimeout=None, ContinueOnError=False, MaxObjectCnt=0)

Opens an enumeration for association CIMInstance objects with an input object path.

Parameters:
  • ObjectName (CIMInstanceName) – Object path that is the basis for the enumeration.
  • namespace (str) – Namespace name, from which the elements should be retrieved.
  • ResultClass (str) – See DMTF
  • Role (str) – See DMTF
  • IncludeQualifiers (bool) – Unused
  • IncludeClassOrigin (bool) – See DMTF
  • PropertyList (list) – See DMTF
  • QueryLanguage (str) – Query language to be used with the Query
  • Query (str) – Filter query to be applied to the enumeration
  • OperationTimeout (int) – Defines the interoperation timeout in seconds between the response and subsequent request operations of an enumeration sequence.
  • ContinueOnError (bool) – Defines whether the server should continue to return elements subsequent to a CIMError occurring in the server.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing list of retrieved CIMInstance objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
PullInstanceNames(Context, MaxObjectCnt=0)

Retrieves a list of CIMInstanceName for an open enumeration sequence opened by an openQueryInstances operation and represented by an enumeration context returned by the original open or previous WBEMConnection.PullInstanceNames() operation.

Parameters:
  • Context (CIMEnumerationContext) – Identifier for the enumeration sequence.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing list of retrieved CIMInstanceName objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
PullInstances(Context, MaxObjectCnt=0)

Retrieves a list of CIMInstance for an open enumeration sequence opened by an openQueryInstances operation and represented by an enumeration context returned by the original open or previous WBEMConnection.PullInstancesWithPath() operation.

Parameters:
  • Context (CIMEnumerationContext) – Identifier for the enumeration sequence.
  • MaxObjectCnt (int) – Defines the maximum number of elements that this Open operation can return.
Returns:

Tuple containing a list of retrieved CIMInstance objects, enumeration context and boolean which defines if all the instances have been retrieved.

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.
ReferenceNames(ObjectName, ResultClass=None, Role=None, namespace=None)

Returns a list of association CIMInstanceName objects with an input object path.

Parameters:
  • ObjectName (CIMInstanceName) – Object path that is the basis for the enumeration
  • ResultClass (str) – See DMTF
  • Role (str) – See DMTF
  • namespace (str) – See DMTF
Returns:

List of association CIMInstanceName objects with an input object path

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of ReferenceNames.

References(ObjectName, ResultClass=None, Role=None, IncludeQualifiers=False, IncludeClassOrigin=False, PropertyList=None, namespace=None)

Returns a list of association CIMInstance objects with an input object path.

Parameters:
  • ObjectName (CIMInstanceName) – Object path that is the basis for the enumeration
  • ResultClass (str) – See DMTF
  • Role (str) – See DMTF
  • IncludeQualifiers (bool) – See DMTF
  • IncludeClassOrigin (bool) – See DMTF
  • PropertyList (list) – See DMTF
  • namespace (str) – See DMTF
Returns:

List of association CIMInstance objects with an input object path

Raises:
  • CIMError – When a CIM error occurs.
  • ConnectionError – When a connection can’t be established.

See also

Full example of References.

connect(url=None, username=None, password=None, cert_file=None, key_file=None, no_verification=None)

Connects to CIMOM.

Parameters:
  • url (str) – URL of CIMOM instance
  • username (str) – Username for authentication
  • password (str) – Password for authentication
  • no_verification (bool) – If True, CIMOM’s X509 certificate shall not be verified
Raises:

ConnectionError – When a connection can’t be established.

See also

Full example of Connecting to CIMOM.

connectLocally()

Connect to CIMOM using local Unix socket.

Raises:ConnectionError – When a connection can’t be established.

See also

Full example of Connection using Unix Socket.

connect_locally
creds
default_namespace

Property for default CIM namespace used for CIM operations.

disconnect()

Disconnects from CIMOM.

hostname

Returns a CIMOM hostname.

is_connected

Returns True, if the client is connected to a CIMOM.

no_verification
request_accept_languages

Property for accept languages currently configured for this client.

timeout

Property for CIM operations timeout in milliseconds. Default value is 60000ms.

url