Inventory:- making changes in the mako and the C++ structure

As fru yaml would be having extra properties like
entityID,entityInstance so changes were needed to make the
change in the corresponding c++ structure.

Change-Id: I314d1556cf07a3e212996615c1cd2f28fb6d9bba
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/fruread.hpp b/fruread.hpp
index 203dfa0..e035a74 100644
--- a/fruread.hpp
+++ b/fruread.hpp
@@ -21,7 +21,16 @@
 using DbusInterfaceVec = std::vector<std::pair<DbusInterface, DbusPropertyVec>>;
 
 using FruInstancePath = std::string;
-using FruInstanceVec = std::vector<std::pair<FruInstancePath, DbusInterfaceVec>>;
+
+struct FruInstance
+{
+    uint8_t entityID;
+    uint8_t entityInstance;
+    FruInstancePath path;
+    DbusInterfaceVec interfaces;
+};
+
+using FruInstanceVec = std::vector<FruInstance>;
 
 using FruId = uint32_t;
 using FruMap = std::map<FruId, FruInstanceVec>;
diff --git a/read_fru_data.cpp b/read_fru_data.cpp
index 510f0af..a1bced9 100644
--- a/read_fru_data.cpp
+++ b/read_fru_data.cpp
@@ -82,7 +82,7 @@
         auto& instanceList = fru.second;
         for (auto& instance : instanceList)
         {
-            if(instance.first == path)
+            if(instance.path == path)
             {
                 found = true;
                 break;
@@ -133,10 +133,10 @@
     auto& instanceList = iter->second;
     for (auto& instance : instanceList)
     {
-        for (auto& intf : instance.second)
+        for (auto& intf : instance.interfaces)
         {
             ipmi::PropertyMap allProp = readAllProperties(
-                    intf.first, instance.first);
+                    intf.first, instance.path);
             for (auto& properties : intf.second)
             {
                 auto iter = allProp.find(properties.first);
diff --git a/scripts/fru-read-example.yaml b/scripts/fru-read-example.yaml
index 86151af..41e1598 100644
--- a/scripts/fru-read-example.yaml
+++ b/scripts/fru-read-example.yaml
@@ -12,113 +12,128 @@
 #         IPMI Fru mapping
 0:
   /system:
-    xyz.openbmc_project.Inventory.Item:
-      PrettyName:
-        IPMIFruProperty: Product Name
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Decorator.Asset:
-      Manufacturer:
-        IPMIFruProperty: Manufacturer
-        IPMIFruSection: Product
-      PartNumber:
-        IPMIFruProperty: Part Number
-        IPMIFruSection: Product
-      SerialNumber:
-        IPMIFruProperty: Serial Number
-        IPMIFruSection: Product
-      BuildDate:
-        IPMIFruProperty: Mfg Date
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Decorator.Revision:
-      Version:
-        IPMIFruProperty: Version
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Item.System:
+    entityID: 23
+    entityInstance: 1
+    interfaces:
+      xyz.openbmc_project.Inventory.Item:
+        PrettyName:
+          IPMIFruProperty: Product Name
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Decorator.Asset:
+        Manufacturer:
+          IPMIFruProperty: Manufacturer
+          IPMIFruSection: Product
+        PartNumber:
+          IPMIFruProperty: Part Number
+          IPMIFruSection: Product
+        SerialNumber:
+          IPMIFruProperty: Serial Number
+          IPMIFruSection: Product
+        BuildDate:
+          IPMIFruProperty: Mfg Date
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Decorator.Revision:
+        Version:
+          IPMIFruProperty: Version
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Item.System:
 1:
   /system/chassis/motherboard/dimm0:
-    xyz.openbmc_project.Inventory.Item:
-      PrettyName:
-        IPMIFruProperty: Product Name
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Decorator.Asset:
-      Manufacturer:
-        IPMIFruProperty: Manufacturer
-        IPMIFruSection: Product
-      BuildDate:
-        IPMIFruProperty: Mfg Date
-        IPMIFruSection: Product
-      SerialNumber:
-        IPMIFruProperty: Serial Number
-        IPMIFruSection: Product
-      PartNumber:
-        IPMIFruProperty: Part Number
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Decorator.Revision:
-      Version:
-        IPMIFruProperty: Version
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Item.Dimm:
+    entityID: 32
+    entityInstance: 1
+    interfaces:
+      xyz.openbmc_project.Inventory.Item:
+        PrettyName:
+          IPMIFruProperty: Product Name
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Decorator.Asset:
+        Manufacturer:
+          IPMIFruProperty: Manufacturer
+          IPMIFruSection: Product
+        BuildDate:
+          IPMIFruProperty: Mfg Date
+          IPMIFruSection: Product
+        SerialNumber:
+          IPMIFruProperty: Serial Number
+          IPMIFruSection: Product
+        PartNumber:
+          IPMIFruProperty: Part Number
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Decorator.Revision:
+        Version:
+          IPMIFruProperty: Version
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Item.Dimm:
 2:
   /system/chassis/motherboard/dimm1:
-    xyz.openbmc_project.Inventory.Item:
-      PrettyName:
-        IPMIFruProperty: Product Name
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Decorator.Asset:
-      Manufacturer:
-        IPMIFruProperty: Manufacturer
-        IPMIFruSection: Product
-      BuildDate:
-        IPMIFruProperty: Mfg Date
-        IPMIFruSection: Product
-      SerialNumber:
-        IPMIFruProperty: Serial Number
-        IPMIFruSection: Product
-      PartNumber:
-        IPMIFruProperty: Part Number
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Decorator.Revision:
-      Version:
-        IPMIFruProperty: Version
-        IPMIFruSection: Product
-    xyz.openbmc_project.Inventory.Item.Dimm:
+    entityID: 32
+    entityInstance: 2
+    interfaces:
+      xyz.openbmc_project.Inventory.Item:
+        PrettyName:
+          IPMIFruProperty: Product Name
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Decorator.Asset:
+        Manufacturer:
+          IPMIFruProperty: Manufacturer
+          IPMIFruSection: Product
+        BuildDate:
+          IPMIFruProperty: Mfg Date
+          IPMIFruSection: Product
+        SerialNumber:
+          IPMIFruProperty: Serial Number
+          IPMIFruSection: Product
+        PartNumber:
+          IPMIFruProperty: Part Number
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Decorator.Revision:
+        Version:
+          IPMIFruProperty: Version
+          IPMIFruSection: Product
+      xyz.openbmc_project.Inventory.Item.Dimm:
 3:
   /system/chassis/motherboard/cpu0:
-    xyz.openbmc_project.Inventory.Item:
-      PrettyName:
-        IPMIFruProperty: Product Name
-        IPMIFruSection: Board
-    xyz.openbmc_project.Inventory.Decorator.Asset:
-      BuildDate:
-        IPMIFruProperty: Mfg Date
-        IPMIFruSection: Board
-      SerialNumber:
-        IPMIFruProperty: Serial Number
-        IPMIFruSection: Board
-      PartNumber:
-        IPMIFruProperty: Part Number
-        IPMIFruSection: Board
-      Manufacturer:
-        IPMIFruProperty: Manufacturer
-        IPMIFruSection: Board
-    xyz.openbmc_project.Inventory.Item.Cpu:
+    entityID: 3
+    entityInstance: 1
+    interfaces:
+      xyz.openbmc_project.Inventory.Item:
+        PrettyName:
+          IPMIFruProperty: Product Name
+          IPMIFruSection: Board
+      xyz.openbmc_project.Inventory.Decorator.Asset:
+        BuildDate:
+          IPMIFruProperty: Mfg Date
+          IPMIFruSection: Board
+        SerialNumber:
+          IPMIFruProperty: Serial Number
+          IPMIFruSection: Board
+        PartNumber:
+          IPMIFruProperty: Part Number
+          IPMIFruSection: Board
+        Manufacturer:
+          IPMIFruProperty: Manufacturer
+          IPMIFruSection: Board
+      xyz.openbmc_project.Inventory.Item.Cpu:
 4:
   /system/chassis/motherboard/cpu1:
-    xyz.openbmc_project.Inventory.Item:
-      PrettyName:
-        IPMIFruProperty: Product Name
-        IPMIFruSection: Board
-    xyz.openbmc_project.Inventory.Decorator.Asset:
-      BuildDate:
-        IPMIFruProperty: Mfg Date
-        IPMIFruSection: Board
-      SerialNumber:
-        IPMIFruProperty: Serial Number
-        IPMIFruSection: Board
-      PartNumber:
-        IPMIFruProperty: Part Number
-        IPMIFruSection: Board
-      Manufacturer:
-        IPMIFruProperty: Manufacturer
-        IPMIFruSection: Board
-    xyz.openbmc_project.Inventory.Item.Cpu:
+    entityID: 3
+    entityInstance: 2
+    interfaces:
+      xyz.openbmc_project.Inventory.Item:
+        PrettyName:
+          IPMIFruProperty: Product Name
+          IPMIFruSection: Board
+      xyz.openbmc_project.Inventory.Decorator.Asset:
+        BuildDate:
+          IPMIFruProperty: Mfg Date
+          IPMIFruSection: Board
+        SerialNumber:
+          IPMIFruProperty: Serial Number
+          IPMIFruSection: Board
+        PartNumber:
+          IPMIFruProperty: Part Number
+          IPMIFruSection: Board
+        Manufacturer:
+          IPMIFruProperty: Manufacturer
+          IPMIFruSection: Board
+      xyz.openbmc_project.Inventory.Item.Cpu:
diff --git a/scripts/readfru.mako.cpp b/scripts/readfru.mako.cpp
index 061b4e0..57265be 100644
--- a/scripts/readfru.mako.cpp
+++ b/scripts/readfru.mako.cpp
@@ -6,17 +6,22 @@
 % for key in fruDict.keys():
    {${key},{
 <%
-    fru = fruDict[key]
+    instanceList = fruDict[key]
 %>
-    % for object,interfaces in fru.items():
-         {"${object}",{
+    % for instancePath,instanceInfo in instanceList.items():
+<%
+        entityID = instanceInfo["entityID"]
+        entityInstance = instanceInfo["entityInstance"]
+        interfaces = instanceInfo["interfaces"]
+%>
+         {${entityID}, ${entityInstance}, "${instancePath}",{
          % for interface,properties in interfaces.items():
              {"${interface}",{
             % if properties:
                 % for dbus_property,property_value in properties.items():
                     {"${dbus_property}",{
                         "${property_value.get("IPMIFruSection", "")}",
-                        "${property_value.get("IPMIFruProperty", "")}", \
+                        "${property_value.get("IPMIFruProperty", "")}",\
 <%
     delimiter = property_value.get("IPMIFruValueDelimiter")
     if not delimiter: