watchdog: Implement watchdog action setting

We now respect the action set during the SetTimeout command. This maps
to one of the actions defined by the dbus Watchdog interface

Change-Id: I4d13d2539a2d955a4340bf5f915ca6f3b694550a
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
index 36a967c..f11c4bf 100644
--- a/app/watchdog_service.cpp
+++ b/app/watchdog_service.cpp
@@ -3,12 +3,15 @@
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/message.hpp>
 #include <string>
+#include <xyz/openbmc_project/State/Watchdog/server.hpp>
 
 #include "host-ipmid/ipmid-api.h"
 #include "utils.hpp"
 
 using sdbusplus::message::variant_ns::get;
 using sdbusplus::message::variant_ns::variant;
+using sdbusplus::xyz::openbmc_project::State::server::convertForMessage;
+using sdbusplus::xyz::openbmc_project::State::server::Watchdog;
 
 static constexpr char wd_path[] = "/xyz/openbmc_project/watchdog/host0";
 static constexpr char wd_intf[] = "xyz.openbmc_project.State.Watchdog";
@@ -36,6 +39,8 @@
     Properties wd_prop;
     wd_prop.initialized = get<bool>(properties.at("Initialized"));
     wd_prop.enabled = get<bool>(properties.at("Enabled"));
+    wd_prop.expireAction = Watchdog::convertActionFromString(
+            get<std::string>(properties.at("ExpireAction")));
     wd_prop.interval = get<uint64_t>(properties.at("Interval"));
     wd_prop.timeRemaining = get<uint64_t>(properties.at("TimeRemaining"));
     return wd_prop;
@@ -64,6 +69,11 @@
     setProperty("Enabled", enabled);
 }
 
+void WatchdogService::setExpireAction(Action expireAction)
+{
+    setProperty("ExpireAction", convertForMessage(expireAction));
+}
+
 void WatchdogService::setInterval(uint64_t interval)
 {
     setProperty("Interval", interval);