summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2019-08-05 12:08:44 -0700
committerPatrick Venture <venture@google.com>2019-08-05 13:22:18 -0700
commitee614ec1d1b10bceb0b4a68ca2413377c518e29d (patch)
tree3e5f271345732bfaa254f196f8f0e64342d49316
parent0caec99f7851fc72bb262627dfbac587f64709a2 (diff)
downloadphosphor-ipmi-flash-ee614ec1d1b10bceb0b4a68ca2413377c518e29d.tar.gz
phosphor-ipmi-flash-ee614ec1d1b10bceb0b4a68ca2413377c518e29d.zip
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
-rw-r--r--bmc/buildjson.cpp3
-rw-r--r--bmc/test/firmware_json_unittest.cpp4
-rw-r--r--bmc/verify_systemd.cpp13
-rw-r--r--bmc/verify_systemd.hpp12
4 files changed, 24 insertions, 8 deletions
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 @@ std::vector<HandlerConfig> buildHandlerFromJson(const nlohmann::json& data)
{
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 @@ TEST(FirmwareJsonTest, VerifyValidSingleNonReboot)
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 @@ namespace ipmi_flash
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 @@ bool SystemdVerification::trigger()
auto method = bus.new_method_call(systemdService, systemdRoot,
systemdInterface, "StartUnit");
method.append(triggerService);
- method.append("replace");
+ method.append(mode);
try
{
@@ -97,4 +99,9 @@ ActionStatus SystemdVerification::status()
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 @@ class SystemdVerification : public TriggerableActionInterface
*
* @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 @@ class SystemdVerification : public TriggerableActionInterface
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
OpenPOWER on IntegriCloud