monitor: Add ability to delay finding conf file

In the future, fan monitor will start as part of multi-user.target
starting, possibly before entity-manager starting.  Since, when
configured to use JSON, an entity-manager provided D-Bus interface is
needed to find the config file, the code needs to be able to wait for
that to show up on D-Bus before starting monitoring.

This commit allows one to instantiate an instance of the JsonConfig
class, which before only had static methods.  One of the arguments to
the constructor is a function to call when the config file is available.

The constructor will attempt to find the config file in the override and
default paths in the filesystem, followed by using the
IBMCompatibleSystem interface to build up the path to it.  If a config
file with any of those paths exists, it will call the passed in function
right then, otherwise it will use an interfacesAdded D-Bus watch to wait
for the IBMCompatibleSystem interface to show up to try again.

Previously the code would check for a config file based on the
IBMCompatibleSystem data before looking for a default file, and this
commit swaps the order of that since only one of those should be there
anyway so it doesn't matter which is checked first.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I577b18df498f4d1526a9da83b3407cf55208419d
1 file changed