blob: 9d567223dc4184bf5aa1041a7da1dad07b228eb1 [file] [log] [blame]
Patrick Venture26a17262019-05-20 11:03:35 -07001#pragma once
2
3#include "status.hpp"
Patrick Venture26a17262019-05-20 11:03:35 -07004
5#include <memory>
6#include <sdbusplus/bus.hpp>
7#include <string>
8
Patrick Venture1d5a31c2019-05-20 11:38:22 -07009namespace ipmi_flash
Patrick Venture26a17262019-05-20 11:03:35 -070010{
11
12/**
13 * Representation of what is used for verification. Currently, this reduces the
14 * chance of error by using an object instead of two strings to control the
15 * verification step, however, it leaves room for a future possibility out
16 * something wholly configurable.
17 */
Patrick Venture1d66fe62019-06-03 14:57:27 -070018class SystemdVerification : public TriggerableActionInterface
Patrick Venture26a17262019-05-20 11:03:35 -070019{
20 public:
21 /**
22 * Create a default Verification object that uses systemd to trigger the
23 * process.
24 *
25 * @param[in] bus - an sdbusplus handler for a bus to use.
26 * @param[in] path - the path to check for verification status.
Patrick Ventureee614ec2019-08-05 12:08:44 -070027 * @param[in] service - the systemd service to start to trigger
Patrick Venture26a17262019-05-20 11:03:35 -070028 * verification.
Patrick Ventureee614ec2019-08-05 12:08:44 -070029 * @param[in] mode - the job-mode when starting the systemd Unit.
Patrick Venture26a17262019-05-20 11:03:35 -070030 */
Patrick Venture1d66fe62019-06-03 14:57:27 -070031 static std::unique_ptr<TriggerableActionInterface>
Patrick Venture26a17262019-05-20 11:03:35 -070032 CreateVerification(sdbusplus::bus::bus&& bus, const std::string& path,
Patrick Ventureee614ec2019-08-05 12:08:44 -070033 const std::string& service, const std::string& mode);
Patrick Venture26a17262019-05-20 11:03:35 -070034
35 SystemdVerification(sdbusplus::bus::bus&& bus, const std::string& path,
Patrick Ventureee614ec2019-08-05 12:08:44 -070036 const std::string& service, const std::string& mode) :
Patrick Venture26a17262019-05-20 11:03:35 -070037 bus(std::move(bus)),
Patrick Ventureee614ec2019-08-05 12:08:44 -070038 checkPath(path), triggerService(service), mode(mode)
Patrick Venture26a17262019-05-20 11:03:35 -070039 {
40 }
41
42 ~SystemdVerification() = default;
43 SystemdVerification(const SystemdVerification&) = delete;
44 SystemdVerification& operator=(const SystemdVerification&) = delete;
45 SystemdVerification(SystemdVerification&&) = default;
46 SystemdVerification& operator=(SystemdVerification&&) = default;
47
Patrick Venture1d66fe62019-06-03 14:57:27 -070048 bool trigger() override;
49 void abort() override;
Patrick Ventureda66fd82019-06-03 11:11:24 -070050 ActionStatus status() override;
Patrick Venture26a17262019-05-20 11:03:35 -070051
Patrick Ventureee614ec2019-08-05 12:08:44 -070052 const std::string getMode() const;
53
Patrick Venture26a17262019-05-20 11:03:35 -070054 private:
55 sdbusplus::bus::bus bus;
56 const std::string checkPath;
57 const std::string triggerService;
Patrick Ventureee614ec2019-08-05 12:08:44 -070058 const std::string mode;
Patrick Venture26a17262019-05-20 11:03:35 -070059};
Patrick Venture1d5a31c2019-05-20 11:38:22 -070060} // namespace ipmi_flash