blob: 693beb455984af92ad4b7c7870699a8dca205d7d [file] [log] [blame]
#pragma once
#include "update.hpp"
#include <memory>
#include <sdbusplus/bus.hpp>
#include <string>
namespace ipmi_flash
{
/**
* Implements the update interface by simply triggering a systemd unit.
*/
class SystemdUpdateMechanism : public UpdateInterface
{
public:
static std::unique_ptr<UpdateInterface>
CreateSystemdUpdate(sdbusplus::bus::bus&& bus,
const std::string& target,
const std::string& mode = "");
SystemdUpdateMechanism(sdbusplus::bus::bus&& bus, const std::string& target,
const std::string& mode) :
bus(std::move(bus)),
target(target), mode(mode)
{
}
~SystemdUpdateMechanism() = default;
SystemdUpdateMechanism(const SystemdUpdateMechanism&) = delete;
SystemdUpdateMechanism& operator=(const SystemdUpdateMechanism&) = delete;
SystemdUpdateMechanism(SystemdUpdateMechanism&&) = default;
SystemdUpdateMechanism& operator=(SystemdUpdateMechanism&&) = default;
bool triggerUpdate() override;
void abortUpdate() override;
ActionStatus status() override;
private:
sdbusplus::bus::bus bus;
const std::string target;
const std::string mode;
};
} // namespace ipmi_flash