blob: b0b8b891c8a1501132b4a5cb6f331c88d5844764 [file] [log] [blame]
Gunnar Millse91d3212017-04-19 15:42:47 -05001#pragma once
Gunnar Mills3027bba2017-04-27 15:49:03 -05002#include "version.hpp"
Gunnar Millse91d3212017-04-19 15:42:47 -05003
4namespace phosphor
5{
6namespace software
7{
8namespace manager
9{
10
Gunnar Mills3027bba2017-04-27 15:49:03 -050011/** @class Manager
12 * @brief Contains a map of Version dbus objects.
13 * @details The software image manager class that contains the Version dbus
14 * objects and their version ids.
Gunnar Millse91d3212017-04-19 15:42:47 -050015 */
Gunnar Mills3027bba2017-04-27 15:49:03 -050016class Manager
17{
18 public:
19 /** @brief Constructs Manager Class
20 *
21 * @param[in] bus - The Dbus bus object
22 */
Saqib Khanba239882017-05-26 08:41:54 -050023 Manager(sdbusplus::bus::bus& bus) : bus(bus){};
Gunnar Millse91d3212017-04-19 15:42:47 -050024
Gunnar Mills3027bba2017-04-27 15:49:03 -050025 /**
26 * @brief Verify and untar the tarball. Verify the manifest file.
27 * Create and populate the version and filepath interfaces.
28 *
29 * @param[in] tarballFilePath - Tarball path.
30 * @param[out] result - 0 if successful.
31 */
32 int processImage(const std::string& tarballFilePath);
33
Leonel Gonzalez50d559c2017-07-07 14:38:25 -050034 /**
35 * @brief Erase specified entry d-bus object
36 * and deletes the image file.
37 *
38 * @param[in] entryId - unique identifier of the entry
39 */
40 void erase(std::string entryId);
41
Gunnar Mills3027bba2017-04-27 15:49:03 -050042 private:
43 /** @brief Persistent map of Version dbus objects and their
44 * version id */
45 std::map<std::string, std::unique_ptr<Version>> versions;
46
47 /** @brief Persistent sdbusplus DBus bus connection. */
48 sdbusplus::bus::bus& bus;
49
50 /**
51 * @brief Untar the tarball.
52 *
53 * @param[in] tarballFilePath - Tarball path.
54 * @param[in] extractDirPath - Dir path to extract tarball ball to.
55 * @param[out] result - 0 if successful.
56 */
57 static int unTar(const std::string& tarballFilePath,
58 const std::string& extractDirPath);
Gunnar Mills3027bba2017-04-27 15:49:03 -050059};
Gunnar Mills19e4ce52017-04-27 11:24:19 -050060
Gunnar Millse91d3212017-04-19 15:42:47 -050061} // namespace manager
62} // namespace software
63} // namespace phosphor