Create objects for running PSUs

On service startup, create activation and version objects for running
PSUs, and set related active, functional associations.

If multiple PSUs are running with the same software version, they share
the same DBus object, and the object will be associated to multiple PSU
inventories.

Tested: Verify the software objects are created on Witherspoon, and the
        active, functional associations are created.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: Ia8372aba8299818baccfdf37e98fdbc99f747b7c
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index aacd77f..6df7624 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -45,13 +45,7 @@
                      std::bind(std::mem_fn(&ItemUpdater::createActivation),
                                this, std::placeholders::_1))
     {
-        // TODO: create psu inventory objects based on the paths
-        using namespace phosphor::logging;
-        auto paths = utils::getPSUInventoryPath(bus);
-        for (const auto& p : paths)
-        {
-            log<level::INFO>("PSU path", entry("PATH=%s", p.c_str()));
-        }
+        processPSUImage();
     }
 
     /** @brief Deletes version
@@ -73,12 +67,12 @@
      */
     void createActiveAssociation(const std::string& path);
 
-    /** @brief Updates the functional association to the
+    /** @brief Add the functional association to the
      *  new "running" PSU images
      *
-     * @param[in]  versionId - The id of the image to update the association to.
+     * @param[in]  path - The path to add the association to.
      */
-    void updateFunctionalAssociation(const std::string& versionId);
+    void addFunctionalAssociation(const std::string& path);
 
     /** @brief Removes the associations from the provided software image path
      *
@@ -93,6 +87,13 @@
      */
     void createActivation(sdbusplus::message::message& msg);
 
+    /** @brief Callback function for PSU inventory match.
+     *  @details Update an Activation D-Bus object for PSU inventory.
+     *
+     * @param[in]  msg       - Data associated with subscribed signal
+     */
+    void onPsuInventoryChanged(sdbusplus::message::message& msg);
+
     /** @brief Create Activation object */
     std::unique_ptr<Activation> createActivationObject(
         const std::string& path, const std::string& versionId,
@@ -110,6 +111,15 @@
                                 Version::VersionPurpose versionPurpose,
                             const std::string& filePath);
 
+    /** @brief Create Activation and Version object for PSU inventory */
+    void createPsuObject(const std::string& psuInventoryPath,
+                         const std::string& psuVersion);
+
+    /**
+     * @brief Create and populate the active PSU Version.
+     */
+    void processPSUImage();
+
     /** @brief Persistent sdbusplus D-Bus bus connection. */
     sdbusplus::bus::bus& bus;
 
@@ -121,9 +131,12 @@
      * version id */
     std::map<std::string, std::unique_ptr<Version>> versions;
 
-    /** @brief sdbusplus signal match for Software.Version */
+    /** @brief sdbusplus signal match for PSU Software*/
     sdbusplus::bus::match_t versionMatch;
 
+    /** @brief sdbusplus signal matches for PSU Inventory */
+    std::vector<sdbusplus::bus::match_t> psuMatches;
+
     /** @brief This entry's associations */
     AssociationList assocs;
 };