regulators: Implements support for compare_vpd action
Enhance the configuration file parser to support the compare_vpd
action element.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: Ia8766a0d2f893898c5ff2655a757d60f7cdcc7df
diff --git a/phosphor-regulators/src/config_file_parser.cpp b/phosphor-regulators/src/config_file_parser.cpp
index 7a3d497..11527b8 100644
--- a/phosphor-regulators/src/config_file_parser.cpp
+++ b/phosphor-regulators/src/config_file_parser.cpp
@@ -77,9 +77,8 @@
}
else if (element.contains("compare_vpd"))
{
- // TODO: Not implemented yet
- // action = parseCompareVPD(element["compare_vpd"]);
- // ++propertyCount;
+ action = parseCompareVPD(element["compare_vpd"]);
+ ++propertyCount;
}
else if (element.contains("i2c_compare_bit"))
{
@@ -252,6 +251,32 @@
return std::make_unique<ComparePresenceAction>(fru, value);
}
+std::unique_ptr<CompareVPDAction> parseCompareVPD(const json& element)
+{
+ verifyIsObject(element);
+ unsigned int propertyCount{0};
+
+ // Required fru property
+ const json& fruElement = getRequiredProperty(element, "fru");
+ std::string fru = parseString(fruElement);
+ ++propertyCount;
+
+ // Required keyword property
+ const json& keywordElement = getRequiredProperty(element, "keyword");
+ std::string keyword = parseString(keywordElement);
+ ++propertyCount;
+
+ // Required value property
+ const json& valueElement = getRequiredProperty(element, "value");
+ std::string value = parseString(valueElement);
+ ++propertyCount;
+
+ // Verify no invalid properties exist
+ verifyPropertyCount(element, propertyCount);
+
+ return std::make_unique<CompareVPDAction>(fru, keyword, value);
+}
+
std::unique_ptr<Configuration> parseConfiguration(const json& element)
{
verifyIsObject(element);