-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathupdate_manager.hpp
76 lines (62 loc) · 2.33 KB
/
update_manager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include "config.h"
#include <sdbusplus/async.hpp>
#include <xyz/openbmc_project/Software/Update/server.hpp>
#include <random>
#include <string>
#include <tuple>
namespace phosphor::software::updater
{
class ItemUpdater;
}
namespace phosphor::software::update
{
using UpdateIntf = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::Software::server::Update>;
using ItemUpdaterIntf = phosphor::software::updater::ItemUpdater;
using ApplyTimeIntf =
sdbusplus::common::xyz::openbmc_project::software::ApplyTime;
/** @class Manager
* @brief Processes the image file from update D-Bus interface.
* @details The update manager class handles software updates and manages
* software info through version and activation objects.
*/
class Manager : public UpdateIntf
{
public:
/** @brief Constructs Manager Class
*
* @param[in] bus - The Dbus bus object
*/
explicit Manager(sdbusplus::async::context& ctx, const std::string& path,
ItemUpdaterIntf& itemUpdater) :
UpdateIntf(ctx.get_bus(), path.c_str(), UpdateIntf::action::defer_emit),
ctx(ctx), itemUpdater(itemUpdater)
{
emit_object_added();
}
private:
/** @brief Implementation for StartUpdate
* Start a firware update to be performed asynchronously.
*/
sdbusplus::message::object_path
startUpdate(sdbusplus::message::unix_fd image,
ApplyTimeIntf::RequestedApplyTimes applyTime) override;
/* @brief Process the image supplied via image fd */
auto processImage(sdbusplus::message::unix_fd image,
ApplyTimeIntf::RequestedApplyTimes applyTime,
std::string id, std::string objPath)
-> sdbusplus::async::task<>;
/* @brief The handler for the image processing failure */
void processImageFailed(sdbusplus::message::unix_fd image, std::string& id);
/** @brief The random generator for the software id */
std::mt19937 randomGen{static_cast<unsigned>(
std::chrono::system_clock::now().time_since_epoch().count())};
/** @brief D-Bus context */
sdbusplus::async::context& ctx;
/** @brief item_updater reference */
ItemUpdaterIntf& itemUpdater;
/** @brief State whether update is in progress */
bool updateInProgress = false;
};
} // namespace phosphor::software::update