Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "status.hpp" |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 4 | |
| 5 | #include <memory> |
| 6 | #include <sdbusplus/bus.hpp> |
| 7 | #include <string> |
| 8 | |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 9 | namespace ipmi_flash |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 10 | { |
| 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 Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 18 | class SystemdVerification : public TriggerableActionInterface |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 19 | { |
| 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 Venture | ee614ec | 2019-08-05 12:08:44 -0700 | [diff] [blame] | 27 | * @param[in] service - the systemd service to start to trigger |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 28 | * verification. |
Patrick Venture | ee614ec | 2019-08-05 12:08:44 -0700 | [diff] [blame] | 29 | * @param[in] mode - the job-mode when starting the systemd Unit. |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 30 | */ |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 31 | static std::unique_ptr<TriggerableActionInterface> |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 32 | CreateVerification(sdbusplus::bus::bus&& bus, const std::string& path, |
Patrick Venture | ee614ec | 2019-08-05 12:08:44 -0700 | [diff] [blame] | 33 | const std::string& service, const std::string& mode); |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 34 | |
| 35 | SystemdVerification(sdbusplus::bus::bus&& bus, const std::string& path, |
Patrick Venture | ee614ec | 2019-08-05 12:08:44 -0700 | [diff] [blame] | 36 | const std::string& service, const std::string& mode) : |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 37 | bus(std::move(bus)), |
Patrick Venture | ee614ec | 2019-08-05 12:08:44 -0700 | [diff] [blame] | 38 | checkPath(path), triggerService(service), mode(mode) |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 39 | { |
| 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 Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 48 | bool trigger() override; |
| 49 | void abort() override; |
Patrick Venture | da66fd8 | 2019-06-03 11:11:24 -0700 | [diff] [blame] | 50 | ActionStatus status() override; |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 51 | |
Patrick Venture | ee614ec | 2019-08-05 12:08:44 -0700 | [diff] [blame] | 52 | const std::string getMode() const; |
| 53 | |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 54 | private: |
| 55 | sdbusplus::bus::bus bus; |
| 56 | const std::string checkPath; |
| 57 | const std::string triggerService; |
Patrick Venture | ee614ec | 2019-08-05 12:08:44 -0700 | [diff] [blame] | 58 | const std::string mode; |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 59 | }; |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 60 | } // namespace ipmi_flash |