blob: 8cb7e371dc89c9306a3162a19f706b8eb95a29a3 [file] [log] [blame]
Saqib Khance148702017-06-11 12:01:58 -05001#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
7namespace openpower
8{
9namespace software
10{
11namespace updater
12{
13
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -050014class ItemUpdater;
15
Saqib Khance148702017-06-11 12:01:58 -050016using VersionInherit = sdbusplus::server::object::object<
Gunnar Millsb78dfa52017-09-21 16:05:22 -050017 sdbusplus::xyz::openbmc_project::Software::server::Version,
Gunnar Millsb78dfa52017-09-21 16:05:22 -050018 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
Saqib Khance148702017-06-11 12:01:58 -050019
20/** @class Version
21 * @brief OpenBMC version software management implementation.
22 * @details A concrete implementation for xyz.openbmc_project.Software.Version
Gunnar Millsb78dfa52017-09-21 16:05:22 -050023 * D-Bus API.
Saqib Khance148702017-06-11 12:01:58 -050024 */
25class Version : public VersionInherit
26{
27 public:
28 /** @brief Constructs Version Software Manager.
29 *
Gunnar Millsb78dfa52017-09-21 16:05:22 -050030 * @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 Khance148702017-06-11 12:01:58 -050033 * @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 Millsb78dfa52017-09-21 16:05:22 -050038 const std::string& versionString,
Saqib Khance148702017-06-11 12:01:58 -050039 VersionPurpose versionPurpose,
Eddie Jamesfa5daf42017-09-01 11:51:28 -050040 const std::string& filePath) :
41 VersionInherit(bus, (objPath).c_str(), true)
Saqib Khance148702017-06-11 12:01:58 -050042 {
43 // Set properties.
44 purpose(versionPurpose);
Gunnar Millsb78dfa52017-09-21 16:05:22 -050045 version(versionString);
Saqib Khance148702017-06-11 12:01:58 -050046 path(filePath);
47
48 // Emit deferred signal.
49 emit_object_added();
50 }
Saqib Khan167601b2017-06-18 23:33:46 -050051
52 /**
53 * @brief Read the manifest file to get the value of the key.
54 *
Gunnar Millsb78dfa52017-09-21 16:05:22 -050055 * @param[in] filePath - The path to the file which contains the value
Saqib Khan167601b2017-06-18 23:33:46 -050056 * 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 Millsb78dfa52017-09-21 16:05:22 -050066 * @brief Calculate the version id from the version string.
Saqib Khan167601b2017-06-18 23:33:46 -050067 *
Gunnar Millsb78dfa52017-09-21 16:05:22 -050068 * @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 Khan167601b2017-06-18 23:33:46 -050072 *
73 * @return The id.
74 */
75 static std::string getId(const std::string& version);
Saqib Khance148702017-06-11 12:01:58 -050076};
77
78} // namespace updater
79} // namespace software
80} // namespace openpower