Create an association to host inventory item

Create an association from /xyz/openbmc_project/software/<id>
to /xyz/openbmc_project/inventory/system/chassis for Host
software images.

Change-Id: Ic0d690f86c164fd3441ad6475cce5e07208d899e
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/activation.hpp b/activation.hpp
index 7ab4e14..fa27086 100755
--- a/activation.hpp
+++ b/activation.hpp
@@ -16,6 +16,8 @@
 namespace updater
 {
 
+using AssociationList =
+        std::vector<std::tuple<std::string, std::string, std::string>>;
 using ActivationInherit = sdbusplus::server::object::object<
     sdbusplus::xyz::openbmc_project::Object::server::Delete,
     sdbusplus::xyz::openbmc_project::Software::server::ExtendedVersion,
@@ -182,13 +184,15 @@
          * @param[in] versionId  - The software version id
          * @param[in] extVersion - The extended version
          * @param[in] activationStatus - The status of Activation
+         * @param[in] assocs - Association objects
          */
         Activation(sdbusplus::bus::bus& bus, const std::string& path,
                    ItemUpdater& parent,
                    std::string& versionId,
                    std::string& extVersion,
                    sdbusplus::xyz::openbmc_project::Software::
-                   server::Activation::Activations activationStatus) :
+                   server::Activation::Activations activationStatus,
+                   AssociationList& assocs) :
                    ActivationInherit(bus, path.c_str(), true),
                    bus(bus),
                    path(path),
@@ -209,6 +213,8 @@
             // Set Properties.
             extendedVersion(extVersion);
             activation(activationStatus);
+            associations(assocs);
+
             // Emit deferred signal.
             emit_object_added();
         }
diff --git a/configure.ac b/configure.ac
index 33c941d..9bfb226 100755
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,10 @@
 AS_IF([test "x$SOFTWARE_OBJPATH" == "x"], [SOFTWARE_OBJPATH="/xyz/openbmc_project/software"])
 AC_DEFINE_UNQUOTED([SOFTWARE_OBJPATH], ["$SOFTWARE_OBJPATH"], [The software manager Dbus root])
 
+AC_DEFINE(ACTIVATION_FWD_ASSOCIATION, "activation", [The name of the activation's forward association.])
+AC_DEFINE(ACTIVATION_REV_ASSOCIATION, "inventory", [The name of the activation's reverse association.])
+AC_DEFINE(HOST_INVENTORY_PATH, "/xyz/openbmc_project/inventory/system/chassis", [The host inventory path.])
+
 AC_DEFINE(VERSION_IFACE, "xyz.openbmc_project.Software.Version",
     [The software version manager interface])
 AC_DEFINE(FILEPATH_IFACE, "xyz.openbmc_project.Common.FilePath",
diff --git a/item_updater.cpp b/item_updater.cpp
index dd313a8..e14bdee 100755
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -106,6 +106,13 @@
         std::string extendedVersion = (Version::getValue(manifestPath.string(),
                  std::map<std::string, std::string>
                  {{"extended_version", ""}})).begin()->second;
+
+        // Create an association to the host inventory item
+        AssociationList associations{(std::make_tuple(
+                                          ACTIVATION_FWD_ASSOCIATION,
+                                          ACTIVATION_REV_ASSOCIATION,
+                                          HOST_INVENTORY_PATH))};
+
         activations.insert(std::make_pair(
                 versionId,
                 std::make_unique<Activation>(
@@ -114,7 +121,8 @@
                         *this,
                         versionId,
                         extendedVersion,
-                        activationState)));
+                        activationState,
+                        associations)));
         versions.insert(std::make_pair(
                             versionId,
                             std::make_unique<Version>(
@@ -180,6 +188,13 @@
             auto purpose = server::Version::VersionPurpose::Host;
             auto path = fs::path(SOFTWARE_OBJPATH) / id;
 
+
+            // Create an association to the host inventory item
+            AssociationList associations{(std::make_tuple(
+                                              ACTIVATION_FWD_ASSOCIATION,
+                                              ACTIVATION_REV_ASSOCIATION,
+                                              HOST_INVENTORY_PATH))};
+
             // Create Activation instance for this version.
             activations.insert(std::make_pair(
                                    id,
@@ -189,7 +204,8 @@
                                        *this,
                                        id,
                                        extendedVersion,
-                                       activationState)));
+                                       activationState,
+                                       associations)));
 
             // If Active, create RedundancyPriority instance for this version.
             if (activationState == server::Activation::Activations::Active)