summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--writefrudata.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 635653f..b36de7e 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -367,6 +367,7 @@ int verify_fru_data(const uint8_t *data, const size_t len)
std::string getFRUValue(const std::string& section,
const std::string& key,
+ const std::string& delimiter,
IPMIFruInfo& fruData)
{
@@ -400,6 +401,22 @@ std::string getFRUValue(const std::string& section,
{
fruValue = itr->second;
}
+
+ //if the key is custom property then the value could be in two formats.
+ //1) custom field 2 = "value".
+ //2) custom field 2 = "key:value".
+ //if delimeter length = 0 i.e custom field 2 = "value"
+
+ constexpr auto customProp = "Custom Field";
+ if (key.find(customProp) != std::string::npos)
+ {
+ if (delimiter.length() > 0)
+ {
+ size_t delimiterpos = fruValue.find(delimiter);
+ if (delimiterpos != std::string::npos)
+ fruValue = fruValue.substr(delimiterpos + 1);
+ }
+ }
return fruValue;
}
@@ -507,7 +524,7 @@ int ipmi_update_inventory(fru_area_vec_t& area_vec)
PropertyMap props;//store all the properties
for (auto& properties : interfaceList.second)
{
- std::string section, property, value;
+ std::string section, property, delimiter, value;
for (auto& info : properties.second)
{
if (info.first == "IPMIFruSection")
@@ -518,11 +535,26 @@ int ipmi_update_inventory(fru_area_vec_t& area_vec)
{
property = std::move(info.second);
}
+ if (info.first == "IPMIFruValueDelimiter")
+ {
+ //Read the delimeter as ascii value
+ //convert it into char
+ if( info.second.length() > 0 )
+ {
+ char dlm = ' ';
+ rc = sscanf(info.second.c_str(),"%hhd",&dlm);
+ if (rc > 0)
+ {
+ delimiter = std::string(1,dlm);
+ }
+ }
+ }
+
}
if (!section.empty() && !property.empty())
{
- value = getFRUValue(section, property, fruData);
+ value = getFRUValue(section, property, delimiter, fruData);
}
props.emplace(std::move(properties.first), std::move(value));
}
OpenPOWER on IntegriCloud