blob: ccd82a03c8fb5d37d810b45d859a5bd9cdd2be77 [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{
Adriana Kobylak2285fe02018-02-27 15:36:59 -060019 public:
20 /** @brief Constructs Manager Class
21 *
22 * @param[in] bus - The Dbus bus object
23 */
24 Manager(sdbusplus::bus::bus& bus) : bus(bus){};
Gunnar Millse91d3212017-04-19 15:42:47 -050025
Adriana Kobylak2285fe02018-02-27 15:36:59 -060026 /**
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);
Gunnar Mills3027bba2017-04-27 15:49:03 -050034
Adriana Kobylak2285fe02018-02-27 15:36:59 -060035 /**
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);
Leonel Gonzalez50d559c2017-07-07 14:38:25 -050042
Adriana Kobylak2285fe02018-02-27 15:36:59 -060043 private:
44 /** @brief Persistent map of Version dbus objects and their
45 * version id */
46 std::map<std::string, std::unique_ptr<Version>> versions;
Gunnar Mills3027bba2017-04-27 15:49:03 -050047
Adriana Kobylak2285fe02018-02-27 15:36:59 -060048 /** @brief Persistent sdbusplus DBus bus connection. */
49 sdbusplus::bus::bus& bus;
Gunnar Mills3027bba2017-04-27 15:49:03 -050050
Adriana Kobylak2285fe02018-02-27 15:36:59 -060051 /**
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