Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/server.hpp> |
| 4 | #include "activation.hpp" |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 5 | #include <xyz/openbmc_project/Common/FactoryReset/server.hpp> |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 6 | #include "version.hpp" |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 7 | |
| 8 | namespace openpower |
| 9 | { |
| 10 | namespace software |
| 11 | { |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 12 | namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 13 | { |
| 14 | |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 15 | using ItemUpdaterInherit = sdbusplus::server::object::object< |
| 16 | sdbusplus::xyz::openbmc_project::Common::server::FactoryReset>; |
Patrick Williams | 3accb32 | 2017-05-30 16:29:52 -0500 | [diff] [blame] | 17 | namespace MatchRules = sdbusplus::bus::match::rules; |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 18 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 19 | /** @class ItemUpdater |
| 20 | * @brief Manages the activation of the version items. |
| 21 | */ |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 22 | class ItemUpdater : public ItemUpdaterInherit |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 23 | { |
| 24 | public: |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 25 | /** @brief Constructs ItemUpdater |
| 26 | * |
| 27 | * @param[in] bus - The Dbus bus object |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 28 | * @param[in] path - The Dbus path |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 29 | */ |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 30 | ItemUpdater(sdbusplus::bus::bus& bus, const std::string& path) : |
| 31 | ItemUpdaterInherit(bus, path.c_str()), |
Adriana Kobylak | d6a549e | 2017-05-10 16:23:01 -0500 | [diff] [blame] | 32 | bus(bus), |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 33 | versionMatch( |
| 34 | bus, |
Patrick Williams | 3accb32 | 2017-05-30 16:29:52 -0500 | [diff] [blame] | 35 | MatchRules::interfacesAdded() + |
| 36 | MatchRules::path("/xyz/openbmc_project/software"), |
| 37 | std::bind( |
| 38 | std::mem_fn(&ItemUpdater::createActivation), |
| 39 | this, |
| 40 | std::placeholders::_1)) |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 41 | { |
| 42 | } |
| 43 | |
Saqib Khan | 81bac88 | 2017-06-08 12:17:01 -0500 | [diff] [blame^] | 44 | /** @brief Sets the given priority free by incrementing |
| 45 | * any existing priority with the same value by 1 |
| 46 | * |
| 47 | * @param[in] value - The priority that needs to be set free. |
| 48 | * |
| 49 | * @return None |
| 50 | */ |
| 51 | void freePriority(uint8_t value); |
| 52 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 53 | private: |
| 54 | /** @brief Callback function for Software.Version match. |
| 55 | * @details Creates an Activation dbus object. |
| 56 | * |
| 57 | * @param[in] msg - Data associated with subscribed signal |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 58 | */ |
Patrick Williams | 3accb32 | 2017-05-30 16:29:52 -0500 | [diff] [blame] | 59 | void createActivation(sdbusplus::message::message& msg); |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 60 | |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 61 | /** |
| 62 | * @brief Get the extended version from the specified file. |
| 63 | * |
| 64 | * @param[in] manifestFilePath - File to read. |
| 65 | * |
| 66 | * @return The extended version. |
| 67 | */ |
| 68 | static std::string getExtendedVersion(const std::string& |
| 69 | manifestFilePath); |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 70 | /** |
| 71 | * @brief Validates the presence of SquashFS iamge in the image dir. |
| 72 | * |
Adriana Kobylak | 5ba6b10 | 2017-05-19 09:41:27 -0500 | [diff] [blame] | 73 | * @param[in] filePath - The path to the SquashfFS image. |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 74 | * @param[out] result - 0 --> if validation was successful |
| 75 | * - -1--> Otherwise |
| 76 | */ |
Adriana Kobylak | 5ba6b10 | 2017-05-19 09:41:27 -0500 | [diff] [blame] | 77 | static int validateSquashFSImage(const std::string& filePath); |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 78 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 79 | /** @brief Persistent sdbusplus DBus bus connection. */ |
Adriana Kobylak | d6a549e | 2017-05-10 16:23:01 -0500 | [diff] [blame] | 80 | sdbusplus::bus::bus& bus; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 81 | |
| 82 | /** @brief Persistent map of Activation dbus objects and their |
| 83 | * version id */ |
Adriana Kobylak | 268616b | 2017-04-05 15:23:30 -0500 | [diff] [blame] | 84 | std::map<std::string, std::unique_ptr<Activation>> activations; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 85 | |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 86 | /** @brief Persistent map of Version dbus objects and their |
| 87 | * version id */ |
| 88 | std::map<std::string, std::unique_ptr<Version>> versions; |
| 89 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 90 | /** @brief sdbusplus signal match for Software.Version */ |
Patrick Williams | 3accb32 | 2017-05-30 16:29:52 -0500 | [diff] [blame] | 91 | sdbusplus::bus::match_t versionMatch; |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 92 | |
| 93 | /** @brief Host factory reset - clears PNOR partitions for each |
| 94 | * Activation dbus object */ |
| 95 | void reset() override; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 96 | }; |
| 97 | |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 98 | } // namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 99 | } // namespace software |
| 100 | } // namespace openpower |