LMICIMXMLClient

class lmi.shell.LMICIMXMLClient.LMICIMXMLClient(uri, username='', password='', verify_server_cert=True, key_file=None, cert_file=None)[source]

CIM-XML client.

Parameters:
  • uri (string) – URI of the CIMOM
  • username (string) – account, under which, the CIM calls will be performed
  • password (string) – user’s password
  • verify_server_cert (bool) – indicates, whether a server side certificate needs to be verified, if SSL used; default value is True
  • key_file (string) – path to x509 key file; default value is None
  • cert_file (string) – path to x509 cert file; default value is None
call_method(instance, method, **params)[source]

Executes a method within a given instance.

Parameters:
  • instance

    object, on which the method will be executed. The object needs to be instance of following classes:

  • method (string) – string containing a method name
  • params (dictionary) – parameters passed to the method call
Returns:

LMIReturnValue object with rval set to return value of the method call, rparams set to returned parameters from the method call, if no error occurs; otherwise rval is set to -1 and errorstr to appropriate error string

Raises:

CIMError, ConnectionError, TypeError

connect(*args, **kwargs)[source]

Connects to CIMOM.

NOTE: Applicable only wbem lmiwbem is used.

create_instance(*args, **kwargs)[source]

Creates a new wbem.CIMInstance object.

Parameters:
  • classname (string) – class name of a new instance
  • namespace (string) – namespace, of the new instance
  • properties (dictionary) – property names and values
  • qualifiers (dictionary) – qualifier names and values
  • property_list (list) – list for property filtering; see wbem.CIMInstance
Returns:

new wbem.CIMInstance, if no error occurs; otherwise None is returned

Raises:

CIMError, ConnectionError

delete_instance(*args, **kwargs)[source]

Deletes a wbem.CIMInstance from the CIMOM side.

Parameters:instance

object to be deleted. The object needs to be instance of following classes:

Returns:LMIReturnValue object with rval set to True, if no error occurs; otherwise rval is set to False and errorstr is set to corresponding error string
Raises:CIMError, ConnectionError, TypeError
disconnect()[source]

Disconnects from CIMOM.

NOTE: Applicable only wbem lmiwbem is used.

dummy()[source]

Sends a “dummy” request to verify credentials.

Returns:LMIReturnValue with rval set to True, if provided credentials are OK; False otherwise. If LMIShell uses exceptions, CIMError or ConnectionError will be raised.
Raises:CIMError, ConnectionError
exec_query(*args, **kwargs)[source]

Executes a query and returns a list of wbem.CIMInstance objects.

Parameters:
  • query_lang (string) – query language
  • query (string) – query to execute
  • namespace (string) – target namespace for the query
Returns:

LMIReturnValue object with rval set to list of wbem.CIMInstance objects, if no error occurs; otherwise rval is set to None and errorstr is set to corresponding error string

Raises:

CIMError, ConnectionError

get_associator_names(*args, **kwargs)[source]

Returns a list of associated wbem.CIMInstanceName objects with an input instance.

Parameters:
  • instance

    for this object the list of associated wbem.CIMInstanceName will be returned. The object needs to be instance of following classes:

  • AssocClass (string) – valid CIM association class name. It acts as a filter on the returned set of names by mandating that each returned name identify an object that shall be associated to the source object through an instance of this class or one of its subclasses.
  • ResultClass (string) – valid CIM class name. It acts as a filter on the returned set of names by mandating that each returned name identify an object that shall be either an instance of this class (or one of its subclasses) or be this class (or one of its subclasses).
  • Role (string) – valid property name. It acts as a filter on the returned set of names by mandating that each returned name identify an object that shall be associated to the source object through an association in which the source object plays the specified role. That is, the name of the property in the association class that refers to the source object shall match the value of this parameter.
  • ResultRole (string) – valid property name. It acts as a filter on the returned set of names by mandating that each returned name identify an object that shall be associated to the source object through an association in which the named returned object plays the specified role. That is, the name of the property in the association class that refers to the returned object shall match the value of this parameter.
  • limit (int) – unused
Returns:

list of associated wbem.CIMInstanceName objects with an input instance, if no error occurs; otherwise an empty list is returned

Raises:

CIMError, ConnectionError, TypeError

get_associators(*args, **kwargs)[source]

Returns a list of associated wbem.CIMInstance objects with an input instance.

Parameters:
  • instance

    for this object the list of associated wbem.CIMInstance objects will be returned. The object needs to be instance of following classes:

  • AssocClass (string) – valid CIM association class name. It acts as a filter on the returned set of objects by mandating that each returned object shall be associated to the source object through an instance of this class or one of its subclasses.
  • ResultClass (string) – valid CIM class name. It acts as a filter on the returned set of objects by mandating that each returned object shall be either an instance of this class (or one of its subclasses) or be this class (or one of its subclasses).
  • Role (string) – valid property name. It acts as a filter on the returned set of objects by mandating that each returned object shall be associated with the source object through an association in which the source object plays the specified role. That is, the name of the property in the association class that refers to the source object shall match the value of this parameter.
  • ResultRole (string) – valid property name. It acts as a filter on the returned set of objects by mandating that each returned object shall be associated to the source object through an association in which the returned object plays the specified role. That is, the name of the property in the association class that refers to the returned object shall match the value of this parameter.
  • IncludeQualifiers (bool) – indicates, if all qualifiers for each object (including qualifiers on the object and on any returned properties) shall be included as <QUALIFIER> elements in the response.
  • IncludeClassOrigin (bool) – indicates, if the CLASSORIGIN attribute shall be present on all appropriate elements in each returned object.
  • PropertyList (list) – if not None, the members of the array define one or more property names. Each returned object shall not include elements for any properties missing from this list. If PropertyList is an empty list, no properties are included in each returned object. If it is None, no additional filtering is defined.
  • limit (int) – unused
Returns:

list of associated wbem.CIMInstance objects with an input instance, if no error occurs; otherwise an empty list is returned

Raises:

CIMError, ConnectionError, TypeError

get_class(*args, **kwargs)[source]

Returns a wbem.CIMClass object.

Parameters:
  • classname (string) – class name
  • namespace (string) – – namespace name, from which the wbem.CIMClass should be retrieved; if None, default namespace will be used (NOTE: see wbem)
  • LocalOnly (bool) – indicates, if only local members should be present in the returned wbem.CIMClass; any CIM elements (properties, methods, and qualifiers), except those added or overridden in the class as specified in the classname input parameter, shall not be included in the returned class.
  • IncludeQualifiers (bool) – indicates, if qualifiers for the class (including qualifiers on the class and on any returned properties, methods, or method parameters) shall be included in the response.
  • IncludeClassOrigin (bool) – indicates, if the CLASSORIGIN attribute shall be present on all appropriate elements in the returned class.
  • PropertyList (list) – if present and not None, the members of the list define one or more property names. The returned class shall not include elements for properties missing from this list. Note that if LocalOnly is specified as True, it acts as an additional filter on the set of properties returned. For example, if property A is included in the PropertyList but LocalOnly is set to True and A is not local to the requested class, it is not included in the response. If the PropertyList input parameter is an empty list, no properties are included in the response. If the PropertyList input parameter is None, no additional filtering is defined.
Returns:

LMIReturnValue object with rval set to wbem.CIMClass, if no error occurs; otherwise rval is set to None and errorstr to appropriate error string

Raises:

CIMError, ConnectionError

get_class_names(*args, **kwargs)[source]

Returns a list of class names.

Parameters:
  • namespace (string) – namespace, from which the class names list should be retrieved; if None, default namespace will be used (NOTE: see wbem)
  • ClassName (string) – defines the class that is the basis for the enumeration. If the ClassName input parameter is absent, this implies that the names of all classes.
  • DeepInheritance (bool) – if not present, of False, only the names of immediate child subclasses are returned, otherwise the names of all subclasses of the specified class should be returned.
Returns:

LMIReturnValue object with rval set to a list of strings containing class names, if no error occurs; otherwise rval is set to None and errorstr contains an appropriate error string

Raises:

CIMError, ConnectionError

get_instance(instance, LocalOnly=True, IncludeQualifiers=False, IncludeClassOrigin=False, PropertyList=None)[source]

Returns a wbem.CIMInstance object.

Parameters:
  • path

    path of the object, which is about to be retrieved. The object needs to be instance of following classes:

  • LocalOnly (bool) – indicates if to include the only elements (properties, methods, references) overridden or defined in the class
  • IncludeQualifiers (bool) – indicates, if all Qualifiers for the class and its elements shall be included in the response
  • IncludeClassOrigin (bool) – indicates, if the CLASSORIGIN attribute shall be present on all appropriate elements in the returned class
  • PropertyList (list) – if present and not None, the members of the list define one or more property names. The returned class shall not include elements for properties missing from this list. Note that if LocalOnly is specified as True, it acts as an additional filter on the set of properties returned. For example, if property A is included in the PropertyList but LocalOnly is set to True and A is not local to the requested class, it is not included in the response. If the PropertyList input parameter is an empty list, no properties are included in the response. If the PropertyList input parameter is None, no additional filtering is defined.
Returns:

LMIReturnValue object, where rval is set to wbem.CIMInstance object, if no error occurs; otherwise rval is set to None and errorstr is set to corresponding error string.

Raises:

CIMError, ConnectionError, TypeError

get_instance_names(classname, namespace=None, inst_filter=None, limit=-1, **kwargs)[source]

Returns a list of wbem.CIMInstanceName objects.

Parameters:
  • classname (string) – class name
  • namespace (string) – namespace name, where the instance names live
  • inst_filter (dictionary) – dictionary containing filter values. The key corresponds to the primary key of the wbem.CIMInstanceName; value contains the filtering value.
  • limit (int) – unused
  • kwargs (dictionary) –

    supported keyword arguments (these are deprecated)

    • Key or key (string) – filtering key, see above
    • Value or value (string) – filtering value, see above
Returns:

LMIReturnValue object with rval contains a list of wbem.CIMInstanceName objects, if no error occurs; otherwise rval is set to None and errorstr contains appropriate error string

Raises:

LMIFilterError, CIMError, ConnectionError

get_instances(classname, namespace=None, inst_filter=None, client_filtering=False, limit=-1, **kwargs)[source]

Returns a list of wbem.CIMInstance objects.

Parameters:
  • classname (string) – class name
  • namespace (string) – namespace, where the instances live
  • inst_filter (dictionary) – dictionary containing filter values. The key corresponds to the primary key of the wbem.CIMInstanceName; value contains the filtering value.
  • client_filtering (bool) – if True, client-side filtering will be performed, otherwise the filtering will be done by a CIMOM. Default value is False.
  • limit (int) – unused
  • kwargs (dictionary) –

    supported keyword arguments (these are deprecated)

    • Key or key (string) – filtering key, see above
    • Value or value (string) – filtering value, see above
Returns:

LMIReturnValue object with rval set to a list of wbem.CIMIntance objects, if no error occurs; otherwise rval is set to None and errorstr is set to corresponding error string.

Raises:

CIMError, ConnectionError

get_reference_names(*args, **kwargs)[source]

Returns a list of association wbem.CIMInstanceName objects with an input instance.

Parameters:
  • instance

    for this object the association wbem.CIMInstanceName objects will be returned. The object needs to be instance of following classes:

  • ResultClass (string) – valid CIM class name. It acts as a filter on the returned set of object names by mandating that each returned Object Name identify an instance of this class (or one of its subclasses) or this class (or one of its subclasses).
  • Role (string) – valid property name. It acts as a filter on the returned set of object names by mandating that each returned object name shall identify an object that refers to the target instance through a property with a name that matches the value of this parameter.
  • limit (int) – unused
Returns:

list of association wbem.CIMInstanceName objects with an input instance, if no error occurs; otherwise an empty list is returned

Raises:

CIMError, ConnectionError, TypeError

get_references(*args, **kwargs)[source]

Returns a list of association wbem.CIMInstance objects with an input instance.

Parameters:
  • instance

    for this object the list of association wbem.CIMInstance objects will be returned. The object needs to be instance of following classes:

  • ResultClass (string) – valid CIM class name. It acts as a filter on the returned set of objects by mandating that each returned object shall be an instance of this class (or one of its subclasses) or this class (or one of its subclasses).
  • Role (string) – valid property name. It acts as a filter on the returned set of objects by mandating that each returned object shall refer to the target object through a property with a name that matches the value of this parameter.
  • IncludeQualifiers (bool) – bool flag indicating, if all qualifiers for each object (including qualifiers on the object and on any returned properties) shall be included as <QUALIFIER> elements in the response.
  • IncludeClassOrigin (bool) – bool flag indicating, if the CLASSORIGIN attribute shall be present on all appropriate elements in each returned object.
  • PropertyList (list) – if not None, the members of the list define one or more property names. Each returned object shall not include elements for any properties missing from this list. If PropertyList is an empty list, no properties are included in each returned object. If PropertyList is None, no additional filtering is defined.
  • limit (int) – unused
Returns:

list of association wbem.CIMInstance objects with an input instance, if no error occurs; otherwise an empty list is returned

Raises:

CIMError, ConnectionError, TypeError

get_superclass(classname, namespace=None)[source]

Returns a superclass to given class.

Parameters:
  • classname (string) – class name
  • namespace (string) – namespace name
Returns:

superclass to given class, if such superclass exists, None otherwise

Raises:

CIMError, ConnectionError

hostname[source]
Returns:hostname of CIMOM
Return type:string
modify_instance(*args, **kwargs)[source]

Modifies a wbem.CIMInstance object at CIMOM side.

Parameters:
  • instance (wbem.CIMInstance) – object to be modified
  • IncludeQualifiers (bool) – indicates, if the qualifiers are modified as specified in ModifiedInstance.
  • PropertyList (list) – if not None, the members of the list define one or more property names. Only properties specified in the PropertyList are modified. Properties of the ModifiedInstance that are missing from the PropertyList are ignored. If the PropertyList is an empty list, no properties are modified. If the PropertyList is None, the set of properties to be modified consists of those of ModifiedInstance with values different from the current values in the instance to be modified.
Returns:

LMIReturnValue object with rval set to 0, if no error occurs; otherwise rval is set to -1 and errorstr is set to corresponding error string.

Raises:

CIMError, ConnectionError

uri[source]
Returns:URI of the CIMOM
Return type:string
username[source]
Returns:user name as a part of provided credentials
Return type:string