blob: 15d616fbf19e13f3118a39ce6058b6392a3c5a57 [file] [log] [blame]
Patrick Venture6f81b162019-05-20 14:02:59 -07001#pragma once
2
Patrick Venture1d66fe62019-06-03 14:57:27 -07003#include "status.hpp"
Patrick Venture6f81b162019-05-20 14:02:59 -07004
5#include <memory>
6#include <sdbusplus/bus.hpp>
7#include <string>
8
9namespace ipmi_flash
10{
11
12/**
13 * Implements the update interface by simply triggering a systemd unit.
14 */
Patrick Venture1d66fe62019-06-03 14:57:27 -070015class SystemdUpdateMechanism : public TriggerableActionInterface
Patrick Venture6f81b162019-05-20 14:02:59 -070016{
17 public:
Patrick Venture1d66fe62019-06-03 14:57:27 -070018 static std::unique_ptr<TriggerableActionInterface>
Patrick Venture6f81b162019-05-20 14:02:59 -070019 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 Venture1d66fe62019-06-03 14:57:27 -070036 bool trigger() override;
37 void abort() override;
Patrick Ventureda66fd82019-06-03 11:11:24 -070038 ActionStatus status() override;
Patrick Venture6f81b162019-05-20 14:02:59 -070039
40 private:
41 sdbusplus::bus::bus bus;
42 const std::string target;
43 const std::string mode;
44};
45
46} // namespace ipmi_flash