power-on-hours: ensure not incremented when system off
Poh counter is incrementing once the timer expires and chassis is power
on. setEnabled will not stops the timer if chassis is poweroff, and the
counter get increments within remaining expring time. Hence, resetting
the remainingexpiring time for poweron state, so counter get increment
after 1 hour intervel.
tested:
root@dgx:~# ipmitool chassis power off
Chassis Power Control: Down/Off
jounal logs:
------------
4267:Jan 01 00:05:52 dgx phosphor-chassis-state-manager[369]: Received
signal that power OFF is complete
4268:Jan 01 00:05:52 dgx phosphor-chassis-state-manager[369]: Change to
Chassis Power State: xyz.openbmc_project.State.Chassis.PowerState.Off
4269:Jan 01 00:05:52 dgx phosphor-host-state-manager[448]: Received sig-
nal that host is off
4270:Jan 01 00:05:52 dgx phosphor-host-state-manager[448]: Change to Host
State: xyz.openbmc_project.State.Host.HostState.Off
root@dgx:~#
root@dgx:~# ipmitool chassis power status
Chassis Power is off
root@dgx:~#
root@dgx:~# ipmitool raw 0x0 0x0f
3c 16 00 00 00
root@dgx:~#
journal logs:
------------
7471:Jan 01 01:38:29 dgx phosphor-chassis-state-manager[369]: Received
signal that power ON is complete
7472:Jan 01 01:38:29 dgx phosphor-chassis-state-manager[369]: Change to
Chassis Power State: xyz.openbmc_project.State.Chassis.PowerState.On
7473:Jan 01 01:38:29 dgx phosphor-host-state-manager[448]: Received sig-
nal that host is running
7474:Jan 01 01:38:29 dgx phosphor-host-state-manager[448]: Change to Host
State: xyz.openbmc_project.State.Host.HostState.Running
root@dgx:~# ipmitool raw 0x0 0x0f
3c 16 00 00 00
root@dgx:~# date
Thu Jan 1 01:39:25 UTC 1970
root@dgx:~# ipmitool chassis power status
Chassis Power is on
root@dgx:~# ipmitool raw 0x0 0x0f
3c 16 00 00 00
root@dgx:~# date
Thu Jan 1 02:25:58 UTC 1970
root@dgx:~# date
Thu Jan 1 02:38:29 UTC 1970
root@dgx:~# ipmitool raw 0x0 0x0f
3c 16 00 00 00
root@dgx:~# ipmitool raw 0x0 0x0f
3c 17 00 00 00
Signed-off-by: shamim ali <shamima@ami.com>
Change-Id: I8ca2c6b32813ed9559ef2edcc26c7216b0fc33b2
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index 310b817..fc1abac 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -463,7 +463,10 @@
value);
chassisPowerState = server::Chassis::currentPowerState(value);
- pohTimer.setEnabled(chassisPowerState == PowerState::On);
+ if (chassisPowerState == PowerState::On)
+ {
+ pohTimer.resetRemaining();
+ }
return chassisPowerState;
}