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

Here are some trouble shooting hints for the installation 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. Installation of lxml misses include files on Python 3.4 on native Windows

On Python 3.4 on native Windows, the installation of the lxml Python package may fail during installation of the development prerequisites (i.e. during make develop), reporting missing include files such as libxml/xmlversion.h.

It has not been investigated what causes this on Python 3.4 (it works on other Python versions). If this issue shows up, try installing the Binary lxml package for Windows manually, with the lxml version >=4.2.4 and <4.4.0.

12.3.3. 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)

For example, this happened after an upgrade of the client OS to Debian buster using Python 3.7, with OpenSSL 1.1.1d.

This is an error that is created by the OpenSSL library and handed back up to the SSL module of Python which hands it up to pywbem. The error indicates that OpenSSL and the WBEM server do not agree about which SSL/TLS protocol level to use.

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

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).

This error means most likely that the WBEM server side does not yet support TLS 1.2 or higher.

This can be fixed for example by adding TLS 1.2 support to the server side (preferred) or by lowering the minimum TLS level OpenSSL requires on the client side (which lowers security). The latter can be done 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 there is:

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

12.3.4. 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 is an error that is created by the OpenSSL library and handed back up to the SSL module of Python which hands it up to pywbem. The 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.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.

In Python 2, the rich comparison operators (e.g. __eq__()) have precedence over the traditional comparator method (__cmp__()). In Python 3, the comparator method (__cmp__()) no longer exists. Therefore, implementing the rich comparison operators works in both.

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 hiearchy 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_file())

Methods:

__repr__()

Return repr(self).

add_namespace(namespace)

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.

remove_namespace(namespace)

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)[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.

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

Exception if the namespace does not exist

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)[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.

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