monitor: Re-log fan error on a power off
In the case where a power off rule runs to completion and powers off the
system due to either missing or faulted fans, at the point of power off
re-post the event log for the previous fan error.
This way, there can be an error associated with the power off, because
depending on the power off rule delays the original error could have
happened several minutes or more in the past.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I1a38062cf75ffd4a11baa417ef3983b6c1a47ada
diff --git a/monitor/json_parser.cpp b/monitor/json_parser.cpp
index 1bb018d..b2b0c06 100644
--- a/monitor/json_parser.cpp
+++ b/monitor/json_parser.cpp
@@ -336,7 +336,8 @@
std::unique_ptr<PowerOffAction>
getPowerOffAction(const json& powerOffConfig,
- std::shared_ptr<PowerInterfaceBase>& powerInterface)
+ std::shared_ptr<PowerInterfaceBase>& powerInterface,
+ PowerOffAction::PrePowerOffFunc& func)
{
std::unique_ptr<PowerOffAction> action;
if (!powerOffConfig.contains("type"))
@@ -368,19 +369,19 @@
if (type == "hard")
{
action = std::make_unique<HardPowerOff>(
- powerOffConfig.at("delay").get<uint32_t>(), powerInterface);
+ powerOffConfig.at("delay").get<uint32_t>(), powerInterface, func);
}
else if (type == "soft")
{
action = std::make_unique<SoftPowerOff>(
- powerOffConfig.at("delay").get<uint32_t>(), powerInterface);
+ powerOffConfig.at("delay").get<uint32_t>(), powerInterface, func);
}
else if (type == "epow")
{
action = std::make_unique<EpowPowerOff>(
powerOffConfig.at("service_mode_delay").get<uint32_t>(),
- powerOffConfig.at("meltdown_delay").get<uint32_t>(),
- powerInterface);
+ powerOffConfig.at("meltdown_delay").get<uint32_t>(), powerInterface,
+ func);
}
else
{
@@ -395,7 +396,8 @@
std::vector<std::unique_ptr<PowerOffRule>>
getPowerOffRules(const json& obj,
- std::shared_ptr<PowerInterfaceBase>& powerInterface)
+ std::shared_ptr<PowerInterfaceBase>& powerInterface,
+ PowerOffAction::PrePowerOffFunc& func)
{
std::vector<std::unique_ptr<PowerOffRule>> rules;
@@ -409,7 +411,7 @@
{
auto state = getPowerOffPowerRuleState(config);
auto cause = getPowerOffCause(config);
- auto action = getPowerOffAction(config, powerInterface);
+ auto action = getPowerOffAction(config, powerInterface, func);
auto rule = std::make_unique<PowerOffRule>(
std::move(state), std::move(cause), std::move(action));