Remove FRU vs Module VPD Handling

Some keywords were arbitrarily chosen to serve as FRU VPD
for dual chip modules (DCM - same FRU with two VPD chips).

However, since we expose both chips in such FRUs as
unique inventory items as well as unique Redfish endpoints,
having one of them serve as the VPD for the entire FRU makes
little sense.

This commit gets rid of all the complexity added to handle
DCMs. There is no need for the "inheritEI" and "type" keys
in the inventory JSONs too.

Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: Ia89a44f91daac01f53748409a7633612de8930d6
diff --git a/examples/sample_vpd_inventory_for_recollcetion.json b/examples/sample_vpd_inventory_for_recollcetion.json
index 164c52f..8523164 100644
--- a/examples/sample_vpd_inventory_for_recollcetion.json
+++ b/examples/sample_vpd_inventory_for_recollcetion.json
@@ -389,18 +389,6 @@
           "powerOffOnly" : true,
           "offset": 196608,
           "size": 65504,
-          "type": "fruAndModule",
-          "extraInterfaces": {
-              "xyz.openbmc_project.Inventory.Item.Cpu": null,
-              "com.ibm.ipzvpd.Location" : {
-                  "LocationCode" : "Ufcs-P0-C15"
-              }
-          }
-      },
-      {
-          "inventoryPath": "/system/chassis/motherboard/cpu1",
-          "inheritEI": false,
-          "type": "moduleOnly",
           "extraInterfaces": {
               "xyz.openbmc_project.Inventory.Item.Cpu": null,
               "com.ibm.ipzvpd.Location" : {
@@ -416,7 +404,6 @@
           "offset": 196608,
           "size": 65504,
           "inherit": false,
-          "type": "moduleOnly",
           "extraInterfaces": {
               "xyz.openbmc_project.Inventory.Item.Cpu": null,
               "com.ibm.ipzvpd.Location" : {
@@ -431,18 +418,6 @@
           "powerOffOnly" : true,
           "offset": 196608,
           "size": 65504,
-          "type": "fruAndModule",
-          "extraInterfaces": {
-              "xyz.openbmc_project.Inventory.Item.Cpu": null,
-              "com.ibm.ipzvpd.Location" : {
-                  "LocationCode" : "Ufcs-P0-C24"
-              }
-          }
-      },
-      {
-          "inventoryPath": "/system/chassis/motherboard/cpu3",
-          "inheritEI": false,
-          "type": "moduleOnly",
           "extraInterfaces": {
               "xyz.openbmc_project.Inventory.Item.Cpu": null,
               "com.ibm.ipzvpd.Location" : {
@@ -458,7 +433,6 @@
           "offset": 196608,
           "size": 65504,
           "inherit": false,
-          "type": "moduleOnly",
           "extraInterfaces": {
               "xyz.openbmc_project.Inventory.Item.Cpu": null,
               "com.ibm.ipzvpd.Location" : {
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index fce6bf8..7cc0194 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -1190,16 +1190,13 @@
                 }
             }
         }
-        if (item.value("inheritEI", true))
+        // Populate interfaces and properties that are common to every FRU
+        // and additional interface that might be defined on a per-FRU
+        // basis.
+        if (item.find("extraInterfaces") != item.end())
         {
-            // Populate interfaces and properties that are common to every FRU
-            // and additional interface that might be defined on a per-FRU
-            // basis.
-            if (item.find("extraInterfaces") != item.end())
-            {
-                populateInterfaces(item["extraInterfaces"], interfaces, vpdMap,
-                                   isSystemVpd);
-            }
+            populateInterfaces(item["extraInterfaces"], interfaces, vpdMap,
+                               isSystemVpd);
         }
         objects.emplace(move(object), move(interfaces));
     }
diff --git a/vpd-manager/editor_impl.cpp b/vpd-manager/editor_impl.cpp
index 57fed60..8ae4558 100644
--- a/vpd-manager/editor_impl.cpp
+++ b/vpd-manager/editor_impl.cpp
@@ -373,66 +373,31 @@
         inventory::InterfaceMap interfaces;
         // by default inherit property is true
         bool isInherit = true;
-        bool isInheritEI = true;
-        bool isCpuModuleOnly = false;
 
         if (singleInventory.find("inherit") != singleInventory.end())
         {
             isInherit = singleInventory["inherit"].get<bool>();
         }
 
-        if (singleInventory.find("inheritEI") != singleInventory.end())
-        {
-            isInheritEI = singleInventory["inheritEI"].get<bool>();
-        }
-
-        // "type" exists only in CPU module and FRU
-        if (singleInventory.find("type") != singleInventory.end())
-        {
-            if (singleInventory["type"] == "moduleOnly")
-            {
-                isCpuModuleOnly = true;
-            }
-        }
-
         if (isInherit)
         {
-            // update com interface
-            // For CPU- update  com interface only when isCI true
-            if ((!isCpuModuleOnly) || (isCpuModuleOnly && isCI))
-            {
-                prop.emplace(thisRecord.recKWd, thisRecord.kwdUpdatedData);
-                interfaces.emplace(
-                    (IPZ_INTERFACE + (std::string) "." + thisRecord.recName),
-                    move(prop));
-                objects.emplace(
-                    (singleInventory["inventoryPath"].get<std::string>()),
-                    move(interfaces));
-            }
+            prop.emplace(thisRecord.recKWd, thisRecord.kwdUpdatedData);
+            interfaces.emplace(
+                (IPZ_INTERFACE + (std::string) "." + thisRecord.recName),
+                move(prop));
+            objects.emplace(
+                (singleInventory["inventoryPath"].get<std::string>()),
+                move(interfaces));
 
             // process Common interface
             processAndUpdateCI(singleInventory["inventoryPath"]
                                    .get_ref<const nlohmann::json::string_t&>());
         }
 
-        if (isInheritEI)
-        {
-            if (isCpuModuleOnly)
-            {
-                prop.emplace(thisRecord.recKWd, thisRecord.kwdUpdatedData);
-                interfaces.emplace(
-                    (IPZ_INTERFACE + (std::string) "." + thisRecord.recName),
-                    move(prop));
-                objects.emplace(
-                    (singleInventory["inventoryPath"].get<std::string>()),
-                    move(interfaces));
-            }
-
-            // process extra interfaces
-            processAndUpdateEI(singleInventory,
-                               singleInventory["inventoryPath"]
-                                   .get_ref<const nlohmann::json::string_t&>());
-        }
+        // process extra interfaces
+        processAndUpdateEI(singleInventory,
+                           singleInventory["inventoryPath"]
+                               .get_ref<const nlohmann::json::string_t&>());
 
         // check if we need to copy some specific records in this case.
         if (singleInventory.find("copyRecords") != singleInventory.end())
@@ -532,107 +497,11 @@
     common::utility::callPIM(move(objects));
 }
 
-string EditorImpl::getSysPathForThisFruType(const string& moduleObjPath,
-                                            const string& fruType)
-{
-    string fruVpdPath;
-
-    // get all FRUs list
-    for (const auto& eachFru : jsonFile["frus"].items())
-    {
-        bool moduleObjPathMatched = false;
-        bool expectedFruFound = false;
-
-        for (const auto& eachInventory : eachFru.value())
-        {
-            const auto& thisObjectPath = eachInventory["inventoryPath"];
-
-            // "type" exists only in CPU module and FRU
-            if (eachInventory.find("type") != eachInventory.end())
-            {
-                // If inventory type is fruAndModule then set flag
-                if (eachInventory["type"] == fruType)
-                {
-                    expectedFruFound = true;
-                }
-            }
-
-            if (thisObjectPath == moduleObjPath)
-            {
-                moduleObjPathMatched = true;
-            }
-        }
-
-        // If condition satisfies then collect this sys path and exit
-        if (expectedFruFound && moduleObjPathMatched)
-        {
-            fruVpdPath = eachFru.key();
-            break;
-        }
-    }
-
-    return fruVpdPath;
-}
-
-void EditorImpl::getVpdPathForCpu()
-{
-    isCI = false;
-    // keep a backup In case we need it later
-    inventory::Path vpdFilePathBackup = vpdFilePath;
-
-    // TODO 1:Temp hardcoded list. create it dynamically.
-    std::vector<std::string> commonIntVINIKwds = {"PN", "SN", "DR"};
-    std::vector<std::string> commonIntVR10Kwds = {"DC"};
-    std::unordered_map<std::string, std::vector<std::string>>
-        commonIntRecordsList = {{"VINI", commonIntVINIKwds},
-                                {"VR10", commonIntVR10Kwds}};
-
-    // If requested Record&Kw is one among CI, then update 'FRU' type sys
-    // path, SPI2
-    unordered_map<std::string, vector<string>>::const_iterator isCommonInt =
-        commonIntRecordsList.find(thisRecord.recName);
-
-    if ((isCommonInt != commonIntRecordsList.end()) &&
-        (find(isCommonInt->second.begin(), isCommonInt->second.end(),
-              thisRecord.recKWd) != isCommonInt->second.end()))
-    {
-        isCI = true;
-        vpdFilePath = getSysPathForThisFruType(objPath, "fruAndModule");
-    }
-    else
-    {
-        for (const auto& eachFru : jsonFile["frus"].items())
-        {
-            for (const auto& eachInventory : eachFru.value())
-            {
-                if (eachInventory.find("type") != eachInventory.end())
-                {
-                    const auto& thisObjectPath = eachInventory["inventoryPath"];
-                    if ((eachInventory["type"] == "moduleOnly") &&
-                        (eachInventory.value("inheritEI", true)) &&
-                        (thisObjectPath == static_cast<string>(objPath)))
-                    {
-                        vpdFilePath = eachFru.key();
-                    }
-                }
-            }
-        }
-    }
-    // If it is not a CPU fru then go ahead with default vpdFilePath from
-    // fruMap
-    if (vpdFilePath.empty())
-    {
-        vpdFilePath = vpdFilePathBackup;
-    }
-}
-
 void EditorImpl::updateKeyword(const Binary& kwdData, const bool& updCache)
 {
     startOffset = 0;
 #ifndef ManagerTest
 
-    getVpdPathForCpu();
-
     // check if offset present?
     for (const auto& item : jsonFile["frus"][vpdFilePath])
     {
@@ -719,4 +588,4 @@
 } // namespace editor
 } // namespace manager
 } // namespace vpd
-} // namespace openpower
+} // namespace openpower
\ No newline at end of file
diff --git a/vpd-manager/editor_impl.hpp b/vpd-manager/editor_impl.hpp
index d9b0ff1..c03354a 100644
--- a/vpd-manager/editor_impl.hpp
+++ b/vpd-manager/editor_impl.hpp
@@ -208,26 +208,9 @@
 
     // If requested Interface is common Interface
     bool isCI;
-
-    /** @brief This API will be used to find out Parent FRU of Module/CPU
-     *
-     * @param[in] - moduleObjPath, object path of that FRU
-     * @param[in] - fruType, Type of Parent FRU
-     *              for Module/CPU Parent Type- FruAndModule
-     *
-     * @return returns vpd file path of Parent Fru of that Module
-     */
-    std::string getSysPathForThisFruType(const std::string& moduleObjPath,
-                                         const std::string& fruType);
-
-    /** @brief This API will search for correct EEPROM path for asked CPU
-     *         and will init vpdFilePath
-     */
-    void getVpdPathForCpu();
-
 }; // class EditorImpl
 
 } // namespace editor
 } // namespace manager
 } // namespace vpd
-} // namespace openpower
+} // namespace openpower
\ No newline at end of file