LMIConnection Package

class LMIConnection.LMIConnection(uri, username='', password='', **kwargs)[source]

Class representing a connection object. Each desired connection to separate CIMOM should have its own connection object created. This class provides an entry point to the namespace/classes/instances/methods hierarchy present in the LMIShell.

Parameters:
  • uri (string) – URI of the CIMOM
  • username (string) – account, under which, the CIM calls will be performed
  • password (string) – user’s password
  • interactive (bool) – flag indicating, if the LMIShell client is running in the interactive mode; default value is False.
  • use_cache (bool) – flag indicating, if the LMIShell client should use cache for CIMClass objects. This saves lot’s of communication, if there are EnumerateInstances() and EnumerateClasses() intrinsic methods often issued. Default value is True.
  • conn_type

    type of connection; can be of 2 values:

    • LMIBaseClient.CONN_TYPE_WBEM – WBEM connection,
    • LMIBaseClient.CONN_TYPE_PEGASUS_UDS – applicable only for Tog-Pegasus CIMOM, it uses Unix socket for the connection; default value is LMIBaseClient.CONN_TYPE_WBEM
  • key_file (string) – path to x509 key file; default value is None
  • cert_file (string) – path to x509 cert file; default value is None
  • verify_server_cert (bool) – flag indicating, whether a server side certificate needs to be verified, if SSL used; default value is True

NOTE: If interactive is set to True, LMIShell will:

clear_cache()[source]

Clears the cache.

get_namespace(namespace)[source]
Parameters:namespace (string) – namespace path (eg. root/cimv2)
Returns:LMINamespace object
Raises :LMINamespaceNotFound
namespaces[source]
Returns:list of all available namespaces

Usage: Available namespaces.

print_namespaces()[source]

Prints out all available namespaces.

print_subscribed_indications()[source]

Prints out all the subscribed indications.

root[source]
Returns:LMINamespaceRoot object for root namespace
subscribe_indication(**kwargs)[source]

Subscribes to an indication. Indication is formed by 3 objects, where 2 of them (filter and handler) can be provided, if the LMIShell should not create those 2 by itself.

NOTE: Currently the call registers atexit hook, which auto-deletes all subscribed indications by the LMIShell.

Parameters:kwargs (dictionary) –

parameters for the indication subscription

  • Filter (LMIInstance) – if provided, the LMIInstance object will be used instead of creating a new one; optional
  • Handler (LMIInstance) – if provided, the LMIInstance object will be used instead of creating a new one; optional
  • Query (string) – string containing a query for the indications filtering
  • QueryLanguage (string) – query language; eg. WQL, or DMTF:CQL
  • Name (string) – indication name
  • CreationNamespace (string) – creation namespace
  • SubscriptionCreationClassName (string) – subscription object class name
  • Permanent (bool) – whether to preserve the created subscription on LMIShell’s quit. Default value is False.
  • FilterCreationClassName (string) – creation class name of the filter object
  • FilterSystemCreationClassName (string) – system creation class name of the filter object
  • FilterSourceNamespace (string) – local namespace where the indications originate
  • HandlerCreationClassName (string) – creation class name of the handler object
  • HandlerSystemCreationClassName (string) – system creation name of the handler object
  • Destination (string) – destination URI, where the indications should be delivered
Returns:LMIReturnValue object with rval set to True, if indication was subscribed; False otherwise. If a error occurs, errorstr is set to appropriate error string.
subscribed_indications()[source]
Returns:list of all the subscribed indications
unsubscribe_all_indications()[source]

Unsubscribes all the indications. This call ignores Permanent flag, which may be provided in LMIConnection.subscribe_indication(), and deletes all the subscribed indications.

unsubscribe_indication(name)[source]

Unsubscribes an indication.

Parameters:name (string) – indication name
Returns:LMIReturnValue object with rval set to True, if unsubscribed; False otherwise
uri[source]
Returns:URI of the CIMOM
Return type:string
use_cache(active=True)[source]

Sets a bool flag, which defines, if the LMIShell should use a cache.

Parameters:active (bool) – whether the LMIShell’s cache should be used
verify_credentials()[source]

Verifies credentials by performing a “dummy” GetClass() call on “SomeNonExistingClass”. Provided credentials are OK, if the LMIShell obtains pywbem.CIMError exception with the flag CIM_ERR_NOT_FOUND set. Otherwise, the should receive pywbem.AuthError.

Returns:True if provided credentials are OK; False otherwise
LMIConnection.connect(uri, username='', password='', **kwargs)[source]

Creates a connection object with provided URI and credentials.

Parameters:
  • uri (string) – URI of the CIMOM
  • username (string) – account, under which, the CIM calls will be performed
  • password (string) – user’s password
  • interactive (bool) – flag indicating, if the LMIShell client is running in the interactive mode; default value is False.
  • use_cache (bool) – flag indicating, if the LMIShell client should use cache for CIMClass objects. This saves lot’s of communication, if there are EnumerateInstances() and EnumerateClasses() intrinsic methods often issued. 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
  • verify_server_cert (bool) – flag indicating, whether a server side certificate needs to be verified, if SSL used; default value is True.
  • prompt_prefix (string) – username and password prompt prefix in case the user is asked for credentials. Default value is empty string.
Returns:

LMIConnection object or None, if LMIShell does not use exceptions

Raises :

pywbem.AuthError

NOTE: If interactive is set to True, LMIShell will:

Usage: Establish a connection.

This Page