presence: Create ErrorReporter class

This class will, eventually, create event logs for missing fans.

This first commit will just create a stubbed out class if there is a
'reporting' section in the configuration JSON.  From the JSON, the class
will pull out the value for the number of seconds to wait between first
detecting a fan is missing and creating the event log for it.

This requires a slight change to the existing JSON format, however the
JsonConfig class was updated to support both the old and new formats.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I991ea7cf0457448411e65f4c8e274bb2584d15f4
diff --git a/presence/json_parser.cpp b/presence/json_parser.cpp
index 83267a7..23420b6 100644
--- a/presence/json_parser.cpp
+++ b/presence/json_parser.cpp
@@ -88,11 +88,25 @@
 {
     policies policies;
     std::vector<fanPolicy> fans;
+    const json* fanJSON;
+
+    // The original JSON had the fan array at the root, but the new JSON
+    // has it under a 'fans' element.  Support both.
+    // This can be removed after the new JSON is in the image.
+    if (jsonConf.is_array())
+    {
+        fanJSON = &jsonConf;
+    }
+    else
+    {
+        fanJSON = &jsonConf["fans"];
+    }
+
     // Set the expected number of fan entries
     // to be size of the list of fan json config entries
     // (Must be done to eliminate vector reallocation of fan references)
-    fans.reserve(jsonConf.size());
-    for (auto& member : jsonConf)
+    fans.reserve(fanJSON->size());
+    for (auto& member : *fanJSON)
     {
         if (!member.contains("name") || !member.contains("path") ||
             !member.contains("methods") || !member.contains("rpolicy"))
@@ -159,6 +173,13 @@
 
     _policies.clear();
     _policies.swap(policies);
+
+    // Create the error reporter class if necessary
+    if (jsonConf.contains("reporting"))
+    {
+        _reporter = std::make_unique<ErrorReporter>(
+            _bus, jsonConf.at("reporting"), _fans);
+    }
 }
 
 std::unique_ptr<RedundancyPolicy>