summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarri Devender Rao <devenrao@in.ibm.com>2017-07-26 00:33:26 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-09-08 19:43:28 +0000
commit18aae1f78ab1ee6783bf7f91a6b67b47e7845ac1 (patch)
tree9dbcbab83c2a10cc04328cf8494235e18ebd77a9
parent13791bd5519d2fe63a4b71f48db32e03c159369a (diff)
downloadphosphor-host-ipmid-18aae1f78ab1ee6783bf7f91a6b67b47e7845ac1.tar.gz
phosphor-host-ipmid-18aae1f78ab1ee6783bf7f91a6b67b47e7845ac1.zip
Refactor reading and parsing of inventory data
Refactored to use 'GetAll' dbus method call over multiple 'Get' dbus method calls to read the properties of a inventory object. Change-Id: I0ddc2150830961666fafa661cf29042f66137977 Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
-rw-r--r--read_fru_data.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/read_fru_data.cpp b/read_fru_data.cpp
index b23498e..a7a3256 100644
--- a/read_fru_data.cpp
+++ b/read_fru_data.cpp
@@ -5,6 +5,7 @@
#include "fruread.hpp"
#include "host-ipmid/ipmid-api.h"
#include "utils.hpp"
+#include "types.hpp"
extern const FruMap frus;
namespace ipmi
@@ -30,40 +31,36 @@ namespace cache
FRUAreaMap fruMap;
}
/**
- * @brief Read the property value from Inventory
+ * @brief Read all the property value's for the specified interface
+ * from Inventory.
*
- * @param[in] bus dbus
* @param[in] intf Interface
- * @param[in] propertyName Name of the property
* @param[in] path Object path
- * @return property value
+ * @return map of properties
*/
-std::string readProperty(const std::string& intf,
- const std::string& propertyName,
- const std::string& path)
+ipmi::PropertyMap readAllProperties(const std::string& intf,
+ const std::string& path)
{
+ ipmi::PropertyMap properties;
sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
auto service = ipmi::getService(bus, INV_INTF, OBJ_PATH);
std::string objPath = OBJ_PATH + path;
auto method = bus.new_method_call(service.c_str(),
objPath.c_str(),
PROP_INTF,
- "Get");
- method.append(intf, propertyName);
+ "GetAll");
+ method.append(intf);
auto reply = bus.call(method);
if (reply.is_method_error())
{
//If property is not found simply return empty value
- log<level::INFO>("Property value not set",
- entry("Property=%s", propertyName),
+ log<level::ERR>("Error in reading property values from inventory",
+ entry("Interface=%s", intf),
entry("Path=%s", objPath));
- return {};
+ return properties;
}
- sdbusplus::message::variant<std::string> property;
- reply.read(property);
- std::string value =
- sdbusplus::message::variant_ns::get<std::string>(property);
- return value;
+ reply.read(properties);
+ return properties;
}
void processFruPropChange(sdbusplus::message::message& msg)
@@ -136,15 +133,18 @@ FruInventoryData readDataFromInventory(const FRUId& fruNum)
auto& instanceList = iter->second;
for (auto& instance : instanceList)
{
- for (auto& interfaceList : instance.second)
+ for (auto& intf : instance.second)
{
- for (auto& properties : interfaceList.second)
+ ipmi::PropertyMap allProp = readAllProperties(
+ intf.first, instance.first);
+ for (auto& properties : intf.second)
{
- decltype(auto) pdata = properties.second;
- auto value = readProperty(
- interfaceList.first, properties.first,
- instance.first);
- data[pdata.section].emplace(properties.first, value);
+ auto iter = allProp.find(properties.first);
+ if (iter != allProp.end())
+ {
+ data[properties.second.section].emplace(properties.first,
+ std::move(allProp[properties.first].get<std::string>()));
+ }
}
}
}
OpenPOWER on IntegriCloud