Explicitly convert dbus.Booleans to bools

The dbus.Boolean data type that the dbus python module uses for
booleans is based on an int, so the JSON encoder class serializes
it to a 1 and 0 instead of the native JSON bool presentation of
true and false.  Though the encoder module does allow for custom
serialization functions, it only does so for data types that it
doesn't recognize, and it does recognize a dbus.Boolean though it
thinks it's an int.

To get around this limitation, walk the response dictionary
object and convert all dbus.Booleans to bools before encoding
the response.  The only time that data is copied is when a boolean
is in a dbus.Struct, which is an immutable tuple, so it will be
made into a list during revision before converting it back when
complete.

There is a slight performance penalty to pay for this.  Measurements
showed enumerating the whole /xyz/openbmc_project tree take about
1 second longer.

Resolves openbmc/openbmc#3154

Tested:  Lots of REST calls and output inspection.

Change-Id: I591f010798a80aeafd02289e3d35c335540f6562
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
1 file changed
tree: eb646e7aed71f4f09c1c06508209282f9f5950a5
  1. module/
  2. servers/
  3. LICENSE
  4. MAINTAINERS