blob: 8e79d1df1fcb7a42ce8c2b3a38ba1a679251daba [file] [log] [blame]
Adriana Kobylak2d8fa222017-03-15 12:34:32 -05001#pragma once
2
3#include <sdbusplus/server.hpp>
4#include "activation.hpp"
5
6namespace openpower
7{
8namespace software
9{
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -050010namespace updater
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050011{
12
13/** @class ItemUpdater
14 * @brief Manages the activation of the version items.
15 */
16class ItemUpdater
17{
18 public:
19 ItemUpdater() = delete;
20 ~ItemUpdater() = default;
21 ItemUpdater(const ItemUpdater&) = delete;
22 ItemUpdater& operator=(const ItemUpdater&) = delete;
23 ItemUpdater(ItemUpdater&&) = delete;
24 ItemUpdater& operator=(ItemUpdater&&) = delete;
25
26 /** @brief Constructs ItemUpdater
27 *
28 * @param[in] bus - The Dbus bus object
29 */
30 ItemUpdater(sdbusplus::bus::bus& bus) :
31 busItem(bus),
32 versionMatch(
33 bus,
34 "type='signal',"
35 "member='InterfacesAdded',"
36 "path='/xyz/openbmc_project/software',"
37 "interface='org.freedesktop.DBus.ObjectManager'",
38 createActivation,
39 this)
40 {
41 }
42
43 private:
44 /** @brief Callback function for Software.Version match.
45 * @details Creates an Activation dbus object.
46 *
47 * @param[in] msg - Data associated with subscribed signal
48 * @param[in] userData - Pointer to this object instance
49 * @param[out] retError - Required param
50 */
51 static int createActivation(sd_bus_message* msg,
52 void* userData,
53 sd_bus_error* retError);
54
Saqib Khan7254f0e2017-04-10 21:45:37 -050055 /**
56 * @brief Get the extended version from the specified file.
57 *
58 * @param[in] manifestFilePath - File to read.
59 *
60 * @return The extended version.
61 */
62 static std::string getExtendedVersion(const std::string&
63 manifestFilePath);
Saqib Khana8ade7e2017-04-12 10:27:56 -050064 /**
65 * @brief Validates the presence of SquashFS iamge in the image dir.
66 *
67 * @param[in] versionId - The software version ID.
68 * @param[out] result - 0 --> if validation was successful
69 * - -1--> Otherwise
70 */
71 static int validateSquashFSImage(const std::string& versionId);
Saqib Khan7254f0e2017-04-10 21:45:37 -050072
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050073 /** @brief Persistent sdbusplus DBus bus connection. */
74 sdbusplus::bus::bus& busItem;
75
76 /** @brief Persistent map of Activation dbus objects and their
77 * version id */
Adriana Kobylak268616b2017-04-05 15:23:30 -050078 std::map<std::string, std::unique_ptr<Activation>> activations;
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050079
80 /** @brief sdbusplus signal match for Software.Version */
81 sdbusplus::server::match::match versionMatch;
82};
83
Adriana Kobylakbefe5ce2017-04-05 15:57:44 -050084} // namespace updater
Adriana Kobylak2d8fa222017-03-15 12:34:32 -050085} // namespace software
86} // namespace openpower
87