LMIUtil Package

class LMIUtil.LMIPassByRef(val)[source]

Helper class used for passing a value by reference. It uses the advantage of python, where all the dictionaries are passed by reference.

Parameters:val – value, which will be passed by reference

Example of usage:

by_ref = LMIPassByRef(some_value)
by_ref.value == some_value
value[source]
Returns:value passed by reference.
class LMIUtil.LMIUseExceptionsHelper[source]

Singleton helper class used for storing a bool flag, which defines, if the LMIShell should propagate exceptions or dump them.

use_exceptions[source]
Returns:whether the LMIShell should propagate the exceptions, or throw them away
Return type:bool
LMIUtil.lmi_associators(assoc_classes)[source]

Helper function to speed up associator traversal. Returns a list of tuples, where each tuple contains LMIInstance objects, which are in association.

Parameters:assoc_classes (list) – list of LMIClass objects, for which the associations will be returned
Returns:list of tuples of LMIInstance objects in association
LMIUtil.lmi_cast_to_cim(t, value)[source]

Casts the value to CIM type.

Parameters:
  • t (string) – string of CIM type
  • value – variable to cast
Returns:

cast value in pywbem type

LMIUtil.lmi_cast_to_lmi(t, value)[source]

Casts the value to LMI (python) type.

Parameters:
  • t (string) – string of CIM type
  • value – variable to cast
Returns:

cast value in python native type

LMIUtil.lmi_get_use_exceptions()[source]
Returns:whether the LMIShell should use the exceptions, or throw them away
Return type:bool
LMIUtil.lmi_isinstance(lmi_obj, lmi_class)[source]

Function returns True if lmi_obj is an instance of a lmi_class, False otherwise. When passed LMIInstance, LMIInstanceName as lmi_obj and lmi_class is of LMIClass type, function can tell, if such lmi_obj is direct instance of LMIClass, or it’s super class.

If lmi_obj and lmi_class is not instance of mentioned classes, an exception will be raised.

Parameters:
Returns:

whether lmi_obj is instance of lmi_class

Return type:

bool

Raises :

TypeError

LMIUtil.lmi_raise_or_dump_exception(e=None)[source]

Function which either raises an exception, or throws it away.

Parameters:e (Exception) – exception, which will be either raised or thrown away
LMIUtil.lmi_script_name()[source]
Returns:script name
Return type:string
LMIUtil.lmi_set_use_exceptions(use=True)[source]

Sets a global flag indicating, if the LMIShell should use the exceptions, or throw them away.

Parameters:use (bool) – specifies, whether the LMIShell should use the exceptions
LMIUtil.lmi_transform_to_cim_param(t, value)[source]

Helper function for method calls, which transforms input object into CIMInstanceName object. Members if lists, dictionaries and tuples are transformed as well. The function does not cast numeric types.

Parameters:
  • t (string) – string of CIM type
  • value – object to be transformed to pywbem type.
Returns:

transformed LMIShell’s object into pywbem one

LMIUtil.lmi_transform_to_lmi(conn, value)[source]

Transforms returned values from a method call into LMI wrapped objects. Returns transformed input, where CIMInstance and CIMInstanceName are wrapped into LMI wrapper classes and primitive types are cast to python native types.

Parameters:
  • conn (LMIConnection) – connection object
  • value – object to be transformed into python type from pywbem one
Returns:

transformed py:pywbem object into LMIShell one

LMIUtil.lmi_wrap_cim_class(conn, cim_class_name, cim_namespace_name)[source]

Helper function, which returns wrapped CIMClass into LMIClass.

Parameters:
  • conn (LMIConnection) – connection object
  • cim_class_name (string) – string containing CIMClass name
  • cim_namespace_name (string) – string containing CIMNamespace name, or None, if the namespace is not known
Returns:

wrapped CIMClass into LMIClass

LMIUtil.lmi_wrap_cim_instance(conn, cim_instance, cim_class_name, cim_namespace_name)[source]

Helper function, which returns wrapped CIMInstance into LMIInstance.

Parameters:
  • conn (LMIConnection) – connection object
  • cim_instance (CIMInstance) – CIMInstance object to be wrapped
  • cim_class_name (string) – CIMClass name
  • cim_namespace_name (string) – CIMNamespace name, or None, if the namespace is not known
Returns:

wrapped CIMInstance into LMIInstance

LMIUtil.lmi_wrap_cim_instance_name(conn, cim_instance_name)[source]

Helper function, which returns wrapped CIMInstanceName into LMIInstanceName.

Parameters:
  • conn (LMIConnection) – connection object
  • cim_instance_name (CIMInstanceName) – CIMInstanceName object to be wrapped
Returns:

wrapped CIMInstanceName into LMIInstanceName

LMIUtil.lmi_wrap_cim_method(conn, cim_method_name, lmi_instance, sync_method)[source]

Helper function, which returns wrapped CIMMethod into LMIMethod.

Parameters:
  • conn (LMIConnection) – connection object
  • cim_method_name (string) – method name
  • lmi_instance (LMIInstance) – object, on which the method call will be issued
  • sync_method (bool) – flag indicating, if we are trying to perform a synchronous method call
Returns:

wrapped CIMMethod into LMIMethod

LMIUtil.lmi_wrap_cim_namespace(conn, cim_namespace_name)[source]

Helper function, which returns wrapped CIM namespace in LMINamespace.

Parameters:
  • conn (LMIConnection) – connection object
  • cim_namespace_name (string) – CIM namespace name
Returns:

wrapped CIM namespace into LMINamespace

This Page