12. Appendix

This section contains information that is referenced from other sections, and that does not really need to be read in sequence.

12.1. Special type names

This documentation uses a few special terms to refer to Python types:

string

a unicode string or a byte string

unicode string

a Unicode string type (unicode in Python 2, and str in Python 3)

byte string

a byte string type (str in Python 2, and bytes in Python 3). Unless otherwise indicated, byte strings in pywbem are always UTF-8 encoded.

connection id

a string (string) that uniquely identifies each pywbem.WBEMConnection object created. The connection id is immutable and is accessible from pywbem.WBEMConnection.conn_id. It is included in of each log record created for pywbem log output and may be used to correlate pywbem log records for a single connection.

number

one of the number types int, long (Python 2 only), or float.

integer

one of the integer types int or long (Python 2 only).

callable

a callable object; for example a function, a class (calling it returns a new object of the class), or an object with a __call__() method.

hashable

a hashable object. Hashability requires an object not only to be able to produce a hash value with the hash() function, but in addition that objects that are equal (as per the == operator) produce equal hash values, and that the produced hash value remains unchanged across the lifetime of the object. See term “hashable” in the Python glossary, although the definition there is not very crisp. A more exhaustive discussion of these requirements is in “What happens when you mess with hashing in Python” by Aaron Meurer.

unchanged-hashable

an object that is hashable with the exception that its hash value may change over the lifetime of the object. Therefore, it is hashable only for periods in which its hash value remains unchanged. CIM objects are examples of unchanged-hashable objects in pywbem.

DeprecationWarning

a standard Python warning that indicates a deprecated functionality. See section Deprecation and compatibility policy and the standard Python module warnings for details.

Element

class xml.dom.minidom.Element. Its methods are described in section Element Objects of module xml.dom, with minidom specifics described in section DOM Objects of module xml.dom.minidom.

CIM data type

one of the types listed in CIM data types.

CIM object

one of the types listed in CIM objects.

CIM namespace

an object that is accessible through a WBEM server and is a naming space for CIM classes, CIM instances and CIM qualifier declarations. The namespace is a component of other elements like namespace path used to access objects in the WBEM server.

NocaseList

A case-insensitive list class provided by the nocaselist package.

interop namespace

A CIM namespace is the interop namespace if it has one of the following names: DMTF definition; (‘interop’, ‘root/interop’) pywbem implementation; (‘interop’, ‘root/interop’, ‘root/PG_Interop’), Only one interop namespace is allowed in a WBEM Server. The interop namespace contains CIM classes that the client needs to discover characteristics of the WBEM server (namespaces, coniguration of server components like indications) and the registered profiles implemented by that server.

keybindings input object

a Python object used as input for initializing an ordered list of keybindings in a parent object (i.e. a CIMInstanceName object).

None will result in an an empty list of keybindings.

Otherwise, the type of the input object must be one of:

  • iterable of CIMProperty

  • iterable of tuple(key, value)

  • OrderedDict with key and value

  • dict with key and value (will not preserve order)

with the following definitions for key and value:

  • key (string): Keybinding name.

    Must not be None.

    The lexical case of the string is preserved. Object comparison and hash value calculation are performed case-insensitively.

  • value (CIM data type or number or CIMProperty): Keybinding value.

    If specified as CIM data type or number, the provided object will be stored unchanged as the keybinding value.

    If specified as a CIMProperty object, its name attribute must match the key (case insensitively), and a copy of its value (a CIM data type) will be stored as the keybinding value.

    None for the keybinding value will be stored unchanged.

    If the WBEM server requires the TYPE attribute on KEYVALUE elements to be set in operation requests, this can be achieved by specifying the keybinding value as CIM data type (either directly, or via a CIMProperty object).

The order of keybindings in the parent object is preserved if the input object is an iterable or a OrderedDict object, but not when it is a dict object.

The resulting set of keybindings in the parent object is independent of the input object (except for unmutable objects), so that subsequent modifications of the input object by the caller do not affect the parent object.

methods input object

a Python object used as input for initializing an ordered list of methods represented as CIMMethod objects in a parent object that is a CIMClass.

None will result in an an empty list of methods.

Otherwise, the type of the input object must be one of:

  • iterable of CIMMethod

  • iterable of tuple(key, value)

  • OrderedDict with key and value

  • dict with key and value (will not preserve order)

with the following definitions for key and value:

  • key (string): Method name.

    Must not be None.

    The lexical case of the string is preserved. Object comparison and hash value calculation are performed case-insensitively.

  • value (CIMMethod): Method declaration.

    Must not be None.

    The name attribute of the CIMMethod object must match the key (case insensitively).

    The provided object is stored in the parent object without making a copy of it.

The order of methods in the parent object is preserved if the input object is an iterable or a OrderedDict object, but not when it is a dict object.

The resulting set of methods in the parent object is independent of the input collection object, but consists of the same CIMMethod objects that were provided in the input collection. Therefore, a caller must be careful to not accidentally modify the provided CIMMethod objects.

parameters input object

a Python object used as input for initializing an ordered list of parameters represented as CIMParameter objects in a parent object that is a CIMMethod.

None will result in an an empty list of parameters.

Otherwise, the type of the input object must be one of:

  • iterable of CIMParameter

  • iterable of tuple(key, value)

  • OrderedDict with key and value

  • dict with key and value (will not preserve order)

with the following definitions for key and value:

  • key (string): Parameter name.

    Must not be None.

    The lexical case of the string is preserved. Object comparison and hash value calculation are performed case-insensitively.

  • value (CIMParameter): Parameter (declaration).

    Must not be None.

    The name attribute of the CIMParameter object must match the key (case insensitively).

    The provided object is stored in the parent object without making a copy of it.

The order of parameters in the parent object is preserved if the input object is an iterable or a OrderedDict object, but not when it is a dict object.

The resulting set of parameters in the parent object is independent of the input collection object, but consists of the same CIMParameter objects that were provided in the input collection. Therefore, a caller must be careful to not accidentally modify the provided CIMParameter objects.

properties input object

a Python object used as input for initializing an ordered list of properties represented as CIMProperty objects, in a parent object.

The CIMProperty objects represent property values when the parent object is a CIMInstance, and property declarations when the parent object is a CIMClass.

None will result in an an empty list of properties.

Otherwise, the type of the input object must be one of:

  • iterable of CIMProperty

  • iterable of tuple(key, value)

  • OrderedDict with key and value

  • dict with key and value (will not preserve order)

with the following definitions for key and value:

  • key (string): Property name.

    Must not be None.

    The lexical case of the string is preserved. Object comparison and hash value calculation are performed case-insensitively.

  • value (CIM data type or CIMProperty): Property (value or declaration).

    Must not be None.

    CIMProperty objects can be used as input for both property values and property declarations. CIM data type objects can only be used for property values.

    If specified as a CIM data type, a new CIMProperty object will be created from the provided value, inferring its CIM data type from the provided value.

    If specified as a CIMProperty object, its name attribute must match the key (case insensitively), and the provided object is stored in the parent object without making a copy of it.

The order of properties in the parent object is preserved if the input object is an iterable or a OrderedDict object, but not when it is a dict object.

The resulting set of properties in the parent object is independent of the input collection object, but consists of the same CIMProperty objects that were provided in the input collection. Therefore, a caller must be careful to not accidentally modify the provided CIMProperty objects.

provider

An element of a WBEM server that responds to requests for selected classes. A WBEM server normally contains a main provider that may interface with a CIM respository and provides responses to client requests for which no specific provider is defined and providers which providers that allow specialized responses for selected classes and request types (communicate with managed components) or manipulate the objects being managed.

NOTE: In the SNIA terminology, a provider may also be a complete WBEM server implementation.

user-defined provider

A :term:provider that can be defined independently of the WBEM server and attached dynamically to the WBEM server. In pywbem, user-defined providers can be defined as subclasses of specific default provider types and attached to the server by registering them with the connection.

qualifiers input object

a Python object used as input for initializing an ordered list of qualifiers represented as CIMQualifier objects in a parent object (e.g. in a CIMClass object).

None will result in an an empty list of qualifiers.

Otherwise, the type of the input object must be one of:

  • iterable of CIMQualifier

  • iterable of tuple(key, value)

  • OrderedDict with key and value

  • dict with key and value (will not preserve order)

with the following definitions for key and value:

  • key (string): Qualifier name.

    Must not be None.

    The lexical case of the string is preserved. Object comparison and hash value calculation are performed case-insensitively.

  • value (CIM data type or CIMQualifier): Qualifier (value).

    Must not be None.

    If specified as a CIM data type, a new CIMQualifier object will be created from the provided value, inferring its CIM data type from the provided value.

    If specified as a CIMQualifier object, its name attribute must match the key (case insensitively), and the provided object is stored in the parent object without making a copy of it.

The order of qualifiers in the parent object is preserved if the input object is an iterable or a OrderedDict object, but not when it is a dict object.

The resulting set of qualifiers in the parent object is independent of the input collection object, but consists of the same CIMQualifier objects that were provided in the input collection. Therefore, a caller must be careful to not accidentally modify the provided CIMQualifier objects.

12.2. Profile advertisement methodologies

This section briefly explains the profile advertisement methodologies defined by DMTF. A full description can be found in DSP1033.

These methodologies describe how a client can discover the central instances of a management profile. Discovering the central instances through a management profile is the recommended approach for clients, over simply enumerating a CIM class of choice. The reason is that this approach enables clients to work seamlessly with different server implementations, even when they have implemented a different set of management profiles.

DMTF defines three profile advertisement methodologies in DSP1033:

  • GetCentralInstances methodology (new in DSP1033 1.1)

  • Central class methodology

  • Scoping class methodology

At this point, the GetCentralInstances methodology has not widely been implemented, but pywbem supports it nevertheless.

All three profile advertisement methodologies start from the CIM_RegisteredProfile instance that identifies the management profile, by means of registered organisation, registered name, and registered version.

It is important to understand that the CIM_RegisteredProfile instance not only identifies the management profile, but represents a particular use of the management profile within its scoping profiles. For an autonomous profile, there are no scoping profiles, so in that case, there is only one use of the autonomous profile in a server. However, component profiles do have scoping profiles, and it is well possible that a component profile is used multiple times in a server, in different scoping contexts. If that is the case, and if discovery of central instances using any of the profile advertisement methodologies is supposed to work, then each such use of the profile needs to have its own separate CIM_RegisteredProfile instance, because each such use of the profile will also have its own separate set of central instances.

Unfortunately, neither the DMTF standards nor the SMI-S standards are clear about that requirement, and so there are plenty of implementations that share a single CIM_RegisteredProfile instance identifying a particular component profile, for multiple distinct uses of the profile by its scoping profiles. In such a case, the profile advertisement methodologies will not be able to distinguish the distinct sets of central instances alone, and other means need to be used to distinguish them.

It is also important to understand that the choice which profile advertisement methodology to implement, is done by the WBEM server side. Therefore, a WBEM client such as pywbem needs to support all methodologies and needs to try them one by one until one succeeds. Pywbem tries the three methodologies in the order listed above.

In the GetCentralInstances methodology, the CIM_RegisteredProfile instance has a CIM method named GetCentralInstances that returns the instance paths of the central instances of the use of the profile.

In the central class methodology, the CIM_RegisteredProfile instance is associated directly with the set of central instances of the use of the profile, via a CIM_ElementConformsToProfile association.

In the scoping class methodology, the CIM_RegisteredProfile instance is not associated directly with the set of central instances of the use of the profile, but delegates that to its scoping profile. The client navigates up to the CIM_RegisteredProfile instance representing the (use of the) scoping profile, looks up its central instances, and from each of those, navigates down along the reversed scoping path to the central instances of the profile in question. The scoping path of a component profile describes the traversal across associations and ordinary classes from the central class to the scoping class of the profile. This profile advertisement methodology is obviously the most complex one of the three.

Pywbem encapsulates the complexity and choice of these methodologies into a single invocation of an easy-to use method get_central_instances().

Profile implementations in a WBEM server are not entirely free when making a choice of which methodology to implement:

  • Autonomous profiles in a WBEM server must implement the central class methodology, and may in addition implement the new GetCentralInstances methodology.

    Note that the scoping class methodology falls together with the central class methodology for autonomous profiles, because their scoping class is also their central class.

  • Component profiles in a WBEM server may implement the central class methodology and the new GetCentralInstances methodology, and must support the scoping class methodology.

    Note that implementing the scoping class methodology in a WBEM server requires implementing the classes and associations of the scoping path, which are usually mandatory anyway. So while the scoping class methodology is more complex to use for clients than the central class methodology, it is easier to implement for servers.

Use of the scoping class methodology by a client requires knowing the central class, scoping class and scoping path defined by the component profile.

DSP1001 requires that conformant autonomous profiles specify a central class, and that conformant component profiles specify a central class, scoping class and a scoping path.

Older DMTF component profiles and older SNIA subprofiles do not always specify scoping class and scoping path. In such cases, the scoping class and scoping path can often be determined from the class diagram in the specification for the profile. Many times, CIM_System or CIM_ComputerSystem is the scoping class.

12.3. Troubleshooting

This section describes some trouble shooting hints for the installation and execution of pywbem.

12.3.1. Installation fails with “invalid command ‘bdist_wheel’”

The installation of some Python packages requires the Python “wheel” package. If that package is not installed in the current Python environment, the installation will fail with the following (or similar) symptom:

python setup.py bdist_wheel
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'

To fix this, install the Python “wheel” package:

pip install wheel

12.3.2. Issues with pywbem verson 1.7+, Urllib3 package version 2, and SSL

12.3.2.1. Overview of the changes and issues

Pywbem version 1.7 expanded the urllib3 package version requirement to include urllib3 version >= 2.0. Note that urllib3 version 2.0 was allowed with previous version of pywbem only because the package version requirements did not pin urllib version to < 2.0.

The urlib3 package version requirements in requirements.txt are:

urllib3>=1.26.18; python_version >= '3.7'  (pywbem 1.7.0)

previously:

urllib3>=1.26.18,<2.0.0; python_version >= '3.7' (pywbem 1.6.x)

The urllib3 Python package version 2.0 made a significant number of changes including the following list that can be potentially non-compatible:

  • Urllib3 >= 2.0 limits the minimum OpenSSL version >= 1.1.1. Note that Python 3.10 also limits the minimum OpenSSL version >= 1.1.1.

  • Urllib3 >= 2.0 changes the default minimum TLS version to TLS 1.2 (previously was TLS 1.0), the default minimum defined for OpenSSL 1.1.1.

  • Urllib3 >= 2.0 removed support for LibreSSL, WolfSSL and other non OpenSSL implementations. Multiple operating systems including: macOS and BSD use LibreSSL as the TLS/SSL implementation. LibreSSL support however, was restored to urllib3 in version 2.0.3.

  • Urllib3 >= 2.0 changed the minimum version for Python to Python 3.7.

  • Urllib3 >= 2.0 removed the default set of TLS ciphers, instead now urllib3 uses the list of ciphers configured by the system.

This means that pywbem exceptions can occur during installation, update of pywbem or the underlying platform because:

  • Level of minimum TLS protocol support depends on the Python Version and the SSL implementation version.

  • SSL compatibility issues can happen with new pywbem installations on some platforms or updates to the OS platforms or to pywbem.

Pywbem uses the requests dependent package which uses the urllib3 package which uses the Python openssl module to communicate with OpenSSL; neither pywbem nor the requests package pins the urllib3 package to versions below version 2.0. This is a function of the SSL implementation and urllib3 package version.

Python version 3.10+ already requires OpenSSL version 1.1.1 or higher independent of the use of urllib3 version 2.0+ and pywbem version 1.6 allowed urllib3 version 2.0+ simply because it was released before that urllib3 version was released.

Because of this pywbem change to allow urllib3 >= 2.0, Warnings, Exceptions, etc. can occur in the process of:

  • pywbem package installation

  • pywbem package update ( ie. updating urllib3)

  • Update to use a different version of Python, ex. Python 3.6 to a newer Python version

  • OS update which changes the SSL implementation version

  • Pywbem attempting to communicate with a WBEM server where the server may not implement the new TLS version requirement.

The following documents present more information on this change to urllib3 and the issues and possible corrections:

The current version and implementation of the SSL library can be determined as follows:

$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.1.1  7 Feb 2023

or:

$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
LibreSSL 2.8.3

OpenSSL version can be directly determined from OpenSSL as follows:

$ openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

The current urllib3 installed version can be determined with pip:

$ pip list | grep urllib3
urllib3                       2.2.1

The server TLS version can be verified with the OpenSSL CLI tool:

openssl s_client -connect localhost:15989 -XXXX

where: XXXX is tls1_1, tls1_2
and a certificate is returned if the corresponding TLS version is valid.

The following subsections define specific issues that can occur with this change and proposed solutions.

12.3.2.2. NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+

This issue may be caused by the urllib3 package update to version 2.0 in pywbem version 1.7.0. In this case it is probably that the local environment includes a version of OpenSSL less than 1.1.1 The best options is to reinstall urllib3 < 2.0

12.3.2.3. ConnectionError raised with [SSL] EC lib

Using pywbem on Python 3.5 with OpenSSL 1.0.1e-fips against an IBM DS8000 raised the following exception:

pywbem.exceptions.ConnectionError: SSL error <class 'ssl.SSLError'>:
  [SSL] EC lib (_ssl.c:728)

This error indicates that OpenSSL on the client side cannot deal with the cipher used by the server side. This was fixed by upgrading OpenSSL on the client OS to version 1.1.1.

12.3.2.4. ConnectionError raised with [SSL: UNSUPPORTED_PROTOCOL]

On newer versions of the operating system running the pywbem client, communication with the WBEM server may fail with:

pywbem.exceptions.ConnectionError: SSL error <class 'ssl.SSLError'>:
  [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1056)

This error indicates that OpenSSL and the WBEM server do not agree about which SSL/TLS protocol level to use.

In pywbem version 1.7.0 the urllib3 configuration version limit was modified to allow urllib3 versions >= 2.0. These versions of urllib3 limit the minimum TLS version to 1.2 (i.e OpenSSL version >= 1.1.1). If the version of OpenSSL is less than 1.1.1, this SSLError will occur with the initial request to the WBEM Server. Urllib3 version <= 2.0 also limits the SSL library implementations to just OpenSSL and possibly LibreSSL.

This can also happened after an upgrade of the client OS to Debian buster using Python 3.7, with OpenSSL 1.1.1d. Debian buster includes OpenSSL 1.1.1d and increased its security settings to require at least TLS 1.2 (see https://stackoverflow.com/a/53065682/1424462).

Pywbem specifies SSL parameters such that the highest SSL/TLS protocol version is used that both the client and server support. Pywbem does not put any additional SSL restrictions on top of Python or the SSL libraries.

This error means that the WBEM server side does not yet support TLS 1.2 or higher or that the SSL library used by pywbem does not support TLS 1.2.

This issue can be corrected by:

  1. If the current version of urllib3 is less than 2.0, update the version of urllib3 (ex. pip install --upgrade  --upgrade-strategy eager urllib3). Since the pywbem install does not force an eager update of packages, if a valid previous version of urllib3 exists it will not be upgraded to 2.0+ in the re-installation of pywbem.

  2. If the current version of urllib3 is greater than 2.0, the previous version of urllib3 (ex. version 1.26.5) can be installed with, for example:

    $ pip install urllib3 < 2.0
    
  3. Adding TLS 1.2 support to the WBEM server side (preferred) or owering the minimum TLS level OpenSSL requires on the client side (which lowers security). The latter can be done with OpenSSL by changing the MinProtocol parameter in the OpenSSL config file on the client OS (typically /etc/ssl/openssl.cnf on Linux and OS-X, and C:\OpenSSL-Win64\openssl.cnf on Windows).

    At the end of the file set:

    [system_default_sect]
    MinProtocol = TLSv1.2
    CipherString = DEFAULT@SECLEVEL=2
    

12.3.2.5. ImportError urllib3 v2.0 only supports OpenSSL 1.1.1+

Upgrading Python packages, with a Python that does not support OpenSSL 1.1.1 or higher or other SSL implementations, causes an ImportError exception raised by urllib3 such as:

ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the ‘ssl’ module is compiled with LibreSSL 2.8.3. See: https://github.com/urllib3/urllib3/issues/2168

This can happen for example on macOS with the system Python of macOS as the basis for a Python virtual environment and installing pywbem into that virtual environment, which typically installs the latest available versions of dependent packages, and thus may install urllib3 with a version 2.0 or later.

The ImportError exception message shows the name and version of the underlying SSL library the Python ‘ssl’ module is using. On most Python systems, that is a statically linked SSL library, so just installing OpenSSL 1.1.1 or higher does not address the issue.

At least up to macOS Ventura, Apple compiles the system Python with LibreSSL. As long as that does not change, you cannot use the system Python of macOS with urllib3>=2.0; also not as a basis for Python virtual environments.

There are basically two options on how this issue can be addressed:

  • Use a Python version that uses OpenSSL 1.1.1 or higher. That is the case for the CPython reference implementation version 3.7 or higher. CPython can either be downloaded from https://www.python.org/downloads/macos/ or installed using a third party package installer for macOS, such as Homebrew.

  • Pin the urllib3 package to stay below version 2.0 when on Python 3.7 or higher, by specifying in the package dependencies, e.g. in the requirements.txt file:

    urllib3>=1.26.5,<2.0; python_version >= '3.7'
    

    The minimum version of urllib3 should be at least what the minimum-constraints-install.txt file of the ‘pywbem’ project specifies as a minimum, for the ‘pywbem’ version.

    Note that pinning a dependent package prevents installing security fixes, which is important for a network related package such as urllib3, so this option should not be the preferred one.

12.3.3. Install fails, Externally-managed-environment error

This error is caused by the OS distribution adopting the changes defined by Python PEP 668 (Marking Python base environments as “externally managed”) which sets configuration information so that pip (version 23.0+) will only install packages that are not part of the OS distibution into virtual environments and will not install them into any of the system Python directories. This forces the separation of user packages from OS distribution installed packages.

On newer versions of some operating systems (Ex. Ubuntu 23.04, Debian 12, etc.) installed from the OS distribution, you may get an error message such as the following which indicates that pip refused to install a package:

.. code-block:: text

error: externally-managed-environment × This environment is externally managed … …

The best solution to this issue is to always install pywbem into a virtual environment as recommended in the pywbem Installation documentation.

There are alernatives to allow installation of pywbem into the system Python directories if required including:

  • Create or modify a pip configuration file to include the statement:

    [global]
    break-system-packages = true
    
  • Set an environment variable BREAK_SYSTEM_PACKAGES before installing pywbem since environment variables can be used to define pip command line options.

  • Remove the flag file that pip uses to enable the limiting behavior. See Python PEP 668 (“Marking Python base environments as “externally managed”) which would be most logical in the case of installation into a container such as Docker.

See pywbem issue 3080 for more information about this issue.

12.3.4. Losing indications when sent from OpenPegasus server

If there is a case where the pywbem listener appears to be losing indications sent from at least the OpenPegasus server, this may be due to timeout/retry settings issues between the WBEM server and pywbem listener.

OpenPegasus has two configuration settings that can impact sending indications:

  1. maxIndicationDeliveryRetryAttempts (Default 3 retries)

    If set to a positive integer, value defines the number of times indication service will enable the reliableIndication feature and try to deliver an indication to a particular listener destination. This does not effect the original delivery attempt. A value of 0 disables reliable indication feature completely, and cimserver will attempt deliver the indication once and then discard it.

  2. minIndicationDeliveryRetryInterval (Default: 30 seconds).

    If set to a positive integer, this value defines the minimal time interval in seconds for the indication service to wait before retrying to deliver an indication to a listener destination that previously failed. Cimserver may take longer due to QoS or other processing.

Together these configuration variables try to insure that indications will be delivered. If there is an issue sending any single indication it is put into a delay queue for the destination along with any suceeding indications that are created for the same destination. After the timeout defined by the configuration variable minIndicationDeliveryRetryInterval, OpenPegasus attempts to send the indication again. It repeats this process the number of times determined by the maxIndicationDeliveryRetryAttempts configuration variable.

Thus, as a default after receiving anything but a successful response from the listener OpenPegasus waits 30 seconds and retries. It repeats this process 3 times before discarding the indication.

As noted in pywbem issue https://github.com/pywbem/pywbem/issues/3022 tests with OpenPegasus under high indication loading have indicated that occasionally the WBEM server receives a zero length response immediately after sending the indication. This is treated as an error and the retry process is started. If any timeouts or time checks in the listener, (ex. very short times in tests between received indications) these timeouts could be interpreted as lost indications when, in fact, OpenPegasus will wait 30 seconds and then retry the indication that the server thought had failed.

This was the case with testing against local OpenPegasus Docker containers where the WBEM server was requested to deliver a fixed number of indications as fast as possible but the test listener set a timeout of 3 seonds with no indication received to indicate that the delivery has stopped before all requested indications had been delivered. However the delay was simply waiting 30 seconds delay before resending the failed indications. Setting the OpenPegasus WBEM server to different timeout times can correct this problem (ex. delay 2 seconds, retry attempts 5 for local testing).

The OpenPegasus configuration variables can be set with the OpenPegasus cimconfig command line utility either when the server is running or stopped.

See the OpenPegasus documenation or OpenPegasus cimconfig --help for detailed information on the command parameters for setting these configuation variables.

12.4. Base classes

Some bases classes are included in this documentation in order to provide the descriptions for inherited methods and properties that are referenced from the summary tables in other class descriptions.

class pywbem._exceptions._RequestExceptionMixin(*args, **kwargs)[source]

An internal mixin class for pywbem specific exceptions that provides the ability to store the CIM-XML request string in the exception.

New in pywbem 1.0.

Derived classes using this mixin class need to specify it before the base error class.

Parameters:
  • *args – Any other positional arguments are passed on to the next superclass.

  • **kwargs – Any other keyword arguments are passed on to the next superclass.

  • request_data (string) – CIM-XML request string. Omitted or None means the exception does not store a CIM-XML request. Must be specified as a keyword argument; if specified it will be removed from the keyword arguments that are passed on.

Attributes:

request_data

CIM-XML request string (settable).

property request_data

CIM-XML request string (settable). None if the exception does not store a CIM-XML request.

Type:

string

class pywbem._exceptions._ResponseExceptionMixin(*args, **kwargs)[source]

Mixin class into pywbem specific exceptions that provides the ability to store the CIM-XML response string in the exception.

New in pywbem 1.0.

Derived classes using this mixin class need to specify it before the base error class.

Parameters:
  • *args – Any other positional arguments are passed on to the next superclass.

  • **kwargs – Any other keyword arguments are passed on to the next superclass.

  • response_data (string) – CIM-XML response string. Omitted or None means the exception does not store a CIM-XML response. Must be specified as a keyword argument; if specified it will be removed from the keyword arguments that are passed on.

Attributes:

response_data

CIM-XML response string (settable).

property response_data

CIM-XML response string (settable). None if the exception does not store a CIM-XML response.

Type:

string

class pywbem._cim_types._CIMComparisonMixin[source]

Mixin class providing default implementations for equality test operators and hash function.

The implementations of ordering tests are also provided and raise an exception because ordering of CIM objects is not supported.

Methods:

__eq__(other)

Equality test for two CIM objects.

__hash__()

Interface definition for hash function to be provided by subclasses.

__ne__(other)

Non-equality test for two CIM objects.

__eq__(other)[source]

Equality test for two CIM objects.

The comparison must be implemented in the derived class.

__hash__()[source]

Interface definition for hash function to be provided by subclasses.

Background: In order to behave as expected in sets and other hash-based collections, the hash values of objects must be equal when the objects themselves are considered equal. The default hash function for classes is based on id() and therefore does not satisfy that requirement.

Therefore, the CIM objects need to implement a hash function that satisfies that requirement.

__ne__(other)[source]

Non-equality test for two CIM objects.

The comparison is delegated to the __eq__() method, because we require it to be implemented. See https://stackoverflow.com/a/30676267/1424462 for discussion about delegating to == vs. __eq__().

class pywbem_mock.BaseRepository[source]

An abstract base class defining the required APIs to provide access to a a CIM repository.

New in pywbem 1.0 as experimental and finalized in 1.2.

The API provides functions to:

  1. Manage CIM namespaces in the data repository including creation, deletion and getting a list of the existing namespaces.

  2. Access the object store for each CIM object type in the repository for the objects of the following CIM types: (CIMClass, CIMInstance, and CIMQualifierDeclaration) so that methods of the BaseObjectStore are used to access and manipulate CIM objects of a single CIM type by namespace in the repository.

Methods:

add_namespace(namespace)

Add a CIM namespace to the repository.

get_class_store(namespace)

Return the CIM class object store for the namespace provided.

get_instance_store(namespace)

Return the CIM instance object store for the namespace provided.

get_qualifier_store(namespace)

Return the CIM qualifier declaration object store for the namespace provided.

remove_namespace(namespace)

Remove a CIM namespace from the repository.

validate_namespace(namespace)

Validate if the namespace exists in the repository.

Attributes:

namespaces

NocaseList of string: The names of the namespaces that exist in this CIM repository.

abstract add_namespace(namespace)[source]

Add a CIM namespace to the repository.

The namespace must not yet exist in the CIM repository.

Parameters:

namespace (string) – The name of the CIM namespace in the CIM repository. The name is treated case insensitively and it must not be None. Any leading and trailing slash characters in the namespace string are ignored when accessing the repository.

Raises:

ValueError – If the namespace argument is None or the namespace already exists.

abstract get_class_store(namespace)[source]

Return the CIM class object store for the namespace provided.

Parameters:

namespace (string) – The name of the CIM namespace in the CIM repository. The name is treated case insensitively and it must not be None. Any leading and trailing slash characters in the namespace string are ignored when accessing the repository.

Returns:

CIM class object store for the namespace provided.

Return type:

InMemoryObjectStore

Raises:
  • ValueError – Namespace argument is None.

  • KeyError – Namespace does not exist in the repository

abstract get_instance_store(namespace)[source]

Return the CIM instance object store for the namespace provided.

Parameters:

namespace (string) – The name of the CIM namespace in the CIM repository. The name is treated case insensitively and it must not be None. Any leading and trailing slash characters in the namespace string are ignored when accessing the repository.

Returns:

CIM instance object store for the namespace provided.

Return type:

InMemoryObjectStore

Raises:
  • ValueError – Namespace argument is None.

  • KeyError – Namespace argument does exist in the repository.

abstract get_qualifier_store(namespace)[source]

Return the CIM qualifier declaration object store for the namespace provided.

Parameters:

namespace (string) – The name of the CIM namespace in the CIM repository. The name is treated case insensitively and it must not be None. Any leading and trailing slash characters in the namespace string are ignored when accessing the repository.

Returns:

CIM qualifier declaration object store for the namespace provided.

Return type:

InMemoryObjectStore

Raises:
  • ValueError – namespace parameter is None

  • KeyError – namespace argument does exist in therepository.

abstract property namespaces

NocaseList of string: The names of the namespaces that exist in this CIM repository.

Note that if there were any leading or trailing slash (“/”) characters in namespace parameters used to add the namespaces to the repository, they will be removed from the namespaces returned with this property.

abstract remove_namespace(namespace)[source]

Remove a CIM namespace from the repository.

The namespace must exist in the repository and must be empty.

Parameters:

namespace (string) – The name of the CIM namespace in the CIM repository. The name is treated case insensitively and it must not be None. Any leading and trailing slash characters in the namespace string are ignored when accessing the repository.

Raises:
  • ValueError – Namespace argument is None or the repository namespace is not empty.

  • KeyError – Namespace does not exist in the CIM repository.

abstract validate_namespace(namespace)[source]

Validate if the namespace exists in the repository. If the namespace does not exist a KeyError is raised.

Parameters:

namespace (string) – The name of the CIM namespace in the CIM repository. The name is treated case insensitively and it must not be None. Any leading and trailing slash characters in the namespace string are ignored when accessing the repository.

Raises:
  • KeyError – If the namespace is not defined in the repository.

  • ValueError – if the namespace is None.

class pywbem_mock.BaseObjectStore(cim_object_type)[source]

An abstract class that defines the APIs for the methods of an object store for CIM objects including CIMClass, CIMInstance, and CIMQualifierDeclaration objects that constitute a WBEM server repository. This class provides the abstract methods for creating, accessing, and deleting, CIM objects of a single CIM object type in the repository.

New in pywbem 1.0 as experimental and finalized in 1.2.

CIM objects in the object store are identified by a name which is part of the methods that access the CIM objects and must be unique within a single object store.

Each object store conatins only a single CIM object type.

Instantiate the self.cim_object_type variable.

Parameters:

cim_object_type (CIM object) – The Pywbem CIM object type as defined in cim_types.py for the objects in the data store. Used to verify values on create.

Methods:

create(name, cim_object)

Add the CIM object to the object store.

delete(name)

Delete the CIM object identified by name from the object store.

get(name[, copy])

Return the CIM object identified by name if it exists in the object store.

iter_names()

Return an iterator to the names of the CIM objects in the object store.

iter_values([copy])

Return an iterator to the CIM objects in the object store.

len()

Return the count of objects in this object store.

object_exists(name)

Test if the CIM object identified by name exists in the object store.

update(name, cim_object)

Replace the CIM object in the object store idenfified by the name argument with the CIM object defined by the cim_object argument.

abstract create(name, cim_object)[source]

Add the CIM object to the object store.

Parameters:
  • name (string or CIMInstanceName) – Name by which the CIM object will be identified in the object store.

  • cim_object (CIM object) – The CIM object to be added to the object store. The object is copied into the object store so the user can safely modify the original object without affecting the store.

Raises:

ValueError – If CIM object already exists in the object store.

abstract delete(name)[source]

Delete the CIM object identified by name from the object store.

Parameters:

name (string or CIMInstanceName) – Name by which the object to be deleted is identified in the object store.

Raises:

KeyError – If there is no object with name in this object store

abstract get(name, copy=True)[source]

Return the CIM object identified by name if it exists in the object store.

Parameters:
  • name (string or CIMInstanceName) – Name by which the object is identified in the object store

  • copy (bool) – If True, returns a copy of the object to insure that modifying the returned object does not change the data store. The default behavior is True . If copy is False, the object in the object store is returned but if it is modified by the user, the object in the store may be modified also.

Returns:

Returns the CIM object identified by the name parameter.

Return type:

CIM object

Raises:

KeyError – CIM object identified with name not in the object store

abstract iter_names()[source]

Return an iterator to the names of the CIM objects in the object store. Objects may be accessed using iterator methods.

The order of returned names is undetermined.

Returns:

An iterator for the names of CIM objects in the object store.

Return type:

iterator

abstract iter_values(copy=True)[source]

Return an iterator to the CIM objects in the object store. This allows iteration through all the objects in this object store using iterator methods.

The order of returned CIM objects is undetermined.

Parameters:

copy (bool) – Copy the objects before returning them. This is the default behavior and also the mode that should be used unless the user is certain the object will NOT be modified after it is returned.

Returns:

An iterator for the objects in the object store. If copy == True, each object is copied before it is returned.

Return type:

iterator

abstract len()[source]

Return the count of objects in this object store.

Returns:

Integer that is count of objects in this object store.

Return type:

int

abstract object_exists(name)[source]

Test if the CIM object identified by name exists in the object store.

Parameters:

name (string or CIMInstanceName) – Name by which the object is identified in the object store.

Returns:

Indicates whether the CIM object exists in the object store.

Return type:

bool

abstract update(name, cim_object)[source]

Replace the CIM object in the object store idenfified by the name argument with the CIM object defined by the cim_object argument.

Parameters:
  • name (string or CIMInstanceName) – Name by which the object is identified in the object store.

  • cim_object (CIM object) – The CIM object to replace the original CIM object in the data store. The object is copied into the object store so the user can safely modify the original object without affecting the store.

Raises:

KeyError – If no CIM object with name exists in the object store.

class pywbem_mock.BaseProvider(cimrepository)[source]

BaseProvider is the top level class in the provider hierarchy and includes methods required by both builtin providers and user-defined providers. This class is not intended to be executed directly.

Parameters:

cimrepository (BaseRepository or subclass) – Defines the repository to be used by providers. The repository is fully initialized but contains only objects defined by the FakedWBEMConnection methods that create objects in the repository (ex. compile_mof_file())

Methods:

__repr__()

Return repr(self).

add_namespace(namespace[, verbose])

Add a CIM namespace to the CIM repository.

class_exists(namespace, classname)

Test if class defined by classname parameter exists in CIM repository defined by namespace parameter.

filter_properties(obj, property_list)

Remove properties from an instance or class that aren't in the property_list parameter.

find_interop_namespace()

Find the Interop namespace name in the CIM repository, or return None.

get_class(namespace, classname[, ...])

Get class from CIM repository.

is_interop_namespace(namespace)

Tests if a namespace name is a valid Interop namespace name.

is_subclass(klass, superclass, class_store)

Return boolean indicating whether a class is a (direct or indirect) subclass of a superclass, or the same class, in the specified class store of the CIM repository (i.e. in the namespace of that class store).

remove_namespace(namespace[, verbose])

Remove a CIM namespace from the CIM repository.

validate_namespace(namespace)

Validates that a namespace is defined in the CIM repository.

Attributes:

cimrepository

Instance of class that represents the CIM repository.

interop_namespace_names

NocaseList of string: The valid Interop namespace names.

namespaces

NocaseList of string: The names of the namespaces that exist in the CIM repository.

__repr__()[source]

Return repr(self).

add_namespace(namespace, verbose=False)[source]

Add a CIM namespace to the CIM repository.

The namespace must not yet exist in the CIM repository and the repository can contain only one Interop namespace.

An Interop namespace can be added with this method, if an Interop namespace does not yet exist in the CIM repository.

Parameters:
  • namespace (string) – The name of the CIM namespace in the CIM repository. Must not be None. Any leading or trailing slash characters are removed before the string is used to define the namespace name.

  • verbose (bool) – Verbose mode: Print a message about the namespace creation.

Raises:
  • ValueError – Namespace argument must not be None.

  • CIMError – CIM_ERR_ALREADY_EXISTS if the namespace already exists in the CIM repository.

  • CIMError – CIM_ERR_ALREADY_EXISTS if the namespace is one of the possible Interop namespace names and an interop namespace already exists in the CIM repository.

property cimrepository

Instance of class that represents the CIM repository.

The CIM repository is the data store for CIM classes, CIM instances, and CIM qualifier declarations. All access to the mocker CIM data must pass through this variable to the CIM repository. See BaseRepository for a description of the repository interface.

The mocker may use subclasses of BaseRepository for specific functionality. Thus, InMemoryRepository implements an InMemory CIM repository that must be initialized for each FakedWBEMConnection construction.

Type:

BaseRepository or subclass

class_exists(namespace, classname)[source]

Test if class defined by classname parameter exists in CIM repository defined by namespace parameter.

Returns:

True if class exists and False if it does not exist.

Return type:

bool

Raises:

KeyError – Namespace does not exist in the CIM repository

static filter_properties(obj, property_list)[source]

Remove properties from an instance or class that aren’t in the property_list parameter.

Parameters:
  • obj (CIMClass or CIMInstance) – The class or instance from which properties are to be filtered

  • property_list (list of string) – List of properties which are to be included in the result. If None, remove nothing. If empty list, remove everything. else remove properties that are not in property_list. Duplicated names are allowed in the list and ignored.

find_interop_namespace()[source]

Find the Interop namespace name in the CIM repository, or return None.

The Interop namespace is identified by comparing all namespace names in the CIM repository against the list of valid Interop namespace names returned by interop_namespace_names.

Returns:

The name of the Interop namespace if one exists in the CIM repository or None.

Return type:

string

get_class(namespace, classname, local_only=None, include_qualifiers=None, include_classorigin=None, property_list=None)[source]

Get class from CIM repository. Gets the class defined by classname from the CIM repository, creates a copy, expands the copied class to include superclass properties if not localonly, and filters the class based on propertylist and includeClassOrigin.

This method executes all of the filter actions on the class that are defined for the GetClass operation and so returns a class that satisfies the behavior requirements of the GetClass client request operation defined in DSP0200 . (see: pywbem.WBEMConnection.GetClass())

It also sets the propagated attribute.

Parameters:
  • classname (string) – Name of class to retrieve

  • namespace (string) – The name of the CIM namespace in the CIM repository (case insensitive). Must not be None. Leading or trailing slash characters are ignored.

  • local_only (bool) – If True or None, only properties and methods in this specific class are returned. None means not supplied by client and the normal server default is True. If False, properties and methods from the superclasses are included.

  • include_qualifiers (bool) – If True or None, include qualifiers. None is the server default if the parameter is not provided by the client. If False, do not include qualifiers.

  • include_classorigin (bool) – If True, return the class_origin attributes of properties and methods. If False or None (use server default), class_origin attributes of properties and methods are not returned

  • property_list (list of string) – Properties to be included in returned class. If None, all properties are returned. If empty list, no properties are returned

Returns:

Copy of the CIM class in the CIM repository if found. Includes superclass properties installed and filtered in accord with the local_only, etc. arguments.

Return type:

CIMClass

Raises:
  • CIMError – (CIM_ERR_NOT_FOUND) if class not found in CIM repository.

  • CIMError – (CIM_ERR_INVALID_NAMESPACE) if namespace does not exist.

property interop_namespace_names

NocaseList of string: The valid Interop namespace names.

Only these names may be the Interop namespace and only one Interop namespace may exist in a WBEM server environment. This list is defined in pywbem.WBEMServer.INTEROP_NAMESPACES.

is_interop_namespace(namespace)[source]

Tests if a namespace name is a valid Interop namespace name.

This method does not access the CIM repository for this test; it merely compares the specified namespace name against the list of valid Interop namespace names returned by interop_namespace_names.

Parameters:

namespace (string) – The namespace name that is to be tested.

Returns:

Indicates whether the namespace name is a valid Interop namespace name.

Return type:

bool

is_subclass(klass, superclass, class_store)[source]

Return boolean indicating whether a class is a (direct or indirect) subclass of a superclass, or the same class, in the specified class store of the CIM repository (i.e. in the namespace of that class store).

This test is done by starting at the class and walking its superclasses up to the root, so it is not as expensive as determining all subclasses of a given class.

Parameters:
  • klass (string) – Class name of the class.

  • superclass (string) – Class name of the superclass.

  • class_store (BaseObjectStore) – Class store of the CIM repository to search for the classes.

Returns:

Boolean indicating whether the class is a (direct or indirect) subclass of the superclass, or the same class.

Return type:

bool

Raises:

KeyError – Class or superclass does not exist in the class store.

property namespaces

NocaseList of string: The names of the namespaces that exist in the CIM repository.

remove_namespace(namespace, verbose=False)[source]

Remove a CIM namespace from the CIM repository.

The namespace must exist in the CIM repository and must be empty.

The Interop namespace cannot be removed from the CIM repository.

Parameters:
  • namespace (string) – The name of the CIM namespace in the CIM repository (case insensitive). Must not be None. Leading or trailing slash characters are ignored.

  • verbose (bool) – Verbose mode: Print a message about the namespace deletion.

Raises:
  • ValueError – Namespace argument must not be None.

  • CIMError – CIM_ERR_NOT_FOUND if the namespace does not exist in the CIM repository.

  • CIMError – CIM_ERR_INVALID_NAMESPACE if the Interop namespace was specified.

  • CIMError – CIM_ERR_NAMESPACE_NOT_EMPTY if the namespace icontains objects.

  • CIMError – CIM_ERR_NAMESPACE_NOT_EMPTY if attempting to delete the default connection namespace. This namespace cannot be deleted from the CIM repository

validate_namespace(namespace)[source]

Validates that a namespace is defined in the CIM repository. Returns only if namespace is valid. Otherwise it generates an exception.

Parameters:

namespace (string) – The name of the CIM namespace in the CIM repository (case insensitive). Must not be None. Any leading or trailing slash characters are ignored.

Raises:

CIMError – (CIM_ERR_INVALID_NAMESPACE) Namespace does not exist.

12.5. Glossary

dynamic indication filter
dynamic filter

An indication filter in a WBEM server whose life cycle is managed by a client. See DSP1054 for an authoritative definition and for details.

static indication filter
static filter

An indication filter in a WBEM server that pre-exists and whose life cycle cannot be managed by a client. See DSP1054 for an authoritative definition and for details.

12.6. References

DSP0004

DMTF DSP0004, CIM Infrastructure, Version 2.8

DSP0200

DMTF DSP0200, CIM Operations over HTTP, Version 1.4

DSP0201

DMTF DSP0201, Representation of CIM in XML, Version 2.4

DSP0207

DMTF DSP0207, WBEM URI Mapping, Version 1.0

DSP0212

DMTF DSP0212, Filter Query Language, Version 1.0.1

DSP1001

DMTF DSP1001, Management Profile Specification Usage Guide, Version 1.1

DSP1033

DMTF DSP1033, Profile Registration Profile, Version 1.1

DSP1054

DMTF DSP1054, Indications Profile, Version 1.2

DSP1092

DMTF DSP1092, WBEM Server Profile, Version 1.0

X.509

ITU-T X.509, Information technology - Open Systems Interconnection - The Directory: Public-key and attribute certificate frameworks

RFC2616

IETF RFC2616, Hypertext Transfer Protocol – HTTP/1.1, June 1999

RFC2617

IETF RFC2617, HTTP Authentication: Basic and Digest Access Authentication, June 1999

RFC3986

IETF RFC3986, Uniform Resource Identifier (URI): Generic Syntax, January 2005

RFC6874

IETF RFC6874, Representing IPv6 Zone Identifiers in Address Literals and Uniform Resource Identifiers, February 2013

WBEM Standards

DMTF WBEM Standards

Python Glossary