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, |
Patrick Venture | ec105dd | 2019-08-05 09:35:26 -0700 | [diff] [blame^] | 20 | const std::string& target, const std::string& mode); |
Patrick Venture | 6f81b16 | 2019-05-20 14:02:59 -0700 | [diff] [blame] | 21 | |
| 22 | SystemdUpdateMechanism(sdbusplus::bus::bus&& bus, const std::string& target, |
| 23 | const std::string& mode) : |
| 24 | bus(std::move(bus)), |
| 25 | target(target), mode(mode) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | ~SystemdUpdateMechanism() = default; |
| 30 | SystemdUpdateMechanism(const SystemdUpdateMechanism&) = delete; |
| 31 | SystemdUpdateMechanism& operator=(const SystemdUpdateMechanism&) = delete; |
| 32 | SystemdUpdateMechanism(SystemdUpdateMechanism&&) = default; |
| 33 | SystemdUpdateMechanism& operator=(SystemdUpdateMechanism&&) = default; |
| 34 | |
Patrick Venture | 1d66fe6 | 2019-06-03 14:57:27 -0700 | [diff] [blame] | 35 | bool trigger() override; |
| 36 | void abort() override; |
Patrick Venture | da66fd8 | 2019-06-03 11:11:24 -0700 | [diff] [blame] | 37 | ActionStatus status() override; |
Patrick Venture | 6f81b16 | 2019-05-20 14:02:59 -0700 | [diff] [blame] | 38 | |
| 39 | private: |
| 40 | sdbusplus::bus::bus bus; |
| 41 | const std::string target; |
| 42 | const std::string mode; |
| 43 | }; |
| 44 | |
| 45 | } // namespace ipmi_flash |