item_updater: Look for BMC inventory interface

There were some TODOs to more efficiently find the BMC inventory
object. The pending issues have been resolved so update the code
to search for the BMC inventory interface from the whole
inventory root path.

Change-Id: I4331814bb6b9cc8e8b0bba7b85c8d75b8c1bacf6
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/configure.ac b/configure.ac
index 548b361..749f537 100755
--- a/configure.ac
+++ b/configure.ac
@@ -53,7 +53,10 @@
 
 AC_DEFINE(ACTIVATION_FWD_ASSOCIATION, "inventory", [The name of the activation's forward association.])
 AC_DEFINE(ACTIVATION_REV_ASSOCIATION, "activation", [The name of the activation's reverse association.])
-AC_DEFINE(CHASSIS_INVENTORY_PATH, "/xyz/openbmc_project/inventory/system/chassis/", [The chassis inventory path root.])
+AC_DEFINE(INVENTORY_PATH, "/xyz/openbmc_project/inventory/",
+    [The inventory path root.])
+AC_DEFINE(BMC_INVENTORY_INTERFACE, "xyz.openbmc_project.Inventory.Item.Bmc",
+    [The BMC inventory interface])
 
 AC_DEFINE(ACTIVE_FWD_ASSOCIATION, "active", [The name of the active's forward association.])
 AC_DEFINE(ACTIVE_REV_ASSOCIATION, "software_version", [The name of the active's reverse association.])
diff --git a/item_updater.cpp b/item_updater.cpp
index bbfdef4..df53747 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -533,20 +533,15 @@
 
 void ItemUpdater::setBMCInventoryPath()
 {
-    //TODO: openbmc/openbmc#1786 - Get the BMC path by looking for objects
-    //      that implement the BMC inventory interface
     auto depth = 0;
     auto mapperCall = bus.new_method_call(MAPPER_BUSNAME,
                                           MAPPER_PATH,
                                           MAPPER_INTERFACE,
                                           "GetSubTreePaths");
 
-    mapperCall.append(CHASSIS_INVENTORY_PATH);
+    mapperCall.append(INVENTORY_PATH);
     mapperCall.append(depth);
-
-    // TODO: openbmc/openbmc#2226 - Add Inventory Item filter when
-    //       mapper is fixed.
-    std::vector<std::string> filter = {};
+    std::vector<std::string> filter = {BMC_INVENTORY_INTERFACE};
     mapperCall.append(filter);
 
     auto response = bus.call(mapperCall);
@@ -560,21 +555,12 @@
     ObjectPaths result;
     response.read(result);
 
-    if (result.empty())
+    if (!result.empty())
     {
-        log<level::ERR>("Invalid response from mapper");
-        return;
+        bmcInventoryPath = result.front();
     }
 
-    for (auto& iter : result)
-    {
-        const auto& path = iter;
-        if (path.substr(path.find_last_of('/') + 1).compare("bmc") == 0)
-        {
-            bmcInventoryPath = path;
-            return;
-        }
-    }
+    return;
 }
 
 void ItemUpdater::createActiveAssociation(const std::string& path)