Monitor : handle inventory service offline
Using nameHasOwner and nameOwnerChanged D-Bus signals, a callback is
activated when inventory is started.
There are two primary modes for operation: Compatible Interfaces, the
inventory-detection callback will fail, however start() will be called a
second time after EntityManager starts and forces a reload of the proper
config for the machine type. Separately, if no EntityManager exists,
then the callback for Inventory-detection will succeed and use the
default configuration file.
To test: stop fan monitor and inventory services. start monitor, wait
10s, start Inventory, after about 15s you should see the online
detection.
Signed-off-by: Mike Capps <mikepcapps@gmail.com>
Change-Id: I289493a0aabb849abee8ce8de047513e94ee2219
diff --git a/monitor/system.hpp b/monitor/system.hpp
index 328c958..3997807 100644
--- a/monitor/system.hpp
+++ b/monitor/system.hpp
@@ -113,11 +113,25 @@
}
/**
- * @brief Parses and populates the fan monitor trust groups and list of fans
+ * @brief tests the presence of Inventory and calls load() if present, else
+ * waits for Inventory asynchronously and has a callback to load() when
+ * present
*/
void start();
+ /**
+ * @brief Parses and populates the fan monitor trust groups and list of fans
+ */
+ void load();
+
private:
+ /**
+ * @brief Callback from D-Bus when Inventory service comes online
+ *
+ * @param[in] msg - Service details.
+ */
+ void inventoryOnlineCb(sdbusplus::message::message& msg);
+
/* The mode of fan monitor */
Mode _mode;
@@ -130,6 +144,9 @@
/* Trust manager of trust groups */
std::unique_ptr<phosphor::fan::trust::Manager> _trust;
+ /* match object to detect Inventory service */
+ std::unique_ptr<sdbusplus::bus::match::match> _inventoryMatch;
+
/* List of fan objects to monitor */
std::vector<std::unique_ptr<Fan>> _fans;
@@ -173,9 +190,9 @@
std::vector<std::unique_ptr<sdbusplus::bus::match::match>> _sensorMatch;
/**
- * @brief If start() has been called
+ * @brief true if config files have been loaded
*/
- bool _started = false;
+ bool _loaded = false;
/**
* @brief Captures tach sensor data as JSON for use in