Do not query JSON to determine system VPD

This commit removes the dependency on the VPD JSON to
determine if an inventory items is to be classified as
belonging to "system" VPD. The prior code would use the
"isSystemVpd" key from the JSON to determine this, but this
leads to inconsistencies where some sub-items may not have
this flag set. The net result being, it would cause us
to skip certain actions such as resetting GPIOs/setting the
right udev environment variable when collecting system VPD.

By using the system VPD eeprom path - which is the same for
all IBM systems, we get rid of the JSON dependency.

Tested: I ran with this fix and verified that the udev environment
variable check/set if properly performed now, as is priming the
inventory when we collect system VPD.

Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: I7d6f8b108fa9bb131760a8fde7d6264fea67b627
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index 1e98a56..b268ce3 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -432,10 +432,10 @@
         for (auto& itemEEPROM : itemFRUS.value())
         {
             inventory::InterfaceMap interfaces;
-            auto isSystemVpd = itemEEPROM.value("isSystemVpd", false);
             inventory::Object object(itemEEPROM.at("inventoryPath"));
 
-            if (!isSystemVpd && !itemEEPROM.value("noprime", false))
+            if ((itemFRUS.key() != systemVpdFilePath) &&
+                !itemEEPROM.value("noprime", false))
             {
                 inventory::PropertyMap presProp;
                 presProp.emplace("Present", false);
@@ -718,12 +718,36 @@
     // map to hold all the keywords whose value has been changed at standby
     vector<RestoredEeproms> updatedEeproms = {};
 
-    bool isSystemVpd = false;
+    bool isSystemVpd = (filePath == systemVpdFilePath);
+    if constexpr (is_same<T, Parsed>::value)
+    {
+        if (isSystemVpd)
+        {
+            std::vector<std::string> interfaces = {motherBoardInterface};
+            // call mapper to check for object path creation
+            MapperResponse subTree =
+                getObjectSubtreeForInterfaces(pimPath, 0, interfaces);
+            string mboardPath =
+                js["frus"][filePath].at(0).value("inventoryPath", "");
+
+            // Attempt system VPD restore if we have a motherboard
+            // object in the inventory.
+            if ((subTree.size() != 0) &&
+                (subTree.find(pimPath + mboardPath) != subTree.end()))
+            {
+                updatedEeproms = restoreSystemVPD(vpdMap, mboardPath);
+            }
+            else
+            {
+                log<level::ERR>("No object path found");
+            }
+        }
+    }
+
     for (const auto& item : js["frus"][filePath])
     {
         const auto& objectPath = item["inventoryPath"];
         sdbusplus::message::object_path object(objectPath);
-        isSystemVpd = item.value("isSystemVpd", false);
 
         // Populate the VPD keywords and the common interfaces only if we
         // are asked to inherit that data from the VPD, else only add the
@@ -732,28 +756,6 @@
         {
             if constexpr (is_same<T, Parsed>::value)
             {
-                if (isSystemVpd)
-                {
-                    std::vector<std::string> interfaces = {
-                        motherBoardInterface};
-                    // call mapper to check for object path creation
-                    MapperResponse subTree =
-                        getObjectSubtreeForInterfaces(pimPath, 0, interfaces);
-
-                    // Attempt system VPD restore if we have a motherboard
-                    // object in the inventory.
-                    if ((subTree.size() != 0) &&
-                        (subTree.find(pimPath + std::string(objectPath)) !=
-                         subTree.end()))
-                    {
-                        updatedEeproms = restoreSystemVPD(vpdMap, objectPath);
-                    }
-                    else
-                    {
-                        log<level::ERR>("No object path found");
-                    }
-                }
-
                 // Each record in the VPD becomes an interface and all
                 // keyword within the record are properties under that
                 // interface.
@@ -957,7 +959,7 @@
             cout << "Path after translation: " << file << "\n";
 
             if ((js["frus"].find(file) != js["frus"].end()) &&
-                (js["frus"][file].at(0).value("isSystemVpd", false)))
+                (file == systemVpdFilePath))
             {
                 return 0;
             }