bmc: move verify systemd mode to parameter

Move the mode for the trigger service to a parameter instead of
hard-coding it.  This isn't yet a json configuration option, that'll be
next.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I59564320015c22be1ec3a4701479d0ee93b9f1f7
diff --git a/bmc/buildjson.cpp b/bmc/buildjson.cpp
index d8a9ea1..60575db 100644
--- a/bmc/buildjson.cpp
+++ b/bmc/buildjson.cpp
@@ -91,8 +91,9 @@
             {
                 const auto& path = verify.at("path");
                 const auto& unit = verify.at("unit");
+                const std::string mode = "replace";
                 pack->verification = SystemdVerification::CreateVerification(
-                    sdbusplus::bus::new_default(), path, unit);
+                    sdbusplus::bus::new_default(), path, unit, mode);
             }
             else
             {
diff --git a/bmc/test/firmware_json_unittest.cpp b/bmc/test/firmware_json_unittest.cpp
index 04c0f09..8b4f130 100644
--- a/bmc/test/firmware_json_unittest.cpp
+++ b/bmc/test/firmware_json_unittest.cpp
@@ -1,5 +1,6 @@
 #include "buildjson.hpp"
 #include "update_systemd.hpp"
+#include "verify_systemd.hpp"
 
 #include <nlohmann/json.hpp>
 
@@ -423,6 +424,9 @@
     EXPECT_FALSE(h[0].actions == nullptr);
     EXPECT_FALSE(h[0].actions->preparation == nullptr);
     EXPECT_FALSE(h[0].actions->verification == nullptr);
+    auto verifier = reinterpret_cast<SystemdVerification*>(
+        h[0].actions->verification.get());
+    EXPECT_THAT(verifier->getMode(), "replace");
     EXPECT_FALSE(h[0].actions->update == nullptr);
     auto updater =
         reinterpret_cast<SystemdUpdateMechanism*>(h[0].actions->update.get());
diff --git a/bmc/verify_systemd.cpp b/bmc/verify_systemd.cpp
index f7b88b0..e3316a0 100644
--- a/bmc/verify_systemd.cpp
+++ b/bmc/verify_systemd.cpp
@@ -30,9 +30,11 @@
 std::unique_ptr<TriggerableActionInterface>
     SystemdVerification::CreateVerification(sdbusplus::bus::bus&& bus,
                                             const std::string& path,
-                                            const std::string& service)
+                                            const std::string& service,
+                                            const std::string& mode)
 {
-    return std::make_unique<SystemdVerification>(std::move(bus), path, service);
+    return std::make_unique<SystemdVerification>(std::move(bus), path, service,
+                                                 mode);
 }
 
 bool SystemdVerification::trigger()
@@ -44,7 +46,7 @@
     auto method = bus.new_method_call(systemdService, systemdRoot,
                                       systemdInterface, "StartUnit");
     method.append(triggerService);
-    method.append("replace");
+    method.append(mode);
 
     try
     {
@@ -97,4 +99,9 @@
     return result;
 }
 
+const std::string SystemdVerification::getMode() const
+{
+    return mode;
+}
+
 } // namespace ipmi_flash
diff --git a/bmc/verify_systemd.hpp b/bmc/verify_systemd.hpp
index 894b534..9d56722 100644
--- a/bmc/verify_systemd.hpp
+++ b/bmc/verify_systemd.hpp
@@ -24,17 +24,18 @@
      *
      * @param[in] bus - an sdbusplus handler for a bus to use.
      * @param[in] path - the path to check for verification status.
-     * @param[in[ service - the systemd service to start to trigger
+     * @param[in] service - the systemd service to start to trigger
      * verification.
+     * @param[in] mode - the job-mode when starting the systemd Unit.
      */
     static std::unique_ptr<TriggerableActionInterface>
         CreateVerification(sdbusplus::bus::bus&& bus, const std::string& path,
-                           const std::string& service);
+                           const std::string& service, const std::string& mode);
 
     SystemdVerification(sdbusplus::bus::bus&& bus, const std::string& path,
-                        const std::string& service) :
+                        const std::string& service, const std::string& mode) :
         bus(std::move(bus)),
-        checkPath(path), triggerService(service)
+        checkPath(path), triggerService(service), mode(mode)
     {
     }
 
@@ -48,9 +49,12 @@
     void abort() override;
     ActionStatus status() override;
 
+    const std::string getMode() const;
+
   private:
     sdbusplus::bus::bus bus;
     const std::string checkPath;
     const std::string triggerService;
+    const std::string mode;
 };
 } // namespace ipmi_flash