Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/server.hpp> |
| 4 | #include "activation.hpp" |
Saqib Khan | 705f1bf | 2017-06-09 23:58:38 -0500 | [diff] [blame^] | 5 | #include "version.hpp" |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace software |
| 10 | { |
| 11 | namespace updater |
| 12 | { |
| 13 | |
Patrick Williams | e75d10f | 2017-05-30 16:56:32 -0500 | [diff] [blame] | 14 | namespace MatchRules = sdbusplus::bus::match::rules; |
| 15 | |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 16 | /** @class ItemUpdater |
| 17 | * @brief Manages the activation of the BMC version items. |
| 18 | */ |
| 19 | class ItemUpdater |
| 20 | { |
| 21 | public: |
| 22 | ItemUpdater() = delete; |
| 23 | ~ItemUpdater() = default; |
| 24 | ItemUpdater(const ItemUpdater&) = delete; |
| 25 | ItemUpdater& operator=(const ItemUpdater&) = delete; |
| 26 | ItemUpdater(ItemUpdater&&) = delete; |
| 27 | ItemUpdater& operator=(ItemUpdater&&) = delete; |
| 28 | |
Saqib Khan | 35e83f3 | 2017-05-22 11:37:32 -0500 | [diff] [blame] | 29 | /* |
| 30 | * @brief Types of Activation status for image validation. |
| 31 | */ |
| 32 | enum class ActivationStatus |
| 33 | { |
| 34 | ready, |
| 35 | invalid, |
| 36 | active |
| 37 | }; |
| 38 | |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 39 | /** @brief Constructs ItemUpdater |
| 40 | * |
| 41 | * @param[in] bus - The Dbus bus object |
| 42 | */ |
| 43 | ItemUpdater(sdbusplus::bus::bus& bus) : |
| 44 | bus(bus), |
| 45 | versionMatch( |
| 46 | bus, |
Patrick Williams | e75d10f | 2017-05-30 16:56:32 -0500 | [diff] [blame] | 47 | MatchRules::interfacesAdded() + |
| 48 | MatchRules::path("/xyz/openbmc_project/software"), |
| 49 | std::bind( |
| 50 | std::mem_fn(&ItemUpdater::createActivation), |
| 51 | this, |
| 52 | std::placeholders::_1)) |
| 53 | { |
| 54 | }; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 55 | |
| 56 | private: |
| 57 | /** @brief Callback function for Software.Version match. |
| 58 | * @details Creates an Activation dbus object. |
| 59 | * |
| 60 | * @param[in] msg - Data associated with subscribed signal |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 61 | */ |
Patrick Williams | e75d10f | 2017-05-30 16:56:32 -0500 | [diff] [blame] | 62 | void createActivation(sdbusplus::message::message& msg); |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 63 | |
Saqib Khan | 35e83f3 | 2017-05-22 11:37:32 -0500 | [diff] [blame] | 64 | /** |
| 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 - ActivationStatus Enum. |
| 69 | * ready if validation was successful. |
| 70 | * invalid if validation fail. |
| 71 | * active if image is the current version. |
| 72 | * |
| 73 | */ |
| 74 | ActivationStatus validateSquashFSImage(const std::string& versionId); |
| 75 | |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 76 | /** @brief Persistent sdbusplus DBus bus connection. */ |
| 77 | sdbusplus::bus::bus& bus; |
| 78 | |
| 79 | /** @brief Persistent map of Activation dbus objects and their |
| 80 | * version id */ |
| 81 | std::map<std::string, std::unique_ptr<Activation>> activations; |
| 82 | |
Saqib Khan | 705f1bf | 2017-06-09 23:58:38 -0500 | [diff] [blame^] | 83 | /** @brief Persistent map of Version dbus objects and their |
| 84 | * version id */ |
| 85 | std::map<std::string, std::unique_ptr<phosphor::software:: |
| 86 | manager::Version>> versions; |
| 87 | |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 88 | /** @brief sdbusplus signal match for Software.Version */ |
Patrick Williams | e75d10f | 2017-05-30 16:56:32 -0500 | [diff] [blame] | 89 | sdbusplus::bus::match_t versionMatch; |
Gunnar Mills | ec1b41c | 2017-05-02 12:20:36 -0500 | [diff] [blame] | 90 | |
| 91 | }; |
| 92 | |
| 93 | |
| 94 | |
| 95 | } // namespace updater |
| 96 | } // namespace software |
| 97 | } // namespace phosphor |