pseq: Parsing support for power_sequencer element
Add JSON parsing support for the new power_sequencer element in the
phosphor-power-sequencer configuration file.
Tested:
* Ran automated tests.
Change-Id: I4c9f27af06c9c349ecc4f60ba753f1a6e636f786
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/phosphor-power-sequencer/src/config_file_parser.hpp b/phosphor-power-sequencer/src/config_file_parser.hpp
index 0f5fe3c..fcae99a 100644
--- a/phosphor-power-sequencer/src/config_file_parser.hpp
+++ b/phosphor-power-sequencer/src/config_file_parser.hpp
@@ -15,7 +15,9 @@
*/
#pragma once
+#include "power_sequencer_device.hpp"
#include "rail.hpp"
+#include "services.hpp"
#include <nlohmann/json.hpp>
@@ -108,6 +110,38 @@
const std::map<std::string, std::string>& variables);
/**
+ * Parses a JSON element containing a power_sequencer object.
+ *
+ * Returns the corresponding C++ PowerSequencerDevice object.
+ *
+ * Throws an exception if parsing fails.
+ *
+ * @param element JSON element
+ * @param variables variables map used to expand variables in element value
+ * @param services System services like hardware presence and the journal
+ * @return PowerSequencerDevice object
+ */
+std::unique_ptr<PowerSequencerDevice> parsePowerSequencer(
+ const nlohmann::json& element,
+ const std::map<std::string, std::string>& variables, Services& services);
+
+/**
+ * Parses a JSON element containing an array of power_sequencer objects.
+ *
+ * Returns the corresponding C++ PowerSequencerDevice objects.
+ *
+ * Throws an exception if parsing fails.
+ *
+ * @param element JSON element
+ * @param variables variables map used to expand variables in element value
+ * @param services System services like hardware presence and the journal
+ * @return vector of PowerSequencerDevice objects
+ */
+std::vector<std::unique_ptr<PowerSequencerDevice>> parsePowerSequencerArray(
+ const nlohmann::json& element,
+ const std::map<std::string, std::string>& variables, Services& services);
+
+/**
* Parses a JSON element containing a rail.
*
* Returns the corresponding C++ Rail object.