summaryrefslogtreecommitdiffstats
path: root/writefrudata.cpp
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-02-15 09:29:54 +0530
committerRatan Gupta <ratagupt@in.ibm.com>2017-02-20 20:59:37 +0530
commitcdde23db0122547acde8379184250b3639604635 (patch)
treef4a9a291c6908fdd02da59a13447e1499d179433 /writefrudata.cpp
parentd51dd1c79e58ef9c27603d3d0f9108084852afe3 (diff)
downloadipmi-fru-parser-cdde23db0122547acde8379184250b3639604635.tar.gz
ipmi-fru-parser-cdde23db0122547acde8379184250b3639604635.zip
Inventory: Implement writing custom IPMI FRU property
Change-Id: I9286045c3c10cd8bed840f03cfcc92a5b236d9ca Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'writefrudata.cpp')
-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