blob: 47c8d67b3fc03133ea40b596f4e6c5d25ffd91d7 [file] [log] [blame]
Patrick Venture6f81b162019-05-20 14:02:59 -07001#pragma once
2
3#include "update.hpp"
4
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 */
15class 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;
38 UpdateStatus status() override;
39
40 private:
41 sdbusplus::bus::bus bus;
42 const std::string target;
43 const std::string mode;
44};
45
46} // namespace ipmi_flash