pseq: Parsing support for chassis_template array
Add JSON parsing support for an array of chassis_template elements in
the phosphor-power-sequencer configuration file.
Tested:
* Ran automated tests.
Change-Id: Id9277c1eb938fd8c08c292fbe6c898507d2faced
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/phosphor-power-sequencer/src/config_file_parser.cpp b/phosphor-power-sequencer/src/config_file_parser.cpp
index 18fe32e..9e4a18d 100644
--- a/phosphor-power-sequencer/src/config_file_parser.cpp
+++ b/phosphor-power-sequencer/src/config_file_parser.cpp
@@ -95,7 +95,8 @@
{
std::unique_ptr<Chassis> parseChassis(
- const json& element, std::map<std::string, JSONRefWrapper> chassisTemplates,
+ const json& element,
+ const std::map<std::string, JSONRefWrapper>& chassisTemplates,
Services& services)
{
verifyIsObject(element);
@@ -148,7 +149,8 @@
}
std::vector<std::unique_ptr<Chassis>> parseChassisArray(
- const json& element, std::map<std::string, JSONRefWrapper> chassisTemplates,
+ const json& element,
+ const std::map<std::string, JSONRefWrapper>& chassisTemplates,
Services& services)
{
verifyIsArray(element);
@@ -251,6 +253,18 @@
return {id, JSONRefWrapper{element}};
}
+std::map<std::string, JSONRefWrapper> parseChassisTemplateArray(
+ const json& element)
+{
+ verifyIsArray(element);
+ std::map<std::string, JSONRefWrapper> chassisTemplates;
+ for (auto& chassisTemplateElement : element)
+ {
+ chassisTemplates.emplace(parseChassisTemplate(chassisTemplateElement));
+ }
+ return chassisTemplates;
+}
+
GPIO parseGPIO(const json& element,
const std::map<std::string, std::string>& variables)
{