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