From 788bd1f58886dd68141dff659161da5804c05063 Mon Sep 17 00:00:00 2001 From: Deepak Kodihalli Date: Mon, 20 Feb 2017 01:21:59 -0600 Subject: inventory: update extra properties Change-Id: I8b403f07855cccb001eb63d6c5f11c5e1f58c874 Signed-off-by: Deepak Kodihalli --- writefrudata.cpp | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/writefrudata.cpp b/writefrudata.cpp index b36de7e..e090903 100644 --- a/writefrudata.cpp +++ b/writefrudata.cpp @@ -13,6 +13,7 @@ #include #include #include +#include "types.hpp" #include "frup.hpp" #include "fru-area.hpp" #include @@ -21,21 +22,10 @@ const char *sys_object_name = "/org/openbmc/managers/System"; const char *sys_intf_name = "org.openbmc.managers.System"; -extern const FruMap frus; - -using Property = std::string; -using Value = sdbusplus::message::variant; -// Association between property and its value -using PropertyMap = std::map; - -using Interface = std::string; -// Association between interface and the dbus property -using InterfaceMap = std::map; +using namespace ipmi::vpd; -using Object = sdbusplus::message::object_path; - -// Association between object and the interfaces. -using ObjectMap = std::map; +extern const FruMap frus; +extern const std::map extras; //---------------------------------------------------------------- // Constructor @@ -518,6 +508,7 @@ int ipmi_update_inventory(fru_area_vec_t& area_vec) for (auto& instance : instanceList) { InterfaceMap interfaces; + const auto& extrasIter = extras.find(instance.first); for (auto& interfaceList : instance.second) { @@ -558,11 +549,36 @@ int ipmi_update_inventory(fru_area_vec_t& area_vec) } 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); } -- cgit v1.2.1