Skip to content

Commit

Permalink
Added config option SEND_NULL_VALUE.
Browse files Browse the repository at this point in the history
Details:

- In order to provide for backwards compatibility to WBEM servers that
  do not support VALUE.NULL, a config option SEND_VALUE_NULL was added
  that by default sends VALUE.NULL, but allows for disabling that.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Apr 3, 2018
1 parent 018a565 commit bf8fa25
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,10 @@ Bug fixes
`CIMProperty`, `CIMQualifier` and `CIMQualifierDeclaration` represented
NULL entries in array values using an empty `VALUE` element. They now
correctly generate the `VALUE.NULL` element for NULL entries (Issue #1136).
In order to provide for backwards compatibility to WBEM servers that
do not support VALUE.NULL, a config option SEND_VALUE_NULL was added
that by default sends VALUE.NULL, but allows for disabling that
(Issue #1144).

* Fixed the error that the special float values `INF`, `-INF` and `NaN`
were represented in lower case in CIM-XML. DSP0201 requires the
Expand Down
32 changes: 25 additions & 7 deletions pywbem/cim_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class (the parent object) has a list of CIM properties, CIM methods and CIM
import six

from . import cim_xml
from .config import DEBUG_WARNING_ORIGIN
from .config import DEBUG_WARNING_ORIGIN, SEND_VALUE_NULL
from .cim_types import _CIMComparisonMixin, type_from_name, cimtype, \
atomic_to_cim_xml, CIMType, CIMDateTime, Uint8, Sint8, Uint16, Sint16, \
Uint32, Sint32, Uint64, Sint64, Real32, Real64, number_types, CIMInt, \
Expand Down Expand Up @@ -4887,7 +4887,10 @@ def tocimxml(self):
array_xml = []
for v in self.value:
if v is None:
array_xml.append(cim_xml.VALUE_NULL())
if SEND_VALUE_NULL:
array_xml.append(cim_xml.VALUE_NULL())
else:
array_xml.append(cim_xml.VALUE(None))
elif self.embedded_object is not None:
assert isinstance(v, (CIMInstance, CIMClass))
array_xml.append(cim_xml.VALUE(v.tocimxml().toxml()))
Expand Down Expand Up @@ -6118,7 +6121,10 @@ def tocimxml(self, as_value=False):
array_xml = []
for v in self.value:
if v is None:
array_xml.append(cim_xml.VALUE_NULL())
if SEND_VALUE_NULL:
array_xml.append(cim_xml.VALUE_NULL())
else:
array_xml.append(cim_xml.VALUE(None))
else:
array_xml.append(
cim_xml.VALUE_REFERENCE(v.tocimxml()))
Expand All @@ -6129,7 +6135,10 @@ def tocimxml(self, as_value=False):
array_xml = []
for v in self.value:
if v is None:
array_xml.append(cim_xml.VALUE_NULL())
if SEND_VALUE_NULL:
array_xml.append(cim_xml.VALUE_NULL())
else:
array_xml.append(cim_xml.VALUE(None))
elif self.embedded_object is not None:
array_xml.append(
cim_xml.VALUE(v.tocimxml().toxml()))
Expand Down Expand Up @@ -6727,7 +6736,10 @@ def tocimxml(self):
array_xml = []
for v in self.value:
if v is None:
array_xml.append(cim_xml.VALUE_NULL())
if SEND_VALUE_NULL:
array_xml.append(cim_xml.VALUE_NULL())
else:
array_xml.append(cim_xml.VALUE(None))
else:
array_xml.append(cim_xml.VALUE(atomic_to_cim_xml(v)))
value_xml = cim_xml.VALUE_ARRAY(array_xml)
Expand Down Expand Up @@ -7364,7 +7376,10 @@ def tocimxml(self):
array_xml = []
for v in self.value:
if v is None:
array_xml.append(cim_xml.VALUE_NULL())
if SEND_VALUE_NULL:
array_xml.append(cim_xml.VALUE_NULL())
else:
array_xml.append(cim_xml.VALUE(None))
else:
array_xml.append(cim_xml.VALUE(atomic_to_cim_xml(v)))
value_xml = cim_xml.VALUE_ARRAY(array_xml)
Expand Down Expand Up @@ -7527,7 +7542,10 @@ def tocimxml(value):
array_xml = []
for v in value:
if v is None:
array_xml.append(cim_xml.VALUE_NULL())
if SEND_VALUE_NULL:
array_xml.append(cim_xml.VALUE_NULL())
else:
array_xml.append(cim_xml.VALUE(None))
else:
array_xml.append(cim_xml.VALUE(atomic_to_cim_xml(v)))
value_xml = cim_xml.VALUE_ARRAY(array_xml)
Expand Down
28 changes: 27 additions & 1 deletion pywbem/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

# This module is meant to be safe for 'import *'.

__all__ = ['ENFORCE_INTEGER_RANGE', 'DEFAULT_ITER_MAXOBJECTCOUNT']
__all__ = ['ENFORCE_INTEGER_RANGE', 'DEFAULT_ITER_MAXOBJECTCOUNT',
'SEND_VALUE_NULL']

#: Enforce the allowable value range for CIM integer types (e.g.
#: :class:`~pywbem.Uint8`). For details, see the :class:`~pywbem.CIMInt` base
Expand Down Expand Up @@ -67,3 +68,28 @@
#: Add a stack traceback to the message text of most warnings issued by pywbem.
#: This allows identifying which code originated the warning.
DEBUG_WARNING_ORIGIN = False

#: Backwards compatibility option controlling the use of `VALUE.NULL` for
#: representing NULL entries in array values in CIM-XML requests sent to WBEM
#: servers.
#:
#: :term:`DSP0201` requires the use of `VALUE.NULL` for representing NULL
#: entries in array values since its version 2.2 (released 01/2007). Pywbem
#: added support for using `VALUE.NULL` in CIM-XML requests in its version
#: 0.12. In case a WBEM server has not implemented support for `VALUE.NULL`,
#: this config option can be used to disable the use of `VALUE.NULL` as a
#: means for backwards compatibility with such WBEM servers.
#:
#: Note that the config option only influences the behavior of pywbem for
#: using `VALUE.NULL` in CIM-XML requests sent to a WBEM server. Regardless of
#: the config option, pywbem will always support `VALUE.NULL` in CIM-XML
#: responses the pywbem client receives from a WBEM server, and in CIM-XML
#: requests the pywbem listener receives from a WBEM server.
#:
#: * True (default): Pywbem uses `VALUE.NULL` in CIM-XML requests for
#: representing NULL entries in array values.
#: * False: Pywbem uses `VALUE` with an empty value in CIM-XML requests for
#: representing NULL entries in array values.
#:
#: *New in pywbem 0.12.*
SEND_VALUE_NULL = True

0 comments on commit bf8fa25

Please sign in to comment.