fanctl: Add query_dump cmd to search dump contents

Add a 'query_dump' subcommand to fanctl to assist in looking at the
content of the dump file /tmp/fan_control.json generated by the 'fanctl
dump' command.  This dump file contains the flight recorder as well as
fan control's objects, service, and parameter cache.

The command's output is in JSON.

It has the following parameters:
--section
   The section of the dump: objects, parameters, or services

--name
   The name of the top level JSON dictionary key to match on.
   This can match on substrings, like 'sensors' for all sensors.
   Optional - if not provided it matches on every name.

--properties
   List of property names to match on.
   Geared toward printing property values from the objects cache.
   Optional, if not provided the whole JSON objects under the
   name is printed.

Examples:

Print the flight recorder:
fanctl query_dump --section flight_recorder
{
    "0": "Oct 29 03:41:29.468444: main: Startup"
}

Print the altitude:
fanctl query_dump -s objects -n Altitude -p Value
{
    "/xyz/openbmc_project/sensors/altitude/Altitude": {
        "Value": 1032.82
    }
}

Print all temperatures:
fanctl query_dump -s objects -n sensors/temp -p Value
{
    "/xyz/openbmc_project/sensors/temperature/Ambient_Virtual_Temp": {
        "Value": 25.0
    },
    ...
}

Print every interface and property of the ambient sensor
fanctl query_dump -s objects -n Ambient
{
   ... interfaces with their property names and values ...
}

Print every Value property in the cache:
fanctl query_dump -s objects -p Value
{
    "/xyz/openbmc_project/sensors/altitude/Altitude": {
        "Value": 1032.82
    },
    "/xyz/openbmc_project/sensors/temperature/Ambient_Virtual_Temp": {
        "Value": 25.0
    }
}

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: If66a74b432481f337f02813f2e61ae5767a57d1d
3 files changed