blob: 6dc80cf47e7c6d883646b4ef3a735498d1e915e7 [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>
Adriana Kobylak58aa7502020-06-08 11:12:11 -05005
Andrew Geissler9155b712020-05-16 13:04:44 -05006#include <string>
Gunnar Millsb0ce9962018-09-07 13:39:10 -05007
Gunnar Millse91d3212017-04-19 15:42:47 -05008namespace phosphor
9{
10namespace software
11{
12namespace manager
13{
14
Gunnar Mills3027bba2017-04-27 15:49:03 -050015/** @class Manager
16 * @brief Contains a map of Version dbus objects.
17 * @details The software image manager class that contains the Version dbus
18 * objects and their version ids.
Gunnar Millse91d3212017-04-19 15:42:47 -050019 */
Gunnar Mills3027bba2017-04-27 15:49:03 -050020class Manager
21{
Adriana Kobylak2285fe02018-02-27 15:36:59 -060022 public:
23 /** @brief Constructs Manager Class
24 *
25 * @param[in] bus - The Dbus bus object
26 */
27 Manager(sdbusplus::bus::bus& bus) : bus(bus){};
Gunnar Millse91d3212017-04-19 15:42:47 -050028
Adriana Kobylak2285fe02018-02-27 15:36:59 -060029 /**
30 * @brief Verify and untar the tarball. Verify the manifest file.
31 * Create and populate the version and filepath interfaces.
32 *
33 * @param[in] tarballFilePath - Tarball path.
34 * @param[out] result - 0 if successful.
35 */
36 int processImage(const std::string& tarballFilePath);
Gunnar Mills3027bba2017-04-27 15:49:03 -050037
Adriana Kobylak2285fe02018-02-27 15:36:59 -060038 /**
39 * @brief Erase specified entry d-bus object
40 * and deletes the image file.
41 *
42 * @param[in] entryId - unique identifier of the entry
43 */
44 void erase(std::string entryId);
Leonel Gonzalez50d559c2017-07-07 14:38:25 -050045
Adriana Kobylak2285fe02018-02-27 15:36:59 -060046 private:
47 /** @brief Persistent map of Version dbus objects and their
48 * version id */
49 std::map<std::string, std::unique_ptr<Version>> versions;
Gunnar Mills3027bba2017-04-27 15:49:03 -050050
Adriana Kobylak2285fe02018-02-27 15:36:59 -060051 /** @brief Persistent sdbusplus DBus bus connection. */
52 sdbusplus::bus::bus& bus;
Gunnar Mills3027bba2017-04-27 15:49:03 -050053
Adriana Kobylak2285fe02018-02-27 15:36:59 -060054 /**
55 * @brief Untar the tarball.
56 *
57 * @param[in] tarballFilePath - Tarball path.
58 * @param[in] extractDirPath - Dir path to extract tarball ball to.
59 * @param[out] result - 0 if successful.
60 */
61 static int unTar(const std::string& tarballFilePath,
62 const std::string& extractDirPath);
Gunnar Mills3027bba2017-04-27 15:49:03 -050063};
Gunnar Mills19e4ce52017-04-27 11:24:19 -050064
Gunnar Millse91d3212017-04-19 15:42:47 -050065} // namespace manager
66} // namespace software
67} // namespace phosphor