blob: a8dd8fcc7c4e417a76a8c01c77ac25759e1069b7 [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,
Patrick Ventureec105dd2019-08-05 09:35:26 -070020 const std::string& target, const std::string& mode);
Patrick Venture6f81b162019-05-20 14:02:59 -070021
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 Venture1d66fe62019-06-03 14:57:27 -070035 bool trigger() override;
36 void abort() override;
Patrick Ventureda66fd82019-06-03 11:11:24 -070037 ActionStatus status() override;
Patrick Venture6f81b162019-05-20 14:02:59 -070038
Patrick Venture0caec992019-08-05 09:58:27 -070039 const std::string getMode() const;
40
Patrick Venture6f81b162019-05-20 14:02:59 -070041 private:
42 sdbusplus::bus::bus bus;
43 const std::string target;
44 const std::string mode;
45};
46
47} // namespace ipmi_flash