Skip updateable association for functional BMC

The updateable association should only be created for non-functional
BMCs for dual image systems, otherwise create the updateable association
by default for single image systems. Add object path to version class as
it will be needed for update interface and updateable association
creation.

Tested:
```
> curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/UpdateService/FirmwareInventory/3c956be0
{
  "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/3c956be0",
  "@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
  "Description": "BMC image",
  "Id": "3c956be0",
  "Name": "Software Inventory",
  "RelatedItem": [
    {
      "@odata.id": "/redfish/v1/Managers/bmc"
    }
  ],
  "RelatedItem@odata.count": 1,
  "Status": {
    "Health": "OK",
    "HealthRollup": "OK",
    "State": "Enabled"
  },
  "Updateable": true,
  "Version": "2.16.0-dev-1063-g57294f9ba2-dirty"
}
```
Updateable is marked true for inventory with update interface.

Change-Id: I93b6a6ae36e2d0a06e8f5f97d04007da7707f1d6
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 356a2ac..351fc4c 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -376,10 +376,6 @@
                 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, extendedVersion, flashId,
@@ -403,12 +399,6 @@
                 id, std::make_unique<Activation>(
                         bus, path, *this, id, activationState, associations)));
 
-            // Create Update object for this version.
-            if (useUpdateDBusInterface)
-            {
-                createUpdateObject(id, path);
-            }
-
 #ifdef BMC_STATIC_DUAL_IMAGE
             uint8_t priority;
             if ((functional && (runningImageSlot == 0)) ||
@@ -452,6 +442,21 @@
         }
     }
 
+    for (const auto& version : versions)
+    {
+        if ((versions.size() == 1) || (!version.second->isFunctional()))
+        {
+            // This is the only BMC version or the non-functional BMC version
+            // (in a system with more than one flash), hence create Update
+            // object and Updateable association for this version
+            if (useUpdateDBusInterface)
+            {
+                createUpdateObject(version.first, version.second->objPath);
+            }
+            createUpdateableAssociation(version.second->objPath);
+        }
+    }
+
     if (!functionalFound)
     {
         // If there is no functional version found, read the /etc/os-release and
diff --git a/version.hpp b/version.hpp
index 77b20f7..bb66341 100644
--- a/version.hpp
+++ b/version.hpp
@@ -87,7 +87,8 @@
             const std::string& id) :
         VersionInherit(bus, (objPath).c_str(),
                        VersionInherit::action::defer_emit),
-        eraseCallback(std::move(callback)), id(id), versionStr(versionString)
+        eraseCallback(std::move(callback)), id(id), objPath(objPath),
+        versionStr(versionString)
     {
         // Set properties.
         extendedVersion(extVersion);
@@ -186,6 +187,9 @@
     /** @brief The version ID of the object */
     const std::string id;
 
+    /** @brief The path of the object */
+    std::string objPath;
+
   private:
     /** @brief This Version's version string */
     const std::string versionStr;