Skip to content

Commit

Permalink
Fixed default and returned values of propagated & flavor attrs of CIM…
Browse files Browse the repository at this point in the history
… objects

Details:

* Fixed the incorrect default value for the `propagated` constructor parameter
  of `CIMMethod`. Previously, the default value was `False` and it has been
  corrected to be `None`, consistent with its meaning of "information not
  available".
  The only CIM operations that take a `CIMMethod` object as input are
  `CreateClass()` and `ModifyClass()` (as part of the class that is created
  or modified). Because WBEM servers must ignore the `propagated` information
  on any elements in the provided class, this change is backwards compatible
  for the CIM operations. (Issue #1039).

* Added support for setting the `propagated` attribute on `CIMQualifier`
  objects returned from CIM operations to a default of `False` when it is
  not specified in the CIM-XML response, consistent with DSP0201, and
  consistent with how it was already done for other CIM objects.
  This change should normally be backwards compatible for pywbem users,
  because they don't even know whether the information has been set by
  the server or defaulted by the client as it is now done. (Issue #1039).

* Added support for setting the flavor attributes on `CIMQualifier` and
  `CIMQUalifierDeclaration` objects returned from CIM operations to their
  default values defined in CIM-XML, when they are not specified in the
  CIM-XML response, consistent with DSP0201, and consistent with how it
  was already done for other CIM objects.
  This change should normally be backwards compatible for pywbem users,
  because they don't even know whether the information has been set by
  the server or defaulted by the client as it is now done. (Issue #1039).

* Adjusted the test cases of tupleparser, test_client, and CIM objects
  accordingly.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Feb 11, 2018
1 parent 6af01ed commit fda1145
Show file tree
Hide file tree
Showing 11 changed files with 884 additions and 495 deletions.
27 changes: 27 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,33 @@ Bug fixes
tolerated and treated as `False`. They now cause `ParseError` to be raised
(Issue #1041).

* Fixed the incorrect default value for the `propagated` constructor parameter
of `CIMMethod`. Previously, the default value was `False` and it has been
corrected to be `None`, consistent with its meaning of "information not
available".
The only CIM operations that take a `CIMMethod` object as input are
`CreateClass()` and `ModifyClass()` (as part of the class that is created
or modified). Because WBEM servers must ignore the `propagated` information
on any elements in the provided class, this change is backwards compatible
for the CIM operations. (Issue #1039).

* Added support for setting the `propagated` attribute on `CIMQualifier`
objects returned from CIM operations to a default of `False` when it is
not specified in the CIM-XML response, consistent with DSP0201, and
consistent with how it was already done for other CIM objects.
This change should normally be backwards compatible for pywbem users,
because they don't even know whether the information has been set by
the server or defaulted by the client as it is now done. (Issue #1039).

* Added support for setting the flavor attributes on `CIMQualifier` and
`CIMQUalifierDeclaration` objects returned from CIM operations to their
default values defined in CIM-XML, when they are not specified in the
CIM-XML response, consistent with DSP0201, and consistent with how it
was already done for other CIM objects.
This change should normally be backwards compatible for pywbem users,
because they don't even know whether the information has been set by
the server or defaulted by the client as it is now done. (Issue #1039).

Cleanup
^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion pywbem/cim_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -5044,7 +5044,7 @@ class can be used as members in a set (or as dictionary keys) only during

# pylint: disable=too-many-arguments
def __init__(self, name=None, return_type=None, parameters=None,
class_origin=None, propagated=False, qualifiers=None,
class_origin=None, propagated=None, qualifiers=None,
methodname=None):
"""
The constructor stores the input parameters as-is and does not infer
Expand Down
57 changes: 25 additions & 32 deletions pywbem/tupleparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,15 +1126,6 @@ def parse_qualifier_declaration(tup_tree):
# TODO #1044: Clarify if hex support is needed.
array_size = int(array_size)

flavors = {}
for flavor in ['OVERRIDABLE', 'TOSUBCLASS', 'TOINSTANCE', 'TRANSLATABLE']:
try:
flavors[flavor.lower()] = unpack_boolean(attrl[flavor])
except KeyError:
# This causes the flavor not to be set, so it results in the
# default value defined in the CIMQualifierDeclaration() ctor (None)
pass

scopes = None
value = None
for child in kids(tup_tree):
Expand All @@ -1152,8 +1143,17 @@ def parse_qualifier_declaration(tup_tree):
(name(tup_tree), name(child)))
value = unpack_value(tup_tree)

return CIMQualifierDeclaration(qname, _type, value, is_array,
array_size, scopes, **flavors)
overridable = unpack_boolean(attrl.get('OVERRIDABLE', 'true'))
tosubclass = unpack_boolean(attrl.get('TOSUBCLASS', 'true'))
toinstance = unpack_boolean(attrl.get('TOINSTANCE', 'false'))
translatable = unpack_boolean(attrl.get('TRANSLATABLE', 'false'))

qual_decl = CIMQualifierDeclaration(
qname, _type, value, is_array, array_size, scopes,
overridable=overridable, tosubclass=tosubclass,
toinstance=toinstance, translatable=translatable)

return qual_decl


def parse_qualifier(tup_tree):
Expand All @@ -1178,28 +1178,21 @@ def parse_qualifier(tup_tree):
# The 'xml:lang' attribute is tolerated but ignored.

attrl = attrs(tup_tree)
val = unpack_value(tup_tree)

qual = CIMQualifier(attrl['NAME'], val, type=attrl['TYPE'])

for i in ['OVERRIDABLE', 'TOSUBCLASS', 'TOINSTANCE',
'TRANSLATABLE', 'PROPAGATED']:
rtn_val = attrl.get(i, None)
if rtn_val is not None:
rtn_val = rtn_val.lower()

# TODO #1039: Clarify whether to default omitted qualifier flavors
if rtn_val == 'true':
rtn_val = True
elif rtn_val == 'false':
rtn_val = False
elif rtn_val is None:
pass
else:
raise ParseError("Invalid value %r for %s on %s" %
(rtn_val, i, name(tup_tree)))
qname = attrl['NAME']
_type = attrl['TYPE']

value = unpack_value(tup_tree)

propagated = unpack_boolean(attrl.get('PROPAGATED', 'false'))
overridable = unpack_boolean(attrl.get('OVERRIDABLE', 'true'))
tosubclass = unpack_boolean(attrl.get('TOSUBCLASS', 'true'))
toinstance = unpack_boolean(attrl.get('TOINSTANCE', 'false'))
translatable = unpack_boolean(attrl.get('TRANSLATABLE', 'false'))

setattr(qual, i.lower(), rtn_val)
qual = CIMQualifier(qname, value, _type,
propagated=propagated, overridable=overridable,
tosubclass=tosubclass, toinstance=toinstance,
translatable=translatable)

return qual

Expand Down
2 changes: 1 addition & 1 deletion testsuite/test_cim_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -12145,7 +12145,7 @@ def test_CIMMethod_init_name_methodname(self):
default_exp_attrs = dict(
parameters=NocaseDict(),
class_origin=None,
propagated=False,
propagated=None,
qualifiers=NocaseDict(),
)

Expand Down
Loading

0 comments on commit fda1145

Please sign in to comment.