monitor:JSON: Find and load JSON configuration
Using the JSON config utility to find and load the appropriate JSON
configuration file, the JSON parsed object is returned. This object will
be what's used to parse each section of fan monitor's configuration.
Tested:
JSON configuration file found and loaded at each possible location
Change-Id: I718ad3daa240d654ecee3733ebca2d7743ba9d17
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/main.cpp b/monitor/main.cpp
index 74cc62d..e8b736b 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -13,8 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#include "config.h"
+
#include "argument.hpp"
#include "fan.hpp"
+#ifdef MONITOR_USE_JSON
+#include "json_parser.hpp"
+#endif
#include "fan_defs.hpp"
#include "trust_manager.hpp"
@@ -53,13 +59,16 @@
return 1;
}
- std::unique_ptr<phosphor::fan::trust::Manager> trust =
- std::make_unique<phosphor::fan::trust::Manager>(trustGroups);
-
// Attach the event object to the bus object so we can
// handle both sd_events (for the timers) and dbus signals.
bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
+#ifdef MONITOR_USE_JSON
+ // Get JSON object from monitor JSON config file
+ const auto& jsonObj = getJsonObj(bus);
+#else
+ auto trust = std::make_unique<phosphor::fan::trust::Manager>(trustGroups);
+
for (const auto& fanDef : fanDefinitions)
{
// Check if a condition exists on the fan
@@ -75,6 +84,7 @@
fans.emplace_back(
std::make_unique<Fan>(mode, bus, event, trust, fanDef));
}
+#endif
if (mode == Mode::init)
{