host-sensors: Reset when system off but last state was on
When power was on before a BMC reboot and system is now off, the host
sensors need to be reset to show the correct system state of `off` now.
This is done by starting the `phosphor-reset-sensor-states@0.service`
unit, which handles setting the appropriate dbus properties.
Tested:
Power on system and then remove/add AC
Check BootProgress, etc.. properties set by reset service
Change-Id: I4928a231495a1295425dc828606b40de03253bab
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index 38b7c94..128672f 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -37,6 +37,8 @@
constexpr auto CHASSIS_STATE_HARD_POWEROFF_TGT =
"obmc-chassis-hard-poweroff@0.target";
constexpr auto CHASSIS_STATE_POWERON_TGT = "obmc-chassis-poweron@0.target";
+constexpr auto RESET_HOST_SENSORS_SVC =
+ "phosphor-reset-sensor-states@0.service";
constexpr auto ACTIVE_STATE = "active";
constexpr auto ACTIVATING_STATE = "activating";
@@ -132,6 +134,10 @@
{
info(
"Chassis power was on before the BMC reboot and it is off now");
+
+ // Reset host sensors since system is off now
+ startUnit(RESET_HOST_SENSORS_SVC);
+
setStateChangeTime();
if (phosphor::state::manager::utils::getGpioValue(
@@ -321,14 +327,12 @@
return;
}
-void Chassis::executeTransition(Transition tranReq)
+void Chassis::startUnit(const std::string& sysdUnit)
{
- auto sysdTarget = SYSTEMD_TARGET_TABLE.find(tranReq)->second;
-
auto method = this->bus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
SYSTEMD_INTERFACE, "StartUnit");
- method.append(sysdTarget);
+ method.append(sysdUnit);
method.append("replace");
this->bus.call_noreply(method);
@@ -439,7 +443,7 @@
info("Change to Chassis Requested Power State: {REQ_POWER_TRAN}",
"REQ_POWER_TRAN", value);
- executeTransition(value);
+ startUnit(SYSTEMD_TARGET_TABLE.find(value)->second);
return server::Chassis::requestedPowerTransition(value);
}