Log the Host DC On/Off redfish messages when the host state is changed
In order to skip the redfish DC On/Off messages during the
initialization process, move the log action from sel-logger.
Tested:
Reboot BMC, and check the redfish log, there is no DCPowerOn/Off log;
Chassis power on/off, the DCPowerOn/Off log is correct
Change-Id: I2af37940540d768f0882bf038bb0908ebb6352c4
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
diff --git a/power-control-x86/src/power_control.cpp b/power-control-x86/src/power_control.cpp
index 4126a75..1d0950a 100644
--- a/power-control-x86/src/power_control.cpp
+++ b/power-control-x86/src/power_control.cpp
@@ -1253,6 +1253,20 @@
static void currentHostStateMonitor()
{
+ if (getHostState(powerState) ==
+ "xyz.openbmc_project.State.Host.HostState.Running")
+ {
+ pohCounterTimerStart();
+ // Clear the restart cause set for the next restart
+ clearRestartCause();
+ }
+ else
+ {
+ pohCounterTimer.cancel();
+ // Set the restart cause set for this restart
+ setRestartCause();
+ }
+
static auto match = sdbusplus::bus::match::match(
*conn,
"type='signal',member='PropertiesChanged', "
@@ -1283,12 +1297,20 @@
pohCounterTimerStart();
// Clear the restart cause set for the next restart
clearRestartCause();
+ sd_journal_send("MESSAGE=Host system DC power is on",
+ "PRIORITY=%i", LOG_INFO,
+ "REDFISH_MESSAGE_ID=%s",
+ "OpenBMC.0.1.DCPowerOn", NULL);
}
else
{
pohCounterTimer.cancel();
// Set the restart cause set for this restart
setRestartCause();
+ sd_journal_send("MESSAGE=Host system DC power is off",
+ "PRIORITY=%i", LOG_INFO,
+ "REDFISH_MESSAGE_ID=%s",
+ "OpenBMC.0.1.DCPowerOff", NULL);
}
});
}
@@ -2098,8 +2120,6 @@
"CurrentHostState",
std::string(power_control::getHostState(power_control::powerState)));
- power_control::currentHostStateMonitor();
-
power_control::hostIface->initialize();
// Chassis Control Service
@@ -2385,6 +2405,8 @@
power_control::restartCauseIface->initialize();
+ power_control::currentHostStateMonitor();
+
power_control::io.run();
return 0;