Code Update: Host ApplyTime support

Get the requested image apply time value provided through the
UpdateService redfish schema. If the apply time value is Immediate, then
host reboot will be triggered just after the new pnor image activation. The
default apply time value is OnReset in which the new image remains at
Active state and user has to manualy reboot the host for applying the new
image.

Tested: Verified that host is getting rebooted while doing a pnor code update
if the apply time value is Immediate.  Tested this use case at server power Off
and Running scenarios. OnReset scenario was also tested in which new image
remained at Active state as pnor code update application did not trigger the
host reboot.

Note: This change is applicable to ubi based systems (Witherspoon)

Signed-off-by: Jayashankar Padath <jayashankar.padath@in.ibm.com>
Change-Id: I74f73172626919b225efef43d9baacd64eadbf60
diff --git a/ubi/activation_ubi.cpp b/ubi/activation_ubi.cpp
index 5c57c4b..4575a61 100644
--- a/ubi/activation_ubi.cpp
+++ b/ubi/activation_ubi.cpp
@@ -4,6 +4,7 @@
 #include "serialize.hpp"
 
 #include <experimental/filesystem>
+#include <phosphor-logging/log.hpp>
 
 namespace openpower
 {
@@ -13,6 +14,7 @@
 {
 namespace fs = std::experimental::filesystem;
 namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
+using namespace phosphor::logging;
 
 uint8_t RedundancyPriorityUbi::priority(uint8_t value)
 {
@@ -65,6 +67,12 @@
                 (fs::is_directory(PNOR_RO_PREFIX + versionId)))
             {
                 finishActivation();
+                if (Activation::checkApplyTimeImmediate())
+                {
+                    log<level::INFO>("Image Active. ApplyTime is immediate, "
+                                     "rebooting Host.");
+                    Activation::rebootHost();
+                }
                 return softwareServer::Activation::activation(
                     softwareServer::Activation::Activations::Active);
             }