summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaqib Khan <khansa@us.ibm.com>2017-03-10 01:29:20 -0600
committerSaqib Khan <khansa@us.ibm.com>2017-03-20 09:01:24 -0500
commitcbe08d1476eddeb643d4c25a1f8721792eabe0dc (patch)
treef3d676aa41fac41fad96f1d535d0af4f701d8a86
parent2b5d887852c228ceb3cf2a89521498b596954ff9 (diff)
downloadphosphor-state-manager-cbe08d1476eddeb643d4c25a1f8721792eabe0dc.tar.gz
phosphor-state-manager-cbe08d1476eddeb643d4c25a1f8721792eabe0dc.zip
Use the Host BOOTCOUNT to keep track of reboots
We will use the existing HOST BOOTCOUNT to determine if the Host should perform a reboot before going to the quiesce state. When the counter reaches 0, the BOOTCOUNT will be reset to 2 and the HOST will enter the quiesce state. Resolves openbmc/openbmc#1181 Change-Id: Ib67792476993899c6c21f3917f4b760040f23a2e Signed-off-by: Saqib Khan <khansa@us.ibm.com>
-rw-r--r--host_state_manager.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index a7de920..10d5abc 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -41,6 +41,12 @@ constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
constexpr auto MAPPER_PATH = "/xyz/openbmc_project/ObjectMapper";
constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
+constexpr auto REBOOTCOUNTER_SERVICE("org.openbmc.Sensors");
+constexpr auto REBOOTCOUNTER_PATH("/org/openbmc/sensors/host/BootCount");
+constexpr auto REBOOTCOUNTER_INTERFACE("org.openbmc.SensorValue");
+
+const sdbusplus::message::variant<int> DEFAULT_BOOTCOUNT = 2;
+
/* Map a system state to the HostState */
const std::map<std::string, server::Host::HostState> SYS_HOST_STATE_TABLE = {
{"HOST_BOOTING", server::Host::HostState::Running},
@@ -171,9 +177,40 @@ bool Host::isAutoReboot()
return false;
}
+ sdbusplus::message::variant<int> rebootCounterParam;
+ method = this->bus.new_method_call(REBOOTCOUNTER_SERVICE,
+ REBOOTCOUNTER_PATH,
+ REBOOTCOUNTER_INTERFACE,
+ "getValue");
+ reply = this->bus.call(method);
+ if (reply.is_method_error())
+ {
+ log<level::ERR>("Error in BOOTCOUNT getValue");
+ return false;
+ }
+ reply.read(rebootCounterParam);
+
if (strParam == "yes")
{
- return true;
+ method = this->bus.new_method_call(REBOOTCOUNTER_SERVICE,
+ REBOOTCOUNTER_PATH,
+ REBOOTCOUNTER_INTERFACE,
+ "setValue");
+ if( rebootCounterParam > 0)
+ {
+ // Reduce BOOTCOUNT by 1
+ method.append((sdbusplus::message::variant_ns::
+ get<int>(rebootCounterParam)) - 1);
+ this->bus.call_noreply(method);
+ return true;
+ }
+ if(rebootCounterParam == 0)
+ {
+ // Reset reboot counter and go to quiesce state
+ method.append(DEFAULT_BOOTCOUNT);
+ this->bus.call_noreply(method);
+ return false;
+ }
}
return false;
OpenPOWER on IntegriCloud