Patrick Venture | 6f81b16 | 2019-05-20 14:02:59 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "update.hpp" |
| 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 | */ |
| 15 | class SystemdUpdateMechanism : public UpdateInterface |
| 16 | { |
| 17 | public: |
| 18 | static std::unique_ptr<UpdateInterface> |
| 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 | |
| 36 | bool triggerUpdate() override; |
| 37 | void abortUpdate() 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 |