regulators: Implements support for compare_presence action
Enhance the configuration file parser to support the
compare_presence action element.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I9bfa3d260e0a6f7d8f41bed473b436148141ea50
diff --git a/phosphor-regulators/src/config_file_parser.cpp b/phosphor-regulators/src/config_file_parser.cpp
index b94e308..7a3d497 100644
--- a/phosphor-regulators/src/config_file_parser.cpp
+++ b/phosphor-regulators/src/config_file_parser.cpp
@@ -72,9 +72,8 @@
}
else if (element.contains("compare_presence"))
{
- // TODO: Not implemented yet
- // action = parseComparePresence(element["compare_presence"]);
- // ++propertyCount;
+ action = parseComparePresence(element["compare_presence"]);
+ ++propertyCount;
}
else if (element.contains("compare_vpd"))
{
@@ -232,6 +231,27 @@
return chassis;
}
+std::unique_ptr<ComparePresenceAction> parseComparePresence(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 value property
+ const json& valueElement = getRequiredProperty(element, "value");
+ bool value = parseBoolean(valueElement);
+ ++propertyCount;
+
+ // Verify no invalid properties exist
+ verifyPropertyCount(element, propertyCount);
+
+ return std::make_unique<ComparePresenceAction>(fru, value);
+}
+
std::unique_ptr<Configuration> parseConfiguration(const json& element)
{
verifyIsObject(element);