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. |
| 27 | * @param[in[ service - the systemd service to start to trigger |
| 28 | * verification. |
| 29 | */ |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 30 | static std::unique_ptr<TriggerableActionInterface> |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 31 | CreateVerification(sdbusplus::bus::bus&& bus, const std::string& path, |
| 32 | const std::string& service); |
| 33 | |
| 34 | SystemdVerification(sdbusplus::bus::bus&& bus, const std::string& path, |
| 35 | const std::string& service) : |
| 36 | bus(std::move(bus)), |
| 37 | checkPath(path), triggerService(service) |
| 38 | { |
| 39 | } |
| 40 | |
| 41 | ~SystemdVerification() = default; |
| 42 | SystemdVerification(const SystemdVerification&) = delete; |
| 43 | SystemdVerification& operator=(const SystemdVerification&) = delete; |
| 44 | SystemdVerification(SystemdVerification&&) = default; |
| 45 | SystemdVerification& operator=(SystemdVerification&&) = default; |
| 46 | |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 47 | bool trigger() override; |
| 48 | void abort() override; |
Patrick Venture | da66fd8 | 2019-06-03 11:11:24 -0700 | [diff] [blame] | 49 | ActionStatus status() override; |
Patrick Venture | 26a1726 | 2019-05-20 11:03:35 -0700 | [diff] [blame] | 50 | |
| 51 | private: |
| 52 | sdbusplus::bus::bus bus; |
| 53 | const std::string checkPath; |
| 54 | const std::string triggerService; |
| 55 | }; |
Patrick Venture | 1d5a31c | 2019-05-20 11:38:22 -0700 | [diff] [blame] | 56 | } // namespace ipmi_flash |