pseq: Add generic failure handling to base class
Use the power sequencer base class to handle failure cases where the
device is not found or a device specific failure can not determined. Add
a error logging convience method. Move the D-Bus object to the base
class.
Signed-off-by: Jim Wright <jlwright@us.ibm.com>
Change-Id: I6f7c2951e83cb892ec0c63018d65d5e241ebe6f0
diff --git a/phosphor-power-sequencer/src/power_sequencer_monitor.hpp b/phosphor-power-sequencer/src/power_sequencer_monitor.hpp
index e714d08..944e7ae 100644
--- a/phosphor-power-sequencer/src/power_sequencer_monitor.hpp
+++ b/phosphor-power-sequencer/src/power_sequencer_monitor.hpp
@@ -1,5 +1,10 @@
#pragma once
+#include <sdbusplus/bus.hpp>
+
+#include <map>
+#include <string>
+
namespace phosphor::power::sequencer
{
@@ -10,12 +15,42 @@
class PowerSequencerMonitor
{
public:
- PowerSequencerMonitor() = default;
+ PowerSequencerMonitor() = delete;
PowerSequencerMonitor(const PowerSequencerMonitor&) = delete;
PowerSequencerMonitor& operator=(const PowerSequencerMonitor&) = delete;
PowerSequencerMonitor(PowerSequencerMonitor&&) = delete;
PowerSequencerMonitor& operator=(PowerSequencerMonitor&&) = delete;
virtual ~PowerSequencerMonitor() = default;
+
+ /**
+ * Create a base device object for power sequence monitoring.
+ * @param[in] bus D-Bus bus object
+ */
+ explicit PowerSequencerMonitor(sdbusplus::bus::bus& bus);
+
+ /**
+ * Logs an error using the D-Bus Create method.
+ * @param[in] message Message property of the error log entry
+ * @param[in] additionalData AdditionalData property of the error log entry
+ */
+ void logError(const std::string& message,
+ std::map<std::string, std::string>& additionalData);
+
+ /**
+ * Analyzes the device for errors when the device is
+ * known to be in an error state. A log will be created.
+ * @param[in] timeout if the failure state was determined by timing out
+ * @param[in] powerSupplyError The power supply error to log. A default
+ * std:string, i.e. empty string ("") is passed when there is no power
+ * supply error to log.
+ */
+ virtual void onFailure(bool timeout, const std::string& powerSupplyError);
+
+ protected:
+ /**
+ * The D-Bus bus object
+ */
+ sdbusplus::bus::bus& bus;
};
} // namespace phosphor::power::sequencer