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> |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 6 | |
| 7 | namespace openpower |
| 8 | { |
| 9 | namespace software |
| 10 | { |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 11 | namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 12 | { |
| 13 | |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 14 | using ItemUpdaterInherit = sdbusplus::server::object::object< |
| 15 | sdbusplus::xyz::openbmc_project::Common::server::FactoryReset>; |
Patrick Williams | 3accb32 | 2017-05-30 16:29:52 -0500 | [diff] [blame] | 16 | namespace MatchRules = sdbusplus::bus::match::rules; |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 17 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 18 | /** @class ItemUpdater |
| 19 | * @brief Manages the activation of the version items. |
| 20 | */ |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 21 | class ItemUpdater : public ItemUpdaterInherit |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 22 | { |
| 23 | public: |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 24 | /** @brief Constructs ItemUpdater |
| 25 | * |
| 26 | * @param[in] bus - The Dbus bus object |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 27 | * @param[in] path - The Dbus path |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 28 | */ |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 29 | ItemUpdater(sdbusplus::bus::bus& bus, const std::string& path) : |
| 30 | ItemUpdaterInherit(bus, path.c_str()), |
Adriana Kobylak | d6a549e | 2017-05-10 16:23:01 -0500 | [diff] [blame] | 31 | bus(bus), |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 32 | versionMatch( |
| 33 | bus, |
Patrick Williams | 3accb32 | 2017-05-30 16:29:52 -0500 | [diff] [blame] | 34 | MatchRules::interfacesAdded() + |
| 35 | MatchRules::path("/xyz/openbmc_project/software"), |
| 36 | std::bind( |
| 37 | std::mem_fn(&ItemUpdater::createActivation), |
| 38 | this, |
| 39 | std::placeholders::_1)) |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 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 |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 48 | */ |
Patrick Williams | 3accb32 | 2017-05-30 16:29:52 -0500 | [diff] [blame] | 49 | void createActivation(sdbusplus::message::message& msg); |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 50 | |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 51 | /** |
| 52 | * @brief Get the extended version from the specified file. |
| 53 | * |
| 54 | * @param[in] manifestFilePath - File to read. |
| 55 | * |
| 56 | * @return The extended version. |
| 57 | */ |
| 58 | static std::string getExtendedVersion(const std::string& |
| 59 | manifestFilePath); |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 60 | /** |
| 61 | * @brief Validates the presence of SquashFS iamge in the image dir. |
| 62 | * |
Adriana Kobylak | 5ba6b10 | 2017-05-19 09:41:27 -0500 | [diff] [blame^] | 63 | * @param[in] filePath - The path to the SquashfFS image. |
Saqib Khan | a8ade7e | 2017-04-12 10:27:56 -0500 | [diff] [blame] | 64 | * @param[out] result - 0 --> if validation was successful |
| 65 | * - -1--> Otherwise |
| 66 | */ |
Adriana Kobylak | 5ba6b10 | 2017-05-19 09:41:27 -0500 | [diff] [blame^] | 67 | static int validateSquashFSImage(const std::string& filePath); |
Saqib Khan | 7254f0e | 2017-04-10 21:45:37 -0500 | [diff] [blame] | 68 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 69 | /** @brief Persistent sdbusplus DBus bus connection. */ |
Adriana Kobylak | d6a549e | 2017-05-10 16:23:01 -0500 | [diff] [blame] | 70 | sdbusplus::bus::bus& bus; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 71 | |
| 72 | /** @brief Persistent map of Activation dbus objects and their |
| 73 | * version id */ |
Adriana Kobylak | 268616b | 2017-04-05 15:23:30 -0500 | [diff] [blame] | 74 | std::map<std::string, std::unique_ptr<Activation>> activations; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 75 | |
| 76 | /** @brief sdbusplus signal match for Software.Version */ |
Patrick Williams | 3accb32 | 2017-05-30 16:29:52 -0500 | [diff] [blame] | 77 | sdbusplus::bus::match_t versionMatch; |
Michael Tritz | dd961b6 | 2017-05-17 14:07:03 -0500 | [diff] [blame] | 78 | |
| 79 | /** @brief Host factory reset - clears PNOR partitions for each |
| 80 | * Activation dbus object */ |
| 81 | void reset() override; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 82 | }; |
| 83 | |
Adriana Kobylak | befe5ce | 2017-04-05 15:57:44 -0500 | [diff] [blame] | 84 | } // namespace updater |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 85 | } // namespace software |
| 86 | } // namespace openpower |