inventory: update extra properties

Change-Id: I8b403f07855cccb001eb63d6c5f11c5e1f58c874
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/writefrudata.cpp b/writefrudata.cpp
index b36de7e..e090903 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -13,6 +13,7 @@
 #include <fstream>
 #include <sstream>
 #include <mapper.h>
+#include "types.hpp"
 #include "frup.hpp"
 #include "fru-area.hpp"
 #include <sdbusplus/server.hpp>
@@ -21,21 +22,10 @@
 const char  *sys_object_name   =  "/org/openbmc/managers/System";
 const char  *sys_intf_name     =  "org.openbmc.managers.System";
 
+using namespace ipmi::vpd;
+
 extern const FruMap frus;
-
-using Property = std::string;
-using Value = sdbusplus::message::variant<bool, int64_t, std::string>;
-// Association between property and its value
-using PropertyMap = std::map<Property, Value>;
-
-using Interface = std::string;
-// Association between interface and the dbus property
-using InterfaceMap = std::map<Interface, PropertyMap>;
-
-using Object = sdbusplus::message::object_path;
-
-// Association between object and the  interfaces.
-using ObjectMap = std::map<Object, InterfaceMap>;
+extern const std::map<Path, InterfaceMap> extras;
 
 //----------------------------------------------------------------
 // Constructor
@@ -518,6 +508,7 @@
     for (auto& instance : instanceList)
     {
         InterfaceMap interfaces;
+        const auto& extrasIter = extras.find(instance.first);
 
         for (auto& interfaceList : instance.second)
         {
@@ -558,11 +549,36 @@
                 }
                 props.emplace(std::move(properties.first), std::move(value));
             }
-            interfaces.emplace(std::move(interfaceList.first), std::move(props));
+            // Check and update extra properties
+            if(extras.end() != extrasIter)
+            {
+                const auto& propsIter =
+                    (extrasIter->second).find(interfaceList.first);
+                if((extrasIter->second).end() != propsIter)
+                {
+                    for(const auto& map : propsIter->second)
+                    {
+                        props.emplace(map.first, map.second);
+                    }
+                }
+            }
+            interfaces.emplace(std::move(interfaceList.first),
+                               std::move(props));
         }
 
-        //Call the inventory manager
+        // Call the inventory manager
         sdbusplus::message::object_path path = instance.first;
+        // Check and update extra properties
+        if(extras.end() != extrasIter)
+        {
+            for(const auto& entry : extrasIter->second)
+            {
+                if(interfaces.end() == interfaces.find(entry.first))
+                {
+                    interfaces.emplace(entry.first, entry.second);
+                }
+            }
+        }
         objects.emplace(path,interfaces);
     }