Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include "xyz/openbmc_project/Software/Version/server.hpp" |
| 5 | #include "xyz/openbmc_project/Common/FilePath/server.hpp" |
| 6 | |
| 7 | namespace openpower |
| 8 | { |
| 9 | namespace software |
| 10 | { |
| 11 | namespace updater |
| 12 | { |
| 13 | |
Leonel Gonzalez | 9c8adfa | 2017-07-12 11:08:40 -0500 | [diff] [blame] | 14 | class ItemUpdater; |
| 15 | |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 16 | using VersionInherit = sdbusplus::server::object::object< |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 17 | sdbusplus::xyz::openbmc_project::Software::server::Version, |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 18 | sdbusplus::xyz::openbmc_project::Common::server::FilePath>; |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 19 | |
| 20 | /** @class Version |
| 21 | * @brief OpenBMC version software management implementation. |
| 22 | * @details A concrete implementation for xyz.openbmc_project.Software.Version |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 23 | * D-Bus API. |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 24 | */ |
| 25 | class Version : public VersionInherit |
| 26 | { |
| 27 | public: |
| 28 | /** @brief Constructs Version Software Manager. |
| 29 | * |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 30 | * @param[in] bus - The D-Bus bus object |
| 31 | * @param[in] objPath - The D-Bus object path |
| 32 | * @param[in] versionString - The version string |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 33 | * @param[in] versionPurpose - The version purpose |
| 34 | * @param[in] filePath - The image filesystem path |
| 35 | */ |
| 36 | Version(sdbusplus::bus::bus& bus, |
| 37 | const std::string& objPath, |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 38 | const std::string& versionString, |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 39 | VersionPurpose versionPurpose, |
Eddie James | fa5daf4 | 2017-09-01 11:51:28 -0500 | [diff] [blame] | 40 | const std::string& filePath) : |
| 41 | VersionInherit(bus, (objPath).c_str(), true) |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 42 | { |
| 43 | // Set properties. |
| 44 | purpose(versionPurpose); |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 45 | version(versionString); |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 46 | path(filePath); |
| 47 | |
| 48 | // Emit deferred signal. |
| 49 | emit_object_added(); |
| 50 | } |
Saqib Khan | 167601b | 2017-06-18 23:33:46 -0500 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * @brief Read the manifest file to get the value of the key. |
| 54 | * |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 55 | * @param[in] filePath - The path to the file which contains the value |
Saqib Khan | 167601b | 2017-06-18 23:33:46 -0500 | [diff] [blame] | 56 | * of keys. |
| 57 | * @param[in] keys - A map of keys with empty values. |
| 58 | * |
| 59 | * @return The map of keys with filled values. |
| 60 | **/ |
| 61 | static std::map<std::string, std::string> getValue( |
| 62 | const std::string& filePath, |
| 63 | std::map<std::string, std::string> keys); |
| 64 | |
| 65 | /** |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 66 | * @brief Calculate the version id from the version string. |
Saqib Khan | 167601b | 2017-06-18 23:33:46 -0500 | [diff] [blame] | 67 | * |
Gunnar Mills | b78dfa5 | 2017-09-21 16:05:22 -0500 | [diff] [blame] | 68 | * @details The version id is a unique 8 hexadecimal digit id |
| 69 | * calculated from the version string. |
| 70 | * |
| 71 | * @param[in] version - The image version string (e.g. v1.99.10-19). |
Saqib Khan | 167601b | 2017-06-18 23:33:46 -0500 | [diff] [blame] | 72 | * |
| 73 | * @return The id. |
| 74 | */ |
| 75 | static std::string getId(const std::string& version); |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace updater |
| 79 | } // namespace software |
| 80 | } // namespace openpower |