4.2. CIM objects

CIM objects are local representations of CIM instances, classes, properties, etc., as Python objects. They are used as input to and output from WBEM operations:

CIM object Purpose
CIMInstanceName Instance path of a CIM instance
CIMInstance CIM instance
CIMClassName Name of a CIM class, optionally with class path
CIMClass CIM class
CIMProperty CIM property, both as property value in a CIM instance and as property declaration in a CIM class
CIMMethod CIM method declaration in a CIM class
CIMParameter CIM parameter, both as a parameter value in a method invocation and as a parameter declaration in a CIM method declaration in a CIM class
CIMQualifier CIM qualifier value
CIMQualifierDeclaration CIM qualifier type/declaration

4.2.1. Putting CIM objects in sets

Using sets for holding the result of WBEM operations is not uncommon, because that allows comparison of results without regard to the (undefined) order in which the objects are returned.

CIM objects are mutable and unchanged-hashable. This requires some caution when putting them in sets, or using them in any other way that relies on their hash values.

The caution that is needed is that the public attributes, and therefore the state of the CIM objects, must not change as long as they are a member of a set, or used in any other way that relies on their hash values.

The following example shows what happens if a CIM object is modified while being a member of a set:

import pywbem

s = set()

# Create CIM object c1 and show its identity and hash value:
c1 = pywbem.CIMClass('C')
print(id(c1), hash(c1))  # (140362966049680, -7623128493967117119)

# Add c1 to the set and verify the set content:
s.add(c1)
print([id(c) for c in s])  # [140362966049680]

# Modify the c1 object; it now has changed its hash value:
c1.superclass = 'B'
print(id(c1), hash(c1))  # (140362966049680, 638672161836520435)

# Create a CIM object c2 with the same attribute values as c1, and show
# that they compare equal and that c2 has the same hash value as c1 now has:
c2 = pywbem.CIMClass('C', superclass='B')
print(c1 == c2)  # True
print(id(c2), hash(c2))  # (140362970983696, 638672161836520435)

# Add c2 to the set and verify the set content:
s.add(c2)
print([id(c) for c in s])  # [140362966049680, 140362970983696] !!

At the end, the set contains both objects even though they have the same hash value. This is not what one would expect from set types.

The reason is that at the time the object c1 was added to the set, it had a different hash value, and the set uses the hash value it found at insertion time of its member for identifying the object. When the second object is added, it finds it has a yet unknown hash value, and adds it.

While the set type in this particular Python implementation was able to still look up the first member object even though its hash value has changed meanwhile, other collection types or other Python implementations may not be as forgiving and may not even be able to look up the object once its hash value has changed.

Therefore, always make sure that the public attributes of CIM objects that are put into a set remain unchanged while the object is in the set. The same applies to any other usage of CIM objects that relies on their hash values.

4.2.2. Order of CIM child objects

CIM objects have zero or more lists of child objects. For example, a CIM class (the parent object) has a list of CIM properties, CIM methods and CIM qualifiers (the child objects).

In pywbem, the parent CIM object allows initializing each list of child objects via an argument of its constructor. For example, the CIMClass constructor has an argument named properties that allows specifying the properties of the class.

Once the parent CIM object exists, each list of child elements can be modified via a settable attribute. For example, the CIMClass class has a properties attribute for its list of properties.

For such attributes and constructor arguments that specify lists of child objects, pywbem supports a number of different ways the child objects can be specified.

Some of these ways preserve the order of child objects and some don’t.

This section uses properties in classes as an example, but it applies to all kinds of child objects in CIM objects.

The possible input objects for the properties constructor argument and for the properties attribute of CIMClass is described in the type properties input object, and must be one of these objects:

  • iterable of CIMProperty
  • iterable of tuple(key, value)
  • OrderedDict with key and value
  • dict with key and value (will not preserve order)

The keys are always the property names, and the values are always CIMProperty objects (at least when initializing classes).

Even though the OrderedDict class preserves the order of its items, intializing the dictionary with keyword arguments causes the order of items to be lost before the dictionary is even initialized (before Python 3.6). The only way to initialize a dictionary without loosing order of items is by providing a list of tuples(key,value).

The following examples work but loose the order of properties in the class:

# Examples where order of properties in class is not as specified:


# Using an OrderedDict object, initialized with keyword arguments
# (before Python 3.6):

c1_props = OrderedDict(
    Prop1=CIMProperty('Prop1', value='abc'),
    Prop2=CIMProperty('Prop2', value=None, type='string'),
)


# Using a dict object, initialized with keyword arguments (This time
# specified using key:value notation):

c1_props = {
    'Prop1': CIMProperty('Prop1', value='abc'),
    'Prop2': CIMProperty('Prop2', value=None, type='string'),
}


# Using a dict object, initialized with list of tuple(key,value):

c1_props = dict([
    ('Prop1', CIMProperty('Prop1', value='abc')),
    ('Prop2', CIMProperty('Prop2', value=None, type='string')),
])


# Any of the above objects can be used to initialize the class properties:

c1 = CIMClass('CIM_Foo', properties=c1_props)

The following examples all preserve the order of properties in the class:

# Examples where order of properties in class is as specified:


# Using a list of CIMProperty objects (starting with pywbem 0.12):

c1_props = [
    CIMProperty('Prop1', value='abc'),
    CIMProperty('Prop2', value=None, type='string'),
]


# Using an OrderedDict object, initialized with list of tuple(key,value):

c1_props = OrderedDict([
    ('Prop1', CIMProperty('Prop1', value='abc')),
    ('Prop2', CIMProperty('Prop2', value=None, type='string')),
])


# Using a list of tuple(key,value):

c1_props = [
    ('Prop1', CIMProperty('Prop1', value='abc')),
    ('Prop2', CIMProperty('Prop2', value=None, type='string')),
]


# Any of the above objects can be used to initialize the class properties:

c1 = CIMClass('CIM_Foo', properties=c1_props)

4.2.3. NocaseDict

Class NocaseDict is a dictionary implementation with case-insensitive but case-preserving keys, and with preservation of the order of its items.

It is used for lists of child objects of CIM objects (e.g. the list of CIM properties in a CIM class, or the list of CIM parameters in a CIM method).

Users of pywbem will notice NocaseDict objects only as a result of pywbem functions. Users cannot create NocaseDict objects.

Except for the case-insensitivity of its keys, it behaves like the built-in OrderedDict. Therefore, NocaseDict is not described in detail in this documentation.

Deprecated: In pywbem 0.9, support for comparing two NocaseDict instances with the >, >, <=, >= operators has been deprecated.

4.2.4. CIMInstanceName

class pywbem.CIMInstanceName(classname, keybindings=None, host=None, namespace=None)[source]

A CIM instance path (aka CIM instance name).

A CIM instance path references a CIM instance in a CIM namespace in a WBEM server. Namespace and WBEM server may be unspecified.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

Parameters:
  • classname (string) –

    Name of the creation class of the referenced instance.

    Must not be None.

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

  • keybindings (keybindings input object) – Keybindings for the instance path (that is, the key property values of the referenced instance).
  • host (string) –

    Host and optionally port of the WBEM server containing the CIM namespace of the referenced instance.

    The format of the string must be:

    host[:port]

    The host can be specified in any of the usual formats:

    • a short or fully qualified DNS hostname
    • a literal (= dotted) IPv4 address
    • a literal IPv6 address, formatted as defined in RFC3986 with the extensions for zone identifiers as defined in RFC6874, supporting - (minus) for the delimiter before the zone ID string, as an additional choice to %25.

    None means that the WBEM server is unspecified, and the same-named attribute in the CIMInstanceName object will also be None.

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

  • namespace (string) –

    Name of the CIM namespace containing the referenced instance.

    None means that the namespace is unspecified, and the same-named attribute in the CIMInstanceName object will also be None.

    Leading and trailing slash characters will be stripped. The lexical case of the string is preserved. Object comparison and hash value calculation are performed case-insensitively.

Raises:
  • ValueError – An error in the provided argument values.
  • TypeError – An error in the provided argument types.
classname

unicode string – Name of the creation class of the referenced instance.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

keybindings

NocaseDict – Keybindings of the instance path (that is, the key property values of the referenced instance).

Will not be None.

Each dictionary item specifies one keybinding, with:

The order of keybindings in the instance path is preserved.

The keybinding name may be None in objects of this class that are created by pywbem, in the special case a WBEM server has returned an instance path with an unnamed keybinding (i.e. a KEYVALUE or VALUE.REFERENCE element without a parent KEYBINDINGS element). This is allowed as per DSP0201. When creating objects of this class, it is not allowed to specify unnamed keybindings, i.e. the keybinding name must not be None.

This attribute is settable; setting it will cause the current keybindings to be replaced with the new keybindings. For details, see the description of the same-named constructor parameter.

The keybindings can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. The provided input value must be specified as a CIM data type or as number:

instpath = CIMInstanceName(...)
v1 = "abc"  # must be a CIM data type or Python number type

instpath.keybindings['k1'] = v1  # Set "k1" to v1 (add if needed)
v1 = instpath.keybindings['k1']  # Access value of "k1"
del instpath.keybindings['k1']  # Delete "k1" from the inst. path

In addition, the keybindings can be accessed and manipulated one by one by using the entire CIMInstanceName object like a dictionary. Again, the provided input value must be specified as a CIM data type or as number:

instpath = CIMInstanceName(...)
v2 = 42  # must be a CIM data type or Python number type

instpath['k2'] = v2  # Set "k2" to v2 (add if needed)
v2 = instpath['k2']  # Access value of "k2"
del instpath['k2']  # Delete "k2" from the instance path
namespace

unicode string – Name of the CIM namespace containing the referenced instance.

None means that the namespace is unspecified.

This attribute is settable. For details, see the description of the same-named constructor parameter.

host

unicode string – Host and optionally port of the WBEM server containing the CIM namespace of the referenced instance.

For details about the string format, see the same-named constructor parameter.

None means that the host and port are unspecified.

This attribute is settable. For details, see the description of the same-named constructor parameter.

__str__()[source]

Return a WBEM URI string of the CIM instance path represented by the CIMInstanceName object.

The returned WBEM URI string is in the historical format returned by to_wbem_uri().

For new code, it is recommended that the standard format is used; it is returned by to_wbem_uri() as the default format.

Examples (for the historical format):

  • With authority and namespace:

    //acme.com/cimv2/test:CIM_RegisteredProfile.InstanceID="acme.1"
    
  • Without authority but with namespace:

    cimv2/test:CIM_RegisteredProfile.InstanceID="acme.1"
    
  • Without authority and without namespace:

    CIM_RegisteredProfile.InstanceID="acme.1"
    
__repr__()[source]

Return a string representation of the CIMInstanceName object that is suitable for debugging.

The key bindings will be ordered by their names in the result.

copy()[source]

Return a copy of the CIMInstanceName object.

This is a middle-deep copy; any mutable types in attributes except the following are copied, so besides these exceptions, modifications of the original object will not affect the returned copy, and vice versa. The following mutable types are not copied and are therefore shared between original and copy:

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

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

Add the positional arguments and keyword arguments to the keybindings, updating the values of those that already exist.

has_key(key)[source]

Return a boolean indicating whether the instance path has a keybinding with name key.

get(key, default=None)[source]

New in pywbem 0.8.

Return the value of the keybinding with name key, or a default value if a keybinding with that name does not exist.

keys()[source]

Return a copied list of the keybinding names (in their original lexical case).

The order of keybindings is preserved.

values()[source]

Return a copied list of the keybinding values.

The order of keybindings is preserved.

items()[source]

Return a copied list of the keybindings, where each item is a tuple of its keybinding name (in the original lexical case) and its value.

The order of keybindings is preserved.

iterkeys()[source]

Iterate through the keybinding names (in their original lexical case).

The order of keybindings is preserved.

itervalues()[source]

Iterate through the keybinding values.

The order of keybindings is preserved.

iteritems()[source]

Iterate through the keybindings, where each item is a tuple of the keybinding name (in the original lexical case) and the keybinding value.

The order of keybindings is preserved.

tocimxml(ignore_host=False, ignore_namespace=False)[source]

Return the CIM-XML representation of the CIMInstanceName object, as an instance of an appropriate subclass of Element.

Parameters:
  • ignore_host (bool) – Ignore the host of the instance path, even if a host is specified.
  • ignore_namespace (bool) – Ignore the namespace and host of the instance path, even if a namespace and/or host is specified.

If the instance path has no namespace specified or if ignore_namespace is True, the returned CIM-XML representation is an INSTANCENAME element consistent with DSP0201.

Otherwise, if the instance path has no host specified or if ignore_host is True, the returned CIM-XML representation is a LOCALINSTANCEPATH element consistent with DSP0201.

Otherwise, the returned CIM-XML representation is a INSTANCEPATH element consistent with DSP0201.

The order of keybindings in the returned CIM-XML representation is preserved from the CIMInstanceName object.

tocimxmlstr(indent=None, ignore_host=False, ignore_namespace=False)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMInstanceName object, as a unicode string.

For the returned CIM-XML representation, see tocimxml().

Parameters:
  • indent (string or integer) –

    None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

    Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

  • ignore_host (bool) – Ignore the host of the instance path, even if a host is specified.
  • ignore_namespace (bool) – Ignore the namespace and host of the instance path, even if a namespace and/or host is specified.
Returns:

The CIM-XML representation of the value, as a unicode string.

static from_wbem_uri(wbem_uri)[source]

New in pywbem 0.12.

Return a new CIMInstanceName object from the specified WBEM URI string.

The WBEM URI string must be a CIM instance path in untyped WBEM URI format, as defined in DSP0207, with these extensions:

  • DSP0207 restricts the namespace types (URI schemes) to be one of http, https, cimxml-wbem, or cimxml-wbems. Pywbem tolerates any namespace type, but issues a UserWarning if it is not one of the namespace types defined in DSP0207.
  • DSP0207 requires a slash before the namespace name. For local WBEM URIs (no namespace type, no authority), that slash is the first character of the WBEM URI. For historical reasons, pywbem tolerates a missing leading slash for local WBEM URIs. Note that pywbem requires the slash (consistent with DSP0207) when the WBEM URI is not local.
  • DSP0207 requires datetime values in keybindings to be surrounded by double quotes. For historical reasons, pywbem tolerates datetime values that are not surrounded by double quotes, but issues a UserWarning.
  • DSP0207 does not allow the special float values INF, -INF, and NaN in WBEM URIs (according to realValue in DSP0004). However, the CIM-XML protocol supports representation of these special values, so to be on the safe side, pywbem supports these special values as keybindings in WBEM URIs.

Keybindings that are references are supported, recursively.

CIM instance paths in the typed WBEM URI format defined in DSP0207 are not supported.

The untyped WBEM URI format defined in DSP0207 has the following limitations when interpreting a WBEM URI string:

  • It cannot distinguish string-typed keys with a value that is a datetime value from datetime-typed keys with such a value. Pywbem treats such values as datetime-typed keys.
  • It cannot distinguish string-typed keys with a value that is a WBEM URI from reference-typed keys with such a value. Pywbem treats such values as reference-typed keys.

Examples:

https://jdd:test@acme.com:5989/cimv2/test:CIM_RegisteredProfile.InstanceID="acme.1"
http://acme.com/root/cimv2:CIM_ComputerSystem.CreationClassName="ACME_CS",Name="sys1"
/:CIM_SubProfile.Main="/:CIM_RegisteredProfile.InstanceID="acme.1"",Sub="/:CIM_RegisteredProfile.InstanceID="acme.2""
Parameters:wbem_uri (string) – WBEM URI for an instance path.
Returns:The instance path created from the specified WBEM URI string.
Return type:CIMInstanceName
Raises:ValueError – Invalid WBEM URI format for an instance path. This includes typed WBEM URIs.
to_wbem_uri(format='standard')[source]

Return the untyped WBEM URI of the CIM instance path represented by the CIMInstanceName object.

The returned WBEM URI contains its components as follows:

  • it does not contain a namespace type (URI scheme).
  • it contains an authority component according to the host attribute, if that is not None. Othwerise, it does not contain the authority component.
  • it contains a namespace component according to the namespace attribute, if that is not None. Othwerise, it does not contain the namespace component.
  • it contains a class name component according to the classname attribute.
  • it contains keybindings according to the keybindings attribute, with the order of keybindings preserved, and the lexical case of keybinding names preserved.

DSP0004 defines instance paths without a concept of order in their keybindings, and that keybinding names in instance paths match case-insensitively. Because the WBEM URI string returned by this method preserves the order of keybindings (relative to how the keybindings were first added to this object) and because the lexical case of the keybinding names is also preserved, equality of WBEM URIs should not be determined by comparing the returned WBEM URI strings. Instead, compare CIMInstanceName objects using the == operator, which performs the comparison at the logical level required by DSP0004. If you have WBEM URI strings without the corresponding CIMInstanceName object, such an object can be created by using the static method from_wbem_uri().

Parameters:format (string) –

Format for the generated WBEM URI string, using one of the following values:

  • "standard" - Standard format that is conformant to untyped WBEM URIs for instance paths defined in DSP0207.
  • "cimobject" - Format for the CIMObject header field in CIM-XML messages for representing instance paths (used internally, see DSP0200).
  • "historical" - Historical format for WBEM URIs (used by __str__(); should not be used by new code). The historical format has the following differences to the standard format:
    • If the authority component is not present, the slash after the authority is also omitted. In the standard format, that slash is always present.
    • If the namespace component is not present, the colon after the namespace is also omitted. In the standard format, that colon is always present.

Examples for the standard format:

  • With authority and namespace:

    //acme.com/cimv2/test:CIM_RegisteredProfile.InstanceID="acme.1"
    
  • Without authority but with namespace:

    /cimv2/test:CIM_RegisteredProfile.InstanceID="acme.1"
    
  • Without authority and without namespace:

    /:CIM_RegisteredProfile.InstanceID="acme.1"
    
Returns:Untyped WBEM URI of the CIM instance path, in the specified format.
Return type:unicode string
Raises:TypeError – Invalid type in keybindings
static from_instance(class_, instance, namespace=None, host=None, strict=False)[source]

Given a class and corresponding instance, create and return a CIMInstanceName from the class key properties and instance key property values.

If the strict parameter is False, and a property value does not exist in the instance that entry is not included in the constructed CIMInstanceName

If the strict parameter is True all key properties in the class_ must exist in the instance or a ValueError exception is raised.

Parameters:
  • class_ (CIMClass) –

    The CIM class with the key properties.

    In strict mode, that class must contain all key properties that are required to create the CIMInstanceName object. Thus, for example, if the class were retrieved from a server, generally, the LocalOnly parameter in the request should be False to assure that superclass properties are retrieved and IncludeQualifiers parameter should be set to True to assure that qualifiers are retrieved.

    In non-strict mode, that class may have missing key properties. Any missing key properties will result in missing key bindings in the created CIMInstanceName object.

    The specified class does not need to be the creation class of the instance. Thus, it could be a superclass as long as it has the required key properties.

  • instance (CIMInstance) – The CIM instance with the key property values.
  • namespace (string) – Namespace to include in the created CIMInstanceName or None.
  • host (string) – Host name to include in created CIMInstanceName or None.
  • strict (bool) – Strict mode (see description of class_ parameter).
Returns:

CIMInstanceName built from the key properties in the class_ parameter using the key property values in the instance parameter.

Return type:

CIMInstanceName

Raises:

ValueError – The strict attribute is True and a key property does not exist in the instance.

4.2.5. CIMInstance

class pywbem.CIMInstance(classname, properties=None, qualifiers=None, path=None, property_list=None)[source]

A representation of a CIM instance in a CIM namespace in a WBEM server, optionally including its instance path.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

Parameters:
  • classname (string) –

    Name of the creation class for the instance.

    Must not be None.

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

  • properties (properties input object) –

    The property values for the instance.

    If the specified path has keybindings that correspond to these properties, the values of these keybindings will be updated to match the property values.

  • qualifiers (qualifiers input object) –

    The qualifiers for the instance.

    Note that DSP0200 has deprecated the presence of qualifiers on CIM instances.

  • path (CIMInstanceName) –

    Instance path for the instance.

    The provided object will be copied before being stored in the CIMInstance object.

    If this path has keybindings that correspond to the specified properties, the values of the keybindings in (the copy of) this path will be updated to match the property values.

    None means that the instance path is unspecified, and the same-named attribute in the CIMInstance object will also be None.

  • property_list (iterable of string) –

    List of property names for use as a filter by some operations on the instance. The property names may have any lexical case.

    A copy of the provided iterable will be stored in the CIMInstance object, and the property names will be converted to lower case.

    None means that the properties are not filtered, and the same-named attribute in the CIMInstance object will also be None.

    Deprecated: This parameter has been deprecated in pywbem 0.12. Set only the desired properties on the object, instead of working with this property filter.

Raises:
  • ValueError – classname is None, a property or qualifier name is None, or a property or qualifier name does not match its dictionary key.
  • TypeError – a numeric Python type was used for a property or qualifier value.
classname

unicode string – Name of the creation class of the instance.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

properties

NocaseDict – Properties of the CIM instance.

Will not be None.

Each dictionary item specifies one property value, with:

The order of properties in the CIM instance is preserved.

This attribute is settable; setting it will cause the current CIM properties to be replaced with the new properties, and will also cause the values of corresponding keybindings in the instance path (if set) to be updated. For details, see the description of the same-named constructor parameter. Note that the property value may be specified as a CIM data type or as a CIMProperty object.

The CIM property values can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. In that case, the provided input value must be a CIMProperty object. A corresponding keybinding in the instance path (if set) will not (!) be updated in this case:

inst = CIMInstance(...)
p1 = CIMProperty('p1', ...)  # must be CIMProperty

inst.properties['p1'] = p1  # Set "p1" to p1 (add if needed)
p1 = inst.properties['p1']  # Access "p1"
del inst.properties['p1']  # Delete "p1" from the instance

In addition, the CIM properties can be accessed and manipulated one by one by using the entire CIMInstance object like a dictionary. In that case, the provided input value may be specified as a CIM data type or as a CIMProperty object. The value of a corresponding keybinding in the instance path (if set) will be updated to the new property value:

inst = CIMInstance(...)
p2 = Uint32(...)  # may be CIM data type or CIMProperty

inst['p2'] = p2  # Set "p2" to p2 (add if needed)
p2 = inst['p2']  # Access "p2"
del inst['p2']  # Delete "p2" from the instance
qualifiers

NocaseDict – Qualifiers of the CIM instance.

Will not be None.

Each dictionary item specifies one qualifier value, with:

The order of qualifiers in the CIM instance is preserved.

This attribute is settable; setting it will cause the current qualifiers to be replaced with the new qualifiers. For details, see the description of the same-named constructor parameter.

The qualifier values can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary.

Note that DSP0200 has deprecated the presence of qualifier values on CIM instances.

path

CIMInstanceName – Instance path of the instance.

None means that the instance path is unspecified.

This attribute is settable. For details, see the description of the same-named constructor parameter.

property_list

list of unicode string – List of property names for use as a filter by some operations on the instance. The property names are in lower case.

None means that the properties are not filtered.

This attribute is settable. For details, see the description of the same-named constructor parameter.

Deprecated: This attribute has been deprecated in pywbem 0.12. Set only the desired properties on the object, instead of working with this property filter.

__str__()[source]

Return a short string representation of the CIMInstance object for human consumption.

__repr__()[source]

Return a string representation of the CIMInstance object that is suitable for debugging.

The properties and qualifiers will be ordered by their names in the result.

copy()[source]

Return a copy of the CIMInstance object.

This is a middle-deep copy; any mutable types in attributes except the following are copied, so besides these exceptions, modifications of the original object will not affect the returned copy, and vice versa. The following mutable types are not copied and are therefore shared between original and copy:

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

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

Add the positional arguments and keyword arguments to the properties, updating the values of those that already exist.

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

Update the values of already existing properties from the positional arguments and keyword arguments.

has_key(key)[source]

Return a boolean indicating whether the instance has a property with name key.

get(key, default=None)[source]

New in pywbem 0.8.

Return the value of the property with name key, or a default value if a property with that name does not exist.

keys()[source]

Return a copied list of the property names (in their original lexical case).

The order of properties is preserved.

values()[source]

Return a copied list of the property values.

The order of properties is preserved.

items()[source]

Return a copied list of the properties, where each item is a tuple of the property name (in the original lexical case) and the property value.

The order of properties is preserved.

iterkeys()[source]

Iterate through the property names (in their original lexical case).

The order of properties is preserved.

itervalues()[source]

Iterate through the property values.

The order of properties is preserved.

iteritems()[source]

Iterate through the property names (in their original lexical case).

The order of properties is preserved.

tocimxml(ignore_path=False)[source]

Return the CIM-XML representation of the CIMInstance object, as an instance of an appropriate subclass of Element.

Parameters:ignore_path (bool) – Ignore the path of the instance, even if a path is specified.

If the instance has no instance path specified or if ignore_path is True, the returned CIM-XML representation is an INSTANCE element consistent with DSP0201. This is the required element for representing embedded instances.

Otherwise, if the instance path of the instance has no namespace specified, the returned CIM-XML representation is an VALUE.NAMEDINSTANCE element consistent with DSP0201.

Otherwise, if the instance path of the instance has no host specified, the returned CIM-XML representation is a VALUE.OBJECTWITHLOCALPATH element consistent with DSP0201.

Otherwise, the returned CIM-XML representation is a VALUE.INSTANCEWITHPATH element consistent with DSP0201.

The order of properties and qualifiers in the returned CIM-XML representation is preserved from the CIMInstance object.

tocimxmlstr(indent=None, ignore_path=False)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMInstance object, as a unicode string.

For the returned CIM-XML representation, see tocimxml().

Parameters:
  • indent (string or integer) –

    None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

    Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

  • ignore_path (bool) – Ignore the path of the instance, even if a path is specified.
Returns:

The CIM-XML representation of the object, as a unicode string.

tomof(indent=0, maxline=80)[source]

Return a MOF string with the instance specification represented by the CIMInstance object.

The returned MOF string conforms to the instanceDeclaration ABNF rule defined in DSP0004, with the following limitations:

  • Pywbem does not support instance aliases, so the returned MOF string does not define an alias name for the instance.
  • Even though pywbem supports qualifiers on CIMInstance objects, and on CIMProperty objects that are used as property values within an instance, the returned MOF string does not contain any qualifier values on the instance or on its property values.

The order of properties and qualifiers is preserved.

Parameters:indent (integer) – This parameter has been deprecated in pywbem 0.12. A value other than 0 causes a deprecation warning to be issued. Othwerise, the parameter is ignored and the returned MOF instance specification is not indented.
Returns:MOF string.
Return type:unicode string

4.2.6. CIMClassName

class pywbem.CIMClassName(classname, host=None, namespace=None)[source]

A CIM class path (aka CIM class name).

A CIM class path references a CIM class in a CIM namespace in a WBEM server. Namespace and WBEM server may be unspecified.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

Parameters:
  • classname (string) –

    Class name of the referenced class.

    Must not be None.

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

  • host (string) –

    Host and optionally port of the WBEM server containing the CIM namespace of the referenced class.

    The format of the string must be:

    host[:port]

    The host can be specified in any of the usual formats:

    • a short or fully qualified DNS hostname
    • a literal (= dotted) IPv4 address
    • a literal IPv6 address, formatted as defined in RFC3986 with the extensions for zone identifiers as defined in RFC6874, supporting - (minus) for the delimiter before the zone ID string, as an additional choice to %25.

    None means that the WBEM server is unspecified, and the same-named attribute in the CIMClassName object will also be None.

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

  • namespace (string) –

    Name of the CIM namespace containing the referenced class.

    None means that the namespace is unspecified, and the same-named attribute in the CIMClassName object will also be None.

    Leading and trailing slash characters will be stripped. The lexical case of the string is preserved. Object comparison and hash value calculation are performed case-insensitively.

Raises:

ValueError – classname is None.

classname

unicode string – Class name of the referenced class.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

namespace

unicode string – Name of the CIM namespace containing the referenced class.

None means that the namespace is unspecified.

This attribute is settable. For details, see the description of the same-named constructor parameter.

host

unicode string – Host and optionally port of the WBEM server containing the CIM namespace of the referenced class.

For details about the string format, see the same-named constructor parameter.

None means that the host and port are unspecified.

This attribute is settable. For details, see the description of the same-named constructor parameter.

copy()[source]

Return a copy the CIMClassName object.

Objects of this class have no mutable types in any attributes, so modifications of the original object will not affect the returned copy, and vice versa.

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

__str__()[source]

Return a WBEM URI string of the CIM class path represented by the CIMClassName object.

The returned WBEM URI string is in the historical format returned by to_wbem_uri().

For new code, it is recommended that the standard format is used; it is returned by to_wbem_uri() as the default format.

If you want to access the class name, use the classname attribute, instead of relying on the coincidence that the historical format of a WBEM URI without authority and namespace happens to be the class name.

Examples (for the historical format):

  • With authority and namespace:

    //acme.com/cimv2/test:CIM_RegisteredProfile
    
  • Without authority but with namespace:

    cimv2/test:CIM_RegisteredProfile
    
  • Without authority and without namespace:

    CIM_RegisteredProfile
    
__repr__()[source]

Return a string representation of the CIMClassName object that is suitable for debugging.

tocimxml(ignore_host=False, ignore_namespace=False)[source]

Return the CIM-XML representation of the CIMClassName object, as an instance of an appropriate subclass of Element.

Parameters:
  • ignore_host (bool) – Ignore the host of the class path, even if a host is specified.
  • ignore_namespace (bool) – Ignore the namespace and host of the class path, even if a namespace and/or host is specified.

If the class path has no namespace specified or if ignore_namespace is True, the returned CIM-XML representation is a CLASSNAME element consistent with DSP0201.

Otherwise, if the class path has no host specified or if ignore_host is True, the returned CIM-XML representation is a LOCALCLASSPATH element consistent with DSP0201.

Otherwise, the returned CIM-XML representation is a CLASSPATH element consistent with DSP0201.

tocimxmlstr(indent=None, ignore_host=False, ignore_namespace=False)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMClassName object, as a unicode string.

For the returned CIM-XML representation, see tocimxml().

Parameters:
  • indent (string or integer) –

    None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

    Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

  • ignore_host (bool) – Ignore the host of the class path, even if a host is specified.
  • ignore_namespace (bool) – Ignore the namespace and host of the class path, even if a namespace and/or host is specified.
Returns:

The CIM-XML representation of the object, as a unicode string.

static from_wbem_uri(wbem_uri)[source]

New in pywbem 0.12.

Return a new CIMClassName object from the specified WBEM URI string.

The WBEM URI string must be a CIM class path in untyped WBEM URI format, as defined in DSP0207, with these extensions:

  • DSP0207 restricts the namespace types (URI schemes) to be one of http, https, cimxml-wbem, or cimxml-wbems. Pywbem tolerates any namespace type, but issues a UserWarning if it is not one of the namespace types defined in DSP0207.
  • DSP0207 requires a slash before the namespace name. For local WBEM URIs (no namespace type, no authority), that slash is the first character of the WBEM URI. For historical reasons, pywbem tolerates a missing leading slash for local WBEM URIs. Note that pywbem requires the slash (consistent with DSP0207) when the WBEM URI is not local.

CIM class paths in the typed WBEM URI format defined in DSP0207 are not supported.

Examples:

https://jdd:test@acme.com:5989/cimv2/test:CIM_RegisteredProfile
http://acme.com/root/cimv2:CIM_ComputerSystem
http:/root/cimv2:CIM_ComputerSystem
/root/cimv2:CIM_ComputerSystem
root/cimv2:CIM_ComputerSystem
/:CIM_ComputerSystem
:CIM_ComputerSystem
Parameters:wbem_uri (string) – WBEM URI for a class path.
Returns:The class path created from the specified WBEM URI string.
Return type:CIMClassName
Raises:ValueError – Invalid WBEM URI format for a class path. This includes typed WBEM URIs.
to_wbem_uri(format='standard')[source]

Return the untyped WBEM URI of the CIM class path represented by the CIMClassName object.

The returned WBEM URI contains its components as follows:

  • it does not contain a namespace type (URI scheme).
  • it contains an authority component according to the host attribute, if that is not None. Othwerise, it does not contain the authority component.
  • it contains a namespace component according to the namespace attribute, if that is not None. Othwerise, it does not contain the namespace component.
  • it contains a class name component according to the classname attribute.
Parameters:format (string) –

Format for the generated WBEM URI string, using one of the following values:

  • "standard" - Standard format that is conformant to untyped WBEM URIs for class paths defined in DSP0207.
  • "cimobject" - Format for the CIMObject header field in CIM-XML messages for representing class paths (used internally, see DSP0200).
  • "historical" - Historical format for WBEM URIs (used by __str__(); should not be used by new code). The historical format has the following differences to the standard format:
    • If the authority component is not present, the slash after the authority is also omitted. In the standard format, that slash is always present.
    • If the namespace component is not present, the colon after the namespace is also omitted. In the standard format, that colon is always present.

Examples for the standard format:

  • With authority and namespace:

    //acme.com/cimv2/test:CIM_RegisteredProfile
    
  • Without authority but with namespace:

    /cimv2/test:CIM_RegisteredProfile
    
  • Without authority and without namespace:

    /:CIM_RegisteredProfile
    
Returns:Untyped WBEM URI of the CIM class path, in the specified format.
Return type:unicode string

4.2.7. CIMClass

class pywbem.CIMClass(classname, properties=None, methods=None, superclass=None, qualifiers=None, path=None)[source]

A representation of a CIM class in a CIM namespace in a WBEM server, optionally including its class path.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

Parameters:
  • classname (string) –

    Class name of the class.

    Must not be None.

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

  • properties (properties input object) – The property declarations for the class.
  • methods (methods input object) – The method declarations for the class.
  • superclass (string) –

    Name of the superclass for the class.

    None means that the class is a top-level class, and the same-named attribute in the CIMClass object will also be None.

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

  • qualifiers (qualifiers input object) – The qualifiers for the class.
  • path (CIMClassName) –

    New in pywbem 0.11.

    Class path for the class.

    The provided object will be copied before being stored in the CIMClass object.

    None means that the instance path is unspecified, and the same-named attribute in the CIMClass object will also be None.

    This parameter has been added in pywbem 0.11 as a convenience for the user in order so that CIMClass objects can be self-contained w.r.t. their class path.

Raises:
  • ValueError – classname is None, a property, method or qualifier name is None, or a property, method or qualifier name does not match its dictionary key.
  • TypeError – a numeric Python type was used for a qualifier value.
classname

unicode string – Class name of the CIM class.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

superclass

unicode string – Class name of the superclass of the CIM class.

None means that the class is a top-level class.

This attribute is settable. For details, see the description of the same-named constructor parameter.

properties

NocaseDict – Properties (declarations) of the CIM class.

Will not be None.

Each dictionary item specifies one property declaration, with:

The order of properties in the CIM class is preserved.

This attribute is settable; setting it will cause the current CIM properties to be replaced with the new properties. For details, see the description of the same-named constructor parameter.

The CIM properties can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. The provided input value must be a CIMProperty object:

cls = CIMClass(...)
p1 = CIMProperty('p1', ...)  # must be a CIMProperty

cls.properties['p1'] = p1  # Set "p1" to p1 (add if needed)
p1 = cls.properties['p1']  # Access "p1"
del cls.properties['p1']  # Delete "p1" from the class
methods

NocaseDict – Methods (declarations) of the CIM class.

Will not be None.

Each dictionary item specifies one method, with:

The order of methods in the CIM class is preserved.

This attribute is settable; setting it will cause the current CIM methods to be replaced with the new methods. For details, see the description of the same-named constructor parameter.

The CIM methods can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. The provided input value must be a CIMMethod object:

cls = CIMClass(...)
m1 = CIMMethod('m1', ...)  # must be a CIMMethod

cls.methods['m1'] = m1  # Set "m1" to m1 (add if needed)
m1 = cls.methods['m1']  # Access "m1"
del cls.methods['m1']  # Delete "m1" from the class
qualifiers

NocaseDict – Qualifiers (qualifier values) of the CIM class.

Will not be None.

Each dictionary item specifies one qualifier value, with:

The order of qualifiers in the CIM class is preserved.

This attribute is settable; setting it will cause the current qualifiers to be replaced with the new qualifiers. For details, see the description of the same-named constructor parameter.

The qualifier values can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. The provided input value may be specified as a CIM data type or as a CIMQualifier object:

cls = CIMClass(...)
q1 = Uint32(...)  # may be CIM data type or CIMQualifier

cls.qualifiers['q1'] = q1  # Set "q1" to q1 (add if needed)
q1 = cls.qualifiers['q1']  # Access "q1"
del cls.qualifiers['q1']  # Delete "q1" from the class
path

New in pywbem 0.11.

CIMClassName: Class path of the CIM class.

None means that the class path is unspecified.

This attribute has been added in pywbem 0.11 as a convenience for the user in order so that CIMClass objects can be self-contained w.r.t. their class path.

This attribute will be set in in any CIMClass objects returned by WBEMConnection methods, based on information in the response from the WBEM server.

This attribute is settable. For details, see the description of the same-named constructor parameter.

__str__()[source]

Return a short string representation of the CIMClass object for human consumption.

__repr__()[source]

Return a string representation of the CIMClass object that is suitable for debugging.

The order of properties, method and qualifiers will be preserved in the result.

copy()[source]

Return a copy of the CIMClass object.

This is a middle-deep copy; any mutable types in attributes except the following are copied, so besides these exceptions, modifications of the original object will not affect the returned copy, and vice versa. The following mutable types are not copied and are therefore shared between original and copy:

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

tocimxml()[source]

Return the CIM-XML representation of the CIMClass object, as an instance of an appropriate subclass of Element.

The returned CIM-XML representation is a CLASS element consistent with DSP0201. This is the required element for representing embedded classes.

If the class has a class path specified, it will be ignored.

The order of properties, methods, parameters, and qualifiers in the returned CIM-XML representation is preserved from the CIMClass object.

tocimxmlstr(indent=None)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMClass object, as a unicode string.

For the returned CIM-XML representation, see tocimxml().

Parameters:indent (string or integer) –

None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

Returns:The CIM-XML representation of the object, as a unicode string.
tomof(maxline=80)[source]

Return a MOF string with the class definition represented by the CIMClass object.

The returned MOF string conforms to the classDeclaration ABNF rule defined in DSP0004.

The order of properties, methods, parameters, and qualifiers is preserved.

The path attribute of this object will not be included in the returned MOF string.

Consistent with that, class path information is not included in the returned MOF string.

Returns:MOF string.
Return type:unicode string

4.2.8. CIMProperty

class pywbem.CIMProperty(name, value, type=None, class_origin=None, array_size=None, propagated=None, is_array=None, reference_class=None, qualifiers=None, embedded_object=None)[source]

A CIM property (value or declaration).

This object can be used in a CIMInstance object for representing a property value, or in a CIMClass object for representing a property declaration.

For property values in CIM instances:

  • The value attribute is the actual value of the property.
  • Qualifiers are not allowed.

For property declarations in CIM classes:

  • The value attribute is the default value of the property declaration.
  • Qualifiers are allowed.

Scalar (=non-array) properties may have a value of NULL (= None), any primitive CIM data type, reference type, and string type with embedded instance or embedded object.

Array properties may be Null or may have elements with a value of NULL, any primitive CIM data type, and string type with embedded instance or embedded object. Reference types are not allowed in property arrays in CIM, as per DSP0004.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

The constructor infers optional parameters that are not specified (for example, it infers type from the Python type of value and other information). If the specified parameters are inconsistent, an exception is raised. If an optional parameter is needed for some reason, an exception is raised.

Parameters:
  • name (string) –

    Name of the property.

    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 other suitable types) –

    Value of the property (interpreted as actual value when representing a property value, and as default value for property declarations).

    None means that the property is Null, and the same-named attribute in the CIMProperty object will also be None.

    The specified value will be converted to a CIM data type using the rules documented in the description of cimvalue(), taking into account the type parameter.

  • type (string) –

    Name of the CIM data type of the property (e.g. "uint8").

    None will cause the type to be inferred from the value parameter, raising ValueError if it cannot be inferred (for example when value is None or a Python integer).

    ValueError is raised if the type is not a valid CIM data type (see CIM data types).

  • class_origin (string) –

    The CIM class origin of the property (the name of the most derived class that defines or overrides the property in the class hierarchy of the class owning the property).

    None means that class origin information is not available, and the same-named attribute in the CIMProperty object will also be None.

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

  • array_size (integer) –

    The size of the array property, for fixed-size arrays.

    None means that the array property has variable size, and the same-named attribute in the CIMProperty object will also be None.

  • propagated (bool) –

    If not None, indicates whether the property declaration has been propagated from a superclass to this class, or the property value has been propagated from the creation class to this instance (the latter is not really used).

    None means that propagation information is not available, and the same-named attribute in the CIMProperty object will also be None.

  • is_array (bool) –

    A boolean indicating whether the property is an array (True) or a scalar (False).

    None means that it is unspecified whether the property is an array, and the same-named attribute in the CIMProperty object will be inferred from the value parameter. If the value parameter is None, a scalar is assumed.

  • reference_class (string) –

    For reference properties, the name of the class referenced by the property, as declared in the class defining the property (for both, property declarations in CIM classes, and property values in CIM instances).

    None means that the referenced class is unspecified, and the same-named attribute in the CIMProperty object will also be None.

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

    Note: Prior to pywbem 0.11, the corresponding attribute was inferred from the creation class name of a referenced instance. This was incorrect and has been fixed in pywbem 0.11.

  • qualifiers (qualifiers input object) – The qualifiers for the property declaration. Has no meaning for property values.
  • embedded_object (string) –

    A string value indicating the kind of embedded object represented by the property value. Has no meaning for property declarations.

    For details about the possible values, see the corresponding attribute.

    None means that the value is unspecified, causing the same-named attribute in the CIMProperty object to be inferred. An exception is raised if it cannot be inferred.

Examples:

# a string property:
CIMProperty("MyString", "abc")

# a uint8 property:
CIMProperty("MyNum", 42, "uint8")

# a uint8 property:
CIMProperty("MyNum", Uint8(42))

# a uint8 array property:
CIMProperty("MyNumArray", [1, 2, 3], "uint8")

# a reference property:
CIMProperty("MyRef", CIMInstanceName("Foo"))

# an embedded object property containing a class:
CIMProperty("MyEmbObj", CIMClass("Foo"))

# an embedded object property containing an instance:
CIMProperty("MyEmbObj", CIMInstance("Foo"),
            embedded_object="object")

# an embedded instance property:
CIMProperty("MyEmbInst", CIMInstance("Foo"))

# a string property that is Null:
CIMProperty("MyString", None, "string")

# a uint8 property that is Null:
CIMProperty("MyNum", None, "uint8")

# a reference property that is Null:
CIMProperty("MyRef", None, "reference", reference_class="MyClass")

# an embedded object property that is Null:
CIMProperty("MyEmbObj", None, "string", embedded_object="object")

# an embedded instance property that is Null:
CIMProperty("MyEmbInst", None, "string",
            embedded_object="instance")
name

unicode string – Name of the property.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

value

CIM data type – Value of the property (interpreted as actual value when representing a property value, and as default value for property declarations).

None means that the value is Null.

This attribute is settable. For details, see the description of the same-named constructor parameter.

type

unicode string – Name of the CIM data type of the property (e.g. "uint8").

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

reference_class

unicode string – For reference properties, the name of the class referenced by the property, as declared in the class defining the property (for both, property declarations in CIM classes, and property values in CIM instances). None means that the referenced class is unspecified.

For non-reference properties, will be None.

Note that in CIM instances returned from a WBEM server, DSP0201 recommends this attribute not to be set. For CIM classes returned from a WBEM server, DSP0201 requires this attribute to be set.

This attribute is settable. For details, see the description of the same-named constructor parameter.

embedded_object

unicode string – A string value indicating the kind of embedded object represented by the property value.

The following values are defined for this parameter:

  • "instance": The property is declared with the EmbeddedInstance qualifier, indicating that the property value is an embedded instance of the class specified as the value of the EmbeddedInstance qualifier. The property value must be a CIMInstance object, or None.
  • "object": The property is declared with the EmbeddedObject qualifier, indicating that the property value is an embedded object (instance or class) of which the class name is not known. The property value must be a CIMInstance or CIMClass object, or None.
  • None, for properties not representing embedded objects.

This attribute is settable. For details, see the description of the same-named constructor parameter.

is_array

bool – A boolean indicating whether the property is an array (True) or a scalar (False).

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

array_size

integer – The size of the array property, for fixed-size arrays.

None means that the array property has variable size, or that it is not an array.

This attribute is settable. For details, see the description of the same-named constructor parameter.

class_origin

unicode string – The CIM class origin of the property (the name of the most derived class that defines or overrides the property in the class hierarchy of the class owning the property).

None means that class origin information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

propagated

bool – If not None, indicates whether the property declaration has been propagated from a superclass to this class, or the property value has been propagated from the creation class to this instance (the latter is not really used).

None means that propagation information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

qualifiers

NocaseDict – Qualifiers (qualifier values) of the property declaration.

Will not be None.

Each dictionary item specifies one qualifier value, with:

The order of qualifiers in the property is preserved.

This attribute is settable; setting it will cause the current qualifiers to be replaced with the new qualifiers. For details, see the description of the same-named constructor parameter.

The qualifier values can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. The provided input value may be specified as a CIM data type or as a CIMQualifier object:

prop = CIMProperty(...)
q1 = CIMQualifier('q1', ...) # may be CIM data type or CIMQualifier

prop.qualifiers['q1'] = q1  # Set "q1" to q1 (add if needed)
q1 = prop.qualifiers['q1']  # Access "q1"
del prop.qualifiers['q1']  # Delete "q1" from the class
copy()[source]

Return a copy of the CIMProperty object.

This is a middle-deep copy; any mutable types in attributes except the following are copied, so besides these exceptions, modifications of the original object will not affect the returned copy, and vice versa. The following mutable types are not copied and are therefore shared between original and copy:

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

__str__()[source]

Return a short string representation of the CIMProperty object for human consumption.

__repr__()[source]

Return a string representation of the CIMProperty object that is suitable for debugging.

The order of qualifiers will be preserved in the result.

tocimxml()[source]

Return the CIM-XML representation of the CIMProperty object, as an instance of an appropriate subclass of Element.

The returned CIM-XML representation is a PROPERTY, PROPERTY.REFERENCE, or PROPERTY.ARRAY element dependent on the property type, and consistent with DSP0201. Note that array properties cannot be of reference type.

The order of qualifiers in the returned CIM-XML representation is preserved from the CIMProperty object.

tocimxmlstr(indent=None)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMProperty object, as a unicode string.

For the returned CIM-XML representation, see tocimxml().

Parameters:indent (string or integer) –

None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

Returns:The CIM-XML representation of the object, as a unicode string.
tomof(is_instance=True, indent=0, maxline=80, line_pos=0)[source]

New in pywbem 0.9.

Return a MOF fragment with the property definition (for use in a CIM class) or property value (for use in a CIM instance) represented by the CIMProperty object.

Even though pywbem supports qualifiers on CIMProperty objects that are used as property values within an instance, the returned MOF string for property values in instances does not contain any qualifier values.

The order of qualifiers is preserved.

Parameters:
  • is_instance (bool) – If True, return MOF for a property value in a CIM instance. Else, return MOF for a property definition in a CIM class.
  • indent (integer) – Number of spaces to indent each line of the returned string, counted in the line with the property name.
Returns:

MOF fragment.

Return type:

unicode string

4.2.9. CIMMethod

class pywbem.CIMMethod(name=None, return_type=None, parameters=None, class_origin=None, propagated=None, qualifiers=None, methodname=None)[source]

A method (declaration) in a CIM class.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

The constructor stores the input parameters as-is and does not infer unspecified parameters from the others (like CIMProperty does).

Parameters:
  • name (string) –

    Name of the method (just the method name, without class name or parenthesis).

    Must not be None.

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

    Deprecated: This argument has been named methodname before pywbem 0.9. Using methodname as a named argument still works, but has been deprecated in pywbem 0.9.

  • return_type (string) –

    Name of the CIM data type of the method return type (e.g. "uint32").

    Must not be None or "reference".

    ValueError is raised if the type is None, "reference", or not a valid CIM data type (see CIM data types).

    Support for void return types: Pywbem also does not support void return types, consistent with the CIM architecture and MOF syntax (see DSP0004). Note that void return types could be represented in CIM-XML (see DSP0201).

    Support for reference return types: Pywbem does not support reference return types of methods. The CIM architecture and MOF syntax support reference return types, and the CIM-XML protocol supports the invocation of methods with reference return types. However, CIM-XML does not support the representation of class declarations with methods that have reference return types.

    Support for array return types: Pywbem does not support array return types of methods, consistent with the CIM architecture, MOF syntax and CIM-XML.

  • parameters (parameters input object) – Parameter declarations for the method.
  • class_origin (string) –

    The CIM class origin of the method (the name of the most derived class that defines or overrides the method in the class hierarchy of the class owning the method).

    None means that class origin information is not available, and the same-named attribute in the CIMMethod object will also be None.

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

  • propagated (bool) –

    If not None, indicates whether the method has been propagated from a superclass to this class.

    None means that propagation information is not available, and the same-named attribute in the CIMMethod object will also be None.

  • qualifiers (qualifiers input object) – The qualifiers for the method.
name

unicode string – Name of the method.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

return_type

unicode string – Name of the CIM data type of the method return type (e.g. "uint32").

Will not be None or "reference".

This attribute is settable. For details, see the description of the same-named constructor parameter.

class_origin

unicode string – The CIM class origin of the method (the name of the most derived class that defines or overrides the method in the class hierarchy of the class owning the method).

None means that class origin information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

propagated

bool – If not None, indicates whether the method has been propagated from a superclass to this class.

None means that propagation information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

parameters

NocaseDict – Parameters of the method.

Will not be None.

Each dictionary item specifies one parameter, with:

The order of parameters in the method is preserved.

This attribute is settable; setting it will cause the current parameters to be replaced with the new parameters. For details, see the description of the same-named constructor parameter.

The parameters can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. The provided input value must be a CIMParameter object:

meth = CIMMethod(...)
p1 = CIMParameter('p1', ...)  # must be a CIMParameter

meth.parameters['p1'] = p1  # Set "p1" to p1 (add if needed)
p1 = meth.parameters['p1']  # Access "p1"
del meth.parameters['p1']  # Delete "p1" from the class
qualifiers

NocaseDict – Qualifiers (qualifier values) of the method.

Will not be None.

Each dictionary item specifies one qualifier value, with:

The order of qualifiers in the method is preserved.

This attribute is settable; setting it will cause the current qualifiers to be replaced with the new qualifiers. For details, see the description of the same-named constructor parameter.

The qualifier values can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. The provided input value may be specified as a CIM data type or as a CIMQualifier object:

meth = CIMMethod(...)
q1 = "..."  # may be CIM data type or CIMQualifier

meth.qualifiers['q1'] = q1  # Set "q1" to q1 (add if needed)
q1 = meth.qualifiers['q1']  # Access "q1"
del meth.qualifiers['q1']  # Delete "q1" from the class
__str__()[source]

Return a short string representation of the CIMMethod object for human consumption.

__repr__()[source]

Return a string representation of the CIMMethod object that is suitable for debugging.

The order of parameters and qualifiers will be preserved in the result.

copy()[source]

Return a copy of the CIMMethod object.

This is a middle-deep copy; any mutable types in attributes except the following are copied, so besides these exceptions, modifications of the original object will not affect the returned copy, and vice versa. The following mutable types are not copied and are therefore shared between original and copy:

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

tocimxml()[source]

Return the CIM-XML representation of the CIMMethod object, as an instance of an appropriate subclass of Element.

The returned CIM-XML representation is a METHOD element consistent with DSP0201.

The order of parameters and qualifiers in the returned CIM-XML representation is preserved from the CIMMethod object.

tocimxmlstr(indent=None)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMMethod object, as a unicode string.

For the returned CIM-XML representation, see tocimxml().

Parameters:indent (string or integer) –

None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

Returns:The CIM-XML representation of the object, as a unicode string.
tomof(indent=0, maxline=80)[source]

Return a MOF fragment with the method definition represented by the CIMMethod object.

The order of parameters and qualifiers is preserved.

Parameters:indent (integer) – Number of spaces to indent each line of the returned string, counted in the line with the method name.
Returns:MOF fragment.
Return type:unicode string

4.2.10. CIMParameter

class pywbem.CIMParameter(name, type, reference_class=None, is_array=None, array_size=None, qualifiers=None, value=None, embedded_object=None)[source]

A CIM parameter (value or declaration).

This object can be used as parameter value in the InvokeMethod() operation, and as a parameter declaration in a CIMMethod object.

For parameter values in method invocations:

  • The value attribute is the actual value of the parameter.
  • Qualifiers are not allowed.

For parameter declarations in method declarations:

  • The value attribute is ignored.
  • Qualifiers are allowed.

Scalar (=non-array) parameters and items in array parameters may have a value of NULL (= None), any primitive CIM data type, reference type, or string type with embedded instance or embedded object.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

The constructor stores the input parameters as-is and does not infer unspecified parameters from the others (like CIMProperty does).

Parameters:
  • name (string) –

    Name of the parameter.

    Must not be None.

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

  • type (string) –

    Name of the CIM data type of the parameter (e.g. "uint8").

    Must not be None.

    ValueError is raised if the type is None or not a valid CIM data type (see CIM data types).

  • reference_class (string) –

    For reference parameters, the name of the class referenced by the parameter, as declared in the class defining the method.

    None means that the referenced class is unspecified, and the same-named attribute in the CIMParameter object will also be None.

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

  • is_array (bool) –

    A boolean indicating whether the parameter is an array (True) or a scalar (False).

    None means that it is unspecified whether the parameter is an array, and the same-named attribute in the CIMParameter object will be inferred from the value parameter. If the value parameter is None, a scalar is assumed.

  • array_size (integer) –

    The size of the array parameter, for fixed-size arrays.

    None means that the array parameter has variable size, and the same-named attribute in the CIMParameter object will also be None.

  • qualifiers (qualifiers input object) – The qualifiers for the parameter.
  • value

    The value of the CIM method parameter for the method invocation. Has no meaning for parameter declarations.

    The specified value will be converted to a CIM data type using the rules documented in the description of cimvalue(), taking into account the type parameter.

  • embedded_object (string) –

    A string value indicating the kind of embedded object represented by the parameter value (i.e. the value parameter). Has no meaning for parameter declarations.

    For details about the possible values, see the corresponding attribute.

    None means that the value is unspecified, causing the same-named attribute in the CIMParameter object to be inferred from the parameter value (i.e. the value parameter). An exception is raised if it cannot be inferred.

name

unicode string – Name of the parameter.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

type

unicode string – Name of the CIM data type of the parameter (e.g. "uint8").

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

reference_class

unicode string – For reference parameters, the name of the class referenced by the parameter, as declared in the class defining the parameter. None means that the referenced class is unspecified.

For non-reference parameters, will be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

is_array

bool – A boolean indicating whether the parameter is an array (True) or a scalar (False).

None means that it is unspecified whether the parameter is an array.

This attribute is settable. For details, see the description of the same-named constructor parameter.

array_size

integer – The size of the array parameter, for fixed-size arrays.

None means that the array parameter has variable size, or that it is not an array.

This attribute is settable. For details, see the description of the same-named constructor parameter.

qualifiers

NocaseDict – Qualifiers (qualifier values) of the parameter.

Will not be None.

Each dictionary item specifies one qualifier value, with:

The order of qualifiers in the parameter is preserved.

This attribute is settable; setting it will cause the current qualifiers to be replaced with the new qualifiers. For details, see the description of the same-named constructor parameter.

The qualifier values can also be accessed and manipulated one by one because the attribute value is a modifiable dictionary. The provided input value may be specified as a CIM data type or as a CIMQualifier object:

parm = CIMParameter(...)
q1 = True  # may be CIM data type or CIMQualifier

parm.qualifiers['q1'] = q1  # Set "q1" to q1 (add if needed)
q1 = parm.qualifiers['q1']  # Access "q1"
del parm.qualifiers['q1']  # Delete "q1" from the class
value

The value of the CIM method parameter for the method invocation. Has no meaning for parameter declarations.

This attribute is settable. For details, see the description of the same-named constructor parameter.

embedded_object

unicode string – A string value indicating the kind of embedded object represented by the parameter value. Has no meaning for parameter declarations.

The following values are defined for this parameter:

  • "instance": The parameter is declared with the EmbeddedInstance qualifier, indicating that the parameter value is an embedded instance of the class specified as the value of the EmbeddedInstance qualifier. The property value must be a CIMInstance object, or None.
  • "object": The parameter is declared with the EmbeddedObject qualifier, indicating that the parameter value is an embedded object (instance or class) of which the class name is not known. The parameter value must be a CIMInstance or CIMClass object, or None.
  • None, for parameters not representing embedded objects.

This attribute is settable. For details, see the description of the same-named constructor parameter.

__str__()[source]

Return a short string representation of the CIMParameter object for human consumption.

__repr__()[source]

Return a string representation of the CIMParameter object that is suitable for debugging.

The order of qualifiers will be preserved in the result.

copy()[source]

Return a copy of the CIMParameter object.

This is a middle-deep copy; any mutable types in attributes except the following are copied, so besides these exceptions, modifications of the original object will not affect the returned copy, and vice versa. The following mutable types are not copied and are therefore shared between original and copy:

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

tocimxml(as_value=False)[source]

Return the CIM-XML representation of the CIMParameter object, either as a parameter declaration for use in a method declaration, or as a parameter value for use in a method invocation.

If a parameter value is to be returned, the returned CIM-XML representation is a PARAMVALUE element with child elements dependent on the parameter type, and consistent with DSP0201.

If a parameter declaration is to be returned, the returned CIM-XML representation is a PARAMETER, PARAMETER.REFERENCE, PARAMETER.ARRAY, or PARAMETER.REFARRAY element dependent on the parameter type, and consistent with DSP0201.

The order of qualifiers in the returned CIM-XML representation of a parameter declaration is preserved from the CIMParameter object.

Parameters:as_value (bool) – If True, return the object as a parameter value. Otherwise, return the object as a parameter declaration.
Returns:The CIM-XML representation of the object, as an appropriate subclass of Element.
tocimxmlstr(indent=None, as_value=False)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMParameter object, either as a parameter declaration for use in a method declaration, or as a parameter value for use in a method invocation.

For the returned CIM-XML representation, see tocimxml().

Parameters:
  • indent (string or integer) –

    None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

    Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

  • as_value (bool) – If True, return the object as a parameter value. Otherwise, return the object as a parameter declaration.
Returns:

The CIM-XML representation of the object, as a unicode string.

tomof(indent=0, maxline=80)[source]

Return a MOF fragment with the parameter definition represented by the CIMParameter object.

The object is always interpreted as a parameter declaration; so the value and embedded_object attributes are ignored.

The order of qualifiers is preserved.

Parameters:indent (integer) – Number of spaces to indent each line of the returned string, counted in the line with the parameter name.
Returns:MOF fragment.
Return type:unicode string

4.2.11. CIMQualifier

class pywbem.CIMQualifier(name, value, type=None, propagated=None, overridable=None, tosubclass=None, toinstance=None, translatable=None)[source]

A CIM qualifier value.

A qualifier represents metadata on a class, method, property, etc., and specifies information such as a documentation string or whether a property is a key.

CIMQualifier objects can be used to represent the qualifier values that are specified on a CIM element (e.g. on a CIM class). In that case, the propagated property is always False, and the effective values of applicable but unspecified qualifiers need to be determined by users, by considering the default value of the corresponding qualifier type, the propagation and override flavors of the qualifier, and the qualifier values that have been specified in the class ancestry of the CIM element in question.

CIMQualifier objects can also be used to represent the effective values of all applicable qualifiers on a CIM element, including those that have not been specified, e.g. in the MOF declaration of the CIM element. In this case, the CIMQualifier objects for qualifier values that are specified in MOF represent the specified values, and their propagated property is False. The CIMQualifier objects for qualifier values that are not specified in MOF represent the effective values, and their propagated property is True.

Whether a set of CIMQualifier objects on a CIM object represents just the specified qualifiers or all applicable qualifiers needs to be known from the context.

CIMQualifier has properties that represent qualifier flavors (tosubclass, toinstance, overridable, and translatable). If any of these flavor properties is not None, the qualifier value represented by the CIMQualifier object implicitly defines a qualifier type. Implicitly defined qualifier types have been deprecated in DSP0004. The implicitly defined qualifier type is conceptual and is not materialized as a CIMQualifierDeclaration object.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

The constructor infers optional parameters that are not specified (for example, it infers type from the Python type of value and other information). If the specified parameters are inconsistent, an exception is raised. If an optional parameter is needed for some reason, an exception is raised.

Parameters:
  • name (string) –

    Name of the qualifier.

    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 other suitable types) –

    Value of the qualifier.

    None means that the qualifier is Null, and the same-named attribute in the CIMQualifier object will also be None.

    The specified value will be converted to a CIM data type using the rules documented in the description of cimvalue(), taking into account the type parameter.

  • type (string) –

    Name of the CIM data type of the qualifier (e.g. "uint8").

    None will cause the type to be inferred from the value parameter, raising ValueError if it cannot be inferred (for example when value is None or a Python integer).

    ValueError is raised if the type is not a valid CIM data type (see CIM data types).

  • propagated (bool) –

    If not None, specifies whether the qualifier value has been propagated from a superclass to this class.

    None means that this information is not available, and the same-named attribute in the CIMQualifier object will also be None.

  • overridable (bool) –

    If not None, specifies whether the qualifier value is overridable in subclasses.

    None means that this information is not available, and the same-named attribute in the CIMQualifier object will also be None.

  • tosubclass (bool) –

    If not None, specifies whether the qualifier value propagates to subclasses.

    None means that this information is not available, and the same-named attribute in the CIMQualifier object will also be None.

  • toinstance (bool) –

    If not None, specifies whether the qualifier value propagates to instances.

    None means that this information is not available, and the same-named attribute in the CIMQualifier object will also be None.

    Note that DSP0200 has deprecated the presence of qualifier values on CIM instances.

  • translatable (bool) –

    If not None, specifies whether the qualifier is translatable.

    None means that this information is not available, and the same-named attribute in the CIMQualifier object will also be None.

Examples:

# a string qualifier:
CIMQualifier("MyString", "abc")

# a uint8 qualifier:
CIMQualifier("MyNum", 42, "uint8")

# a uint8 qualifier:
CIMQualifier("MyNum", Uint8(42))

# a uint8 array qualifier:
CIMQualifier("MyNumArray", [1, 2, 3], "uint8")

# a string qualifier that is Null:
CIMQualifier("MyString", None, "string")

# a uint8 qualifier that is Null:
CIMQualifier("MyNum", None, "uint8")
name

unicode string – Name of the qualifier.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

type

unicode string – Name of the CIM data type of the qualifier (e.g. "uint8").

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

value

CIM data type – Value of the qualifier.

None means that the value is Null.

For CIM data types string and char16, this attribute will be a unicode string, even when specified as a byte string in the constructor.

This attribute is settable. For details, see the description of the same-named constructor parameter.

propagated

bool – Indicates whether the qualifier value has been propagated from a superclass to this class.

None means that propagation information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

tosubclass

bool – If not None, causes an implicit qualifier type to be defined for this qualifier that has the specified flavor.

If True, specifies the ToSubclass flavor (the qualifier value propagates to subclasses); if False specifies the Restricted flavor (the qualifier values does not propagate to subclasses).

None means that this information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

toinstance

bool – If not None, causes an implicit qualifier type to be defined for this qualifier that has the specified flavor.

If True specifies the ToInstance flavor(the qualifier value propagates to instances. If False, specifies that qualifier values do not propagate to instances. There is no flavor corresponding to toinstance=False.

None means that this information is not available.

Note that DSP0200 has deprecated the presence of qualifier values on CIM instances.

This attribute is settable. For details, see the description of the same-named constructor parameter.

overridable

bool – If not None, causes an implicit qualifier type to be defined for this qualifier that has the specified flavor.

If True, specifies the EnableOverride flavor(the qualifier value is overridable in subclasses); if False specifies the DisableOverride flavor(the qualifier value is not overridable in subclasses).

None means that this information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

translatable

bool – If not None, causes an implicit qualifier type to be defined for this qualifier that has the specified flavor.

If True, specifies the Translatable flavor (the qualifier is translatable); if False specifies that the qualfier is not translatable. There is no flavor corresponding to translatable=False.

None means that this information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

__str__()[source]

Return a short string representation of the CIMQualifier object for human consumption.

__repr__()[source]

Return a string representation of the CIMQualifier object that is suitable for debugging.

copy()[source]

Return a copy of the CIMQualifier object.

Objects of this class have no mutable types in any attributes, so modifications of the original object will not affect the returned copy, and vice versa.

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

tocimxml()[source]

Return the CIM-XML representation of the CIMQualifier object, as an instance of an appropriate subclass of Element.

The returned CIM-XML representation is a QUALIFIER element consistent with DSP0201.

tocimxmlstr(indent=None)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMQualifier object, as a unicode string.

For the returned CIM-XML representation, see tocimxml().

Parameters:indent (string or integer) –

None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

Returns:The CIM-XML representation of the object, as a unicode string.
tomof(indent=3, maxline=80, line_pos=0)[source]

Return a MOF fragment with the qualifier value represented by the CIMQualifier object.

The items of array values are tried to keep on the same line. If the generated line would exceed the maximum MOF line length, the value is split into multiple lines, on array item boundaries, and/or within long strings on word boundaries.

If a string value (of a scalar value, or of an array item) is split into multiple lines, the first line of the value is put onto a line on its own.

Parameters:indent (integer) – For a multi-line result, the number of spaces to indent each line except the first line (on which the qualifier name appears). For a single-line result, ignored.
Returns:MOF fragment.
Return type:unicode string

4.2.12. CIMQualifierDeclaration

class pywbem.CIMQualifierDeclaration(name, type, value=None, is_array=False, array_size=None, scopes=None, overridable=None, tosubclass=None, toinstance=None, translatable=None)[source]

A CIM qualifier type is the declaration of a qualifier and defines the attributes of qualifier name, qualifier type, value, scopes, and flavors for the qualifier.

The scope of a qualifer determines the kinds of schema elements on which it can be specified.

Value specifies the default value for the qualifier.

Flavors specify certain characteristics of the qualifier such as its value propagation from the ancestry of the qualified element and its translatability.

Flavors attributes must be specifically set on construction of the CIMQualifierDeclaration or they will be set to None. This differs from the DMTF specification DSP0004 where default values are defined as follows:

  • Has the EnableOverride flavor; overridable = True
  • Has the ToSubClass flavor; tosubclass = True
  • Does not have theTranslatable flavor; translatable = False
  • Does not have ToInstance flavor; toinstance = False. Not defined in DSP0004 and deprecated in the DMTF protocol specification DSP0200

Because None is allowed as a value for the flavors attributes in constructing a CIMQualifierDeclaration, the user must insure that any flavor which has the value None is set to its default value if required for subsequent processing.

The pywbem MOF compiler supplies all of the flavor values so that those which were not specified in the MOF are set to the DMTF defined default values.

Two objects of this class compare equal if their public attributes compare equal. Objects of this class are unchanged-hashable, with the hash value being based on its public attributes. Therefore, objects of this class can be used as members in a set (or as dictionary keys) only during periods in which their public attributes remain unchanged.

Parameters:
  • name (string) –

    Name of the qualifier.

    Must not be None.

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

  • type (string) –

    Name of the CIM data type of the qualifier (e.g. "uint8").

    Must not be None.

    ValueError is raised if the type is None or not a valid CIM data type (see CIM data types).

  • value (CIM data type or other suitable types) –

    Default value of the qualifier.

    None means a default value of Null, and the same-named attribute in the CIMQualifierDeclaration object will also be None.

    The specified value will be converted to a CIM data type using the rules documented in the description of cimvalue(), taking into account the type parameter.

  • is_array (bool) –

    A boolean indicating whether the qualifier is an array (True) or a scalar (False).

    None means that it is unspecified whether the qualifier is an array, and the same-named attribute in the CIMQualifierDeclaration object will be inferred from the value parameter. If the value parameter is None, a scalar is assumed.

  • array_size (integer) –

    The size of the array qualifier, for fixed-size arrays.

    None means that the array qualifier has variable size, and the same-named attribute in the CIMQualifierDeclaration object will also be None.

  • scopes (dict or NocaseDict) –

    Scopes of the qualifier.

    A shallow copy of the provided dictionary will be stored in the CIMQualifierDeclaration object.

    Each dictionary item specifies one scope value, with:

    • key (string): Scope name, in upper case.

      Must not be None.

    • value (bool): Scope value, specifying whether the qualifier has that scope (i.e. can be applied to a CIM element of that kind).

    Valid scope names are “CLASS”, “ASSOCIATION”, “REFERENCE”, “PROPERTY”, “METHOD”, “PARAMETER”, “INDICATION”, and “ANY”.

    None is interpreted as an empty set of scopes.

    For details about the dictionary items, see the corresponding attribute.

  • overridable (bool) –

    If not None, defines the flavor that defines whether the qualifier value is overridable in subclasses.

    None means that this information is not available, and the same-named attribute in the CIMQualifierDeclaration object will also be None.

  • tosubclass (bool) –

    If not None, specifies the flavor that defines whether the qualifier value propagates to subclasses.

    None means that this information is not available, and the same-named attribute in the CIMQualifierDeclaration object will also be None.

  • toinstance (bool) –

    If not None, specifies the flavor that defines whether the qualifier value propagates to instances.

    None means that this information is not available, and the same-named attribute in the CIMQualifierDeclaration object will also be None.

    Note that DSP0200 has deprecated the presence of qualifier values on CIM instances and this flavor is not defined in DSP0004

  • translatable (bool) –

    If not None, specifies the flavor that defines whether the qualifier is translatable.

    None means that this information is not available, and the same-named attribute in the CIMQualifierDeclaration object will also be None.

name

unicode string – Name of the qualifier.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

type

unicode string – Name of the CIM data type of the qualifier (e.g. "uint8").

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

value

CIM data type – Default value of the qualifier.

None means that the value is Null.

For CIM data types string and char16, this attribute will be a unicode string, even when specified as a byte string in the constructor.

This attribute is settable. For details, see the description of the same-named constructor parameter.

is_array

bool – A boolean indicating whether the qualifier is an array (True) or a scalar (False).

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

array_size

integer – The size of the array qualifier, for fixed-size arrays.

None means that the array qualifier has variable size, or that it is not an array.

This attribute is settable. For details, see the description of the same-named constructor parameter.

scopes

NocaseDict – Scopes of the qualifier.

Each dictionary item specifies one scope value, with:

  • key (unicode string): Scope name, in upper case.
  • value (bool): Scope value, specifying whether the qualifier has that scope (i.e. can be applied to a CIM element of that kind).

Valid scope names are “CLASS”, “ASSOCIATION”, “INDICATION”, “PROPERTY”, “REFERENCE”, “METHOD”, “PARAMETER”, and “ANY”.

Will not be None.

This attribute is settable. For details, see the description of the same-named constructor parameter.

tosubclass

bool – If True specifies the ToSubclass flavor (the qualifier value propagates to subclasses); if False specifies the Restricted flavor (the qualifier value does not propagate to subclasses).

None means that this information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

toinstance

bool – If True, specifies the ToInstance flavor. This flavor specifies that the qualifier value propagates to instances. If False, specifies that qualifier values do not propagate to instances. There is no flavor corresponding to toinstance=False.

None means that this information is not available.

Note that DSP0200 has deprecated the presence of qualifier values on CIM instances.

This attribute is settable. For details, see the description of the same-named constructor parameter.

overridable

bool – If True, specifies the EnableOverride flavor (the qualifier value is overridable in subclasses); if False specifies the DisableOverride flavor (the qualifier value is not overridable in subclasses).

None means that this information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

translatable

bool – If True, specifies the Translatable flavor. This flavor specifies that the qualifier is translatable. If False, specifies that the qualfier is not translatable. There is no flavor corresponding to translatable=False.

None means that this information is not available.

This attribute is settable. For details, see the description of the same-named constructor parameter.

__str__()[source]

Return a short string representation of the CIMQualifierDeclaration object for human consumption.

__repr__()[source]

Return a string representation of the CIMQualifierDeclaration object that is suitable for debugging.

The scopes will be ordered by their names in the result.

copy()[source]

Return a copy the CIMQualifierDeclaration object.

Objects of this class have no mutable types in any attributes, so modifications of the original object will not affect the returned copy, and vice versa.

Note that the Python functions copy.copy() and copy.deepcopy() can be used to create completely shallow or completely deep copies of objects of this class.

tocimxml()[source]

Return the CIM-XML representation of the CIMQualifierDeclaration object, as an instance of an appropriate subclass of Element.

The returned CIM-XML representation is a QUALIFIER.DECLARATION element consistent with DSP0201.

tocimxmlstr(indent=None)[source]

New in pywbem 0.9.

Return the CIM-XML representation of the CIMQualifierDeclaration object, as a unicode string.

For the returned CIM-XML representation, see tocimxml().

Parameters:indent (string or integer) –

None indicates that a single-line version of the XML should be returned, without any whitespace between the XML elements.

Other values indicate that a prettified, multi-line version of the XML should be returned. A string value specifies the indentation string to be used for each level of nested XML elements. An integer value specifies an indentation string of so many blanks.

Returns:The CIM-XML representation of the object, as a unicode string.
tomof(maxline=80)[source]

Return a MOF string with the qualifier type declaration represented by the CIMQualifierDeclaration object.

The returned MOF string conforms to the qualifierDeclaration ABNF rule defined in DSP0004.

Qualifier flavors are included in the returned MOF string only when the information is available (i.e. the value of the corresponding attribute is not None).

Because DSP0004 does not support instance qualifiers, and thus does not define a flavor keyword for the toinstance attribute, that flavor is not included in the returned MOF string.

Returns:MOF string.
Return type:unicode string