blob: 8498c777f2aabacbd5db70c5cdd1d9c70e0bb078 [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
Gunnar Millsb0ce9962018-09-07 13:39:10 -05004#include <sdbusplus/server.hpp>
5
Gunnar Millse91d3212017-04-19 15:42:47 -05006namespace phosphor
7{
8namespace software
9{
10namespace manager
11{
12
Gunnar Mills3027bba2017-04-27 15:49:03 -050013/** @class Manager
14 * @brief Contains a map of Version dbus objects.
15 * @details The software image manager class that contains the Version dbus
16 * objects and their version ids.
Gunnar Millse91d3212017-04-19 15:42:47 -050017 */
Gunnar Mills3027bba2017-04-27 15:49:03 -050018class Manager
19{
Adriana Kobylak2285fe02018-02-27 15:36:59 -060020 public:
21 /** @brief Constructs Manager Class
22 *
23 * @param[in] bus - The Dbus bus object
24 */
25 Manager(sdbusplus::bus::bus& bus) : bus(bus){};
Gunnar Millse91d3212017-04-19 15:42:47 -050026
Adriana Kobylak2285fe02018-02-27 15:36:59 -060027 /**
28 * @brief Verify and untar the tarball. Verify the manifest file.
29 * Create and populate the version and filepath interfaces.
30 *
31 * @param[in] tarballFilePath - Tarball path.
32 * @param[out] result - 0 if successful.
33 */
34 int processImage(const std::string& tarballFilePath);
Gunnar Mills3027bba2017-04-27 15:49:03 -050035
Adriana Kobylak2285fe02018-02-27 15:36:59 -060036 /**
37 * @brief Erase specified entry d-bus object
38 * and deletes the image file.
39 *
40 * @param[in] entryId - unique identifier of the entry
41 */
42 void erase(std::string entryId);
Leonel Gonzalez50d559c2017-07-07 14:38:25 -050043
Adriana Kobylak2285fe02018-02-27 15:36:59 -060044 private:
45 /** @brief Persistent map of Version dbus objects and their
46 * version id */
47 std::map<std::string, std::unique_ptr<Version>> versions;
Gunnar Mills3027bba2017-04-27 15:49:03 -050048
Adriana Kobylak2285fe02018-02-27 15:36:59 -060049 /** @brief Persistent sdbusplus DBus bus connection. */
50 sdbusplus::bus::bus& bus;
Gunnar Mills3027bba2017-04-27 15:49:03 -050051
Adriana Kobylak2285fe02018-02-27 15:36:59 -060052 /**
53 * @brief Untar the tarball.
54 *
55 * @param[in] tarballFilePath - Tarball path.
56 * @param[in] extractDirPath - Dir path to extract tarball ball to.
57 * @param[out] result - 0 if successful.
58 */
59 static int unTar(const std::string& tarballFilePath,
60 const std::string& extractDirPath);
Gunnar Mills3027bba2017-04-27 15:49:03 -050061};
Gunnar Mills19e4ce52017-04-27 11:24:19 -050062
Gunnar Millse91d3212017-04-19 15:42:47 -050063} // namespace manager
64} // namespace software
65} // namespace phosphor