Change association tuple to "monitoring, monitored_by, bmc"

Per the discussion in 46081, we need a way to differentiate between
"Host CPU usage" and "BMC CPU usage" for the DBus objects. Associations
has been used previously for this purpose, so the association for the
health utility "sensors" are changed accordingly for this purpose.

From existing systems, some examples of existing association edge names
may include:
 - "chassis": from a DBus sensor to a Chassis/Board inventory
 - "all_sensors": the reverse of "chassis"
 - "inventory": from a voltage sensor to a board
 - "updateable", "active", "functional": from /software to a
   particular version
 - "software_version": reverse of the above three
 - "containedby": from a module to a module container
 - "contains": reverse of above

Considering existing association names and the "Requirements and
Expectations for dbus interfaces" document, we name the association
edges "monitoring" and "monitored_by". This association tuple is to be
interpreted as "the utilization sensors are monitoring the current BMC;
the current BMC is monitored by the utilization sensors".

Signed-off-by: Sui Chen <suichen@google.com>
Change-Id: Ib0c634df83beacb7acac1dc7885ba47e58523a79
diff --git a/healthMonitor.hpp b/healthMonitor.hpp
index b86563e..321e3a5 100644
--- a/healthMonitor.hpp
+++ b/healthMonitor.hpp
@@ -6,10 +6,14 @@
 #include <sdeventplus/event.hpp>
 #include <sdeventplus/utility/timer.hpp>
 #include <xyz/openbmc_project/Association/Definitions/server.hpp>
+#include <xyz/openbmc_project/Inventory/Item/Bmc/server.hpp>
 #include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp>
 #include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp>
 #include <xyz/openbmc_project/Sensor/Value/server.hpp>
 
+constexpr char BMC_INVENTORY_ITEM[] = "xyz.openbmc_project.Inventory.Item.Bmc";
+constexpr char BMC_CONFIGURATION[] = "xyz.openbmc_project.Configuration.Bmc";
+
 #include <deque>
 #include <limits>
 #include <map>
@@ -60,6 +64,9 @@
     sdbusplus::server::object_t<ValueIface, CriticalInterface, WarningInterface,
                                 AssociationDefinitionInterface>;
 
+using BmcInterface = sdbusplus::server::object::object<
+    sdbusplus::xyz::openbmc_project::Inventory::Item::server::Bmc>;
+
 using AssociationTuple = std::tuple<std::string, std::string, std::string>;
 
 struct HealthConfig
@@ -128,6 +135,15 @@
     void startUnit(const std::string& sysdUnit);
 };
 
+class BmcInventory : public BmcInterface
+{
+  public:
+    BmcInventory() = delete;
+    BmcInventory(sdbusplus::bus::bus& bus, const char* objPath) :
+        BmcInterface(bus, objPath)
+    {}
+};
+
 class HealthMon
 {
   public:
@@ -166,6 +182,13 @@
     /** @brief Create sensors for health monitoring */
     void createHealthSensors(const std::vector<std::string>& bmcIds);
 
+    /** @brief Create the BMC Inventory object */
+    void createBmcInventoryIfNotCreated();
+
+    std::shared_ptr<BmcInventory> bmcInventory;
+
+    bool bmcInventoryCreated();
+
   private:
     sdbusplus::bus_t& bus;
     std::vector<HealthConfig> sensorConfigs;