Patrick Venture | 6f81b16 | 2019-05-20 14:02:59 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 3 | #include "status.hpp" |
Patrick Venture | 6f81b16 | 2019-05-20 14:02:59 -0700 | [diff] [blame] | 4 | |
| 5 | #include <memory> |
| 6 | #include <sdbusplus/bus.hpp> |
| 7 | #include <string> |
| 8 | |
| 9 | namespace ipmi_flash |
| 10 | { |
| 11 | |
| 12 | /** |
| 13 | * Implements the update interface by simply triggering a systemd unit. |
| 14 | */ |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 15 | class SystemdUpdateMechanism : public TriggerableActionInterface |
Patrick Venture | 6f81b16 | 2019-05-20 14:02:59 -0700 | [diff] [blame] | 16 | { |
| 17 | public: |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 18 | static std::unique_ptr<TriggerableActionInterface> |
Patrick Venture | 6f81b16 | 2019-05-20 14:02:59 -0700 | [diff] [blame] | 19 | CreateSystemdUpdate(sdbusplus::bus::bus&& bus, |
| 20 | const std::string& target, |
| 21 | const std::string& mode = ""); |
| 22 | |
| 23 | SystemdUpdateMechanism(sdbusplus::bus::bus&& bus, const std::string& target, |
| 24 | const std::string& mode) : |
| 25 | bus(std::move(bus)), |
| 26 | target(target), mode(mode) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | ~SystemdUpdateMechanism() = default; |
| 31 | SystemdUpdateMechanism(const SystemdUpdateMechanism&) = delete; |
| 32 | SystemdUpdateMechanism& operator=(const SystemdUpdateMechanism&) = delete; |
| 33 | SystemdUpdateMechanism(SystemdUpdateMechanism&&) = default; |
| 34 | SystemdUpdateMechanism& operator=(SystemdUpdateMechanism&&) = default; |
| 35 | |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 36 | bool trigger() override; |
| 37 | void abort() override; |
Patrick Venture | da66fd8 | 2019-06-03 11:11:24 -0700 | [diff] [blame] | 38 | ActionStatus status() override; |
Patrick Venture | 6f81b16 | 2019-05-20 14:02:59 -0700 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | sdbusplus::bus::bus bus; |
| 42 | const std::string target; |
| 43 | const std::string mode; |
| 44 | }; |
| 45 | |
| 46 | } // namespace ipmi_flash |