blob: 507d4d0f7176842d08bb07829e229c443ff921b2 [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"
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -05005#include "xyz/openbmc_project/Object/Delete/server.hpp"
Saqib Khance148702017-06-11 12:01:58 -05006#include "xyz/openbmc_project/Common/FilePath/server.hpp"
7
8namespace openpower
9{
10namespace software
11{
12namespace updater
13{
14
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -050015class ItemUpdater;
16
Saqib Khance148702017-06-11 12:01:58 -050017using VersionInherit = sdbusplus::server::object::object<
18 sdbusplus::xyz::openbmc_project::Software::server::Version,
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -050019 sdbusplus::xyz::openbmc_project::Object::server::Delete,
Saqib Khance148702017-06-11 12:01:58 -050020 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
21
22/** @class Version
23 * @brief OpenBMC version software management implementation.
24 * @details A concrete implementation for xyz.openbmc_project.Software.Version
25 * DBus API.
26 */
27class Version : public VersionInherit
28{
29 public:
30 /** @brief Constructs Version Software Manager.
31 *
32 * @param[in] bus - The Dbus bus object
33 * @param[in] objPath - The Dbus object path
34 * @param[in] versionId - The version identifier
35 * @param[in] versionPurpose - The version purpose
36 * @param[in] filePath - The image filesystem path
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -050037 * @param[in] parent - The version's parent
Saqib Khance148702017-06-11 12:01:58 -050038 */
39 Version(sdbusplus::bus::bus& bus,
40 const std::string& objPath,
41 const std::string& versionId,
42 VersionPurpose versionPurpose,
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -050043 const std::string& filePath,
44 ItemUpdater& parent) : VersionInherit(
45 bus, (objPath).c_str(), true),
46 parent(parent)
Saqib Khance148702017-06-11 12:01:58 -050047 {
48 // Set properties.
49 purpose(versionPurpose);
50 version(versionId);
51 path(filePath);
52
53 // Emit deferred signal.
54 emit_object_added();
55 }
Saqib Khan167601b2017-06-18 23:33:46 -050056
57 /**
58 * @brief Read the manifest file to get the value of the key.
59 *
60 * @param[in] filePath - The path to file which contains the value
61 * of keys.
62 * @param[in] keys - A map of keys with empty values.
63 *
64 * @return The map of keys with filled values.
65 **/
66 static std::map<std::string, std::string> getValue(
67 const std::string& filePath,
68 std::map<std::string, std::string> keys);
69
70 /**
71 * @brief Get the Version id.
72 *
73 * @param[in] version - The image version.
74 *
75 * @return The id.
76 */
77 static std::string getId(const std::string& version);
Leonel Gonzalez9c8adfa2017-07-12 11:08:40 -050078
79 /** @brief Deletes the d-bus object and removes image.
80 *
81 */
82 void delete_() override;
83
84 private:
85 ItemUpdater& parent;
86
Saqib Khance148702017-06-11 12:01:58 -050087};
88
89} // namespace updater
90} // namespace software
91} // namespace openpower