Add updateable association to active BMC FW object

Add 'updateable' association to the active BMC
firmware version object. This 'updateable' association
can be used to mark all the firmware components
which can be programmable from BMC interfaces like
Redfish.

Tested:
 - Able to query the updateable endpoint objects.
Req:
 busctl call xyz.openbmc_project.ObjectMapper
 /xyz/openbmc_project/software/updateable
 org.freedesktop.DBus.Properties Get ss
 xyz.openbmc_project.Association endpoints

Res:
 v as 1 "/xyz/openbmc_project/software/1201fc36"

- Get on FirmwareInventory shows correct value
  for 'Updateable' property. Redfish support is
  added as new commit.

 URI: /redfish/v1/UpdateService/FirmwareInventory/1201fc36
 Res: Can see "Updateable": true output

Change-Id: Id74a134dacdea86399d10fbe0a4b0e62728d1cf4
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/activation.cpp b/activation.cpp
index 4b715e4..ab76420 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -185,6 +185,10 @@
                 // Create active association
                 parent.createActiveAssociation(path);
 
+                // Create updateable association as this
+                // can be re-programmed.
+                parent.createUpdateableAssociation(path);
+
                 if (Activation::checkApplyTimeImmediate() == true)
                 {
                     log<level::INFO>("Image Active. ApplyTime is immediate, "
diff --git a/configure.ac b/configure.ac
index 403ea8d..5fba420 100755
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,9 @@
 AC_DEFINE(FUNCTIONAL_FWD_ASSOCIATION, "functional", [The name of the functional forward association.])
 AC_DEFINE(FUNCTIONAL_REV_ASSOCIATION, "software_version", [The functional reverse association.])
 
+AC_DEFINE(UPDATEABLE_FWD_ASSOCIATION, "updateable", [The name of the updateable forward association.])
+AC_DEFINE(UPDATEABLE_REV_ASSOCIATION, "software_version", [The updateable reverse association.])
+
 AC_ARG_VAR(VERSION_BUSNAME, [The Dbus busname to own])
 AS_IF([test "x$VERSION_BUSNAME" == "x"], [VERSION_BUSNAME="xyz.openbmc_project.Software.Version"])
 AC_DEFINE_UNQUOTED([VERSION_BUSNAME], ["$VERSION_BUSNAME"], [The DBus busname to own])
diff --git a/item_updater.cpp b/item_updater.cpp
index 4f2b833..7fe69e4 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -221,6 +221,10 @@
                 createActiveAssociation(path);
             }
 
+            // All updateable firmware components must expose the updateable
+            // association.
+            createUpdateableAssociation(path);
+
             // Create Version instance for this version.
             auto versionPtr = std::make_unique<VersionClass>(
                 bus, path, version, purpose, "",
@@ -553,6 +557,13 @@
     associations(assocs);
 }
 
+void ItemUpdater::createUpdateableAssociation(const std::string& path)
+{
+    assocs.emplace_back(std::make_tuple(UPDATEABLE_FWD_ASSOCIATION,
+                                        UPDATEABLE_REV_ASSOCIATION, path));
+    associations(assocs);
+}
+
 void ItemUpdater::removeAssociations(const std::string& path)
 {
     for (auto iter = assocs.begin(); iter != assocs.end();)
diff --git a/item_updater.hpp b/item_updater.hpp
index 52607bc..0664a70 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -202,6 +202,13 @@
      */
     void createFunctionalAssociation(const std::string& path);
 
+    /** @brief Creates a updateable association to the
+     *  "running" BMC software image
+     *
+     * @param[in]  path - The path to create the association.
+     */
+    void createUpdateableAssociation(const std::string& path);
+
     /** @brief Persistent sdbusplus D-Bus bus connection. */
     sdbusplus::bus::bus& bus;