blob: 4f2b206482404bd04fc6265cf4cd6e3dfd527bef [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>
Andrew Geissler9155b712020-05-16 13:04:44 -05005#include <string>
Gunnar Millsb0ce9962018-09-07 13:39:10 -05006
Gunnar Millse91d3212017-04-19 15:42:47 -05007namespace phosphor
8{
9namespace software
10{
11namespace manager
12{
13
Gunnar Mills3027bba2017-04-27 15:49:03 -050014/** @class Manager
15 * @brief Contains a map of Version dbus objects.
16 * @details The software image manager class that contains the Version dbus
17 * objects and their version ids.
Gunnar Millse91d3212017-04-19 15:42:47 -050018 */
Gunnar Mills3027bba2017-04-27 15:49:03 -050019class Manager
20{
Adriana Kobylak2285fe02018-02-27 15:36:59 -060021 public:
22 /** @brief Constructs Manager Class
23 *
24 * @param[in] bus - The Dbus bus object
25 */
26 Manager(sdbusplus::bus::bus& bus) : bus(bus){};
Gunnar Millse91d3212017-04-19 15:42:47 -050027
Adriana Kobylak2285fe02018-02-27 15:36:59 -060028 /**
29 * @brief Verify and untar the tarball. Verify the manifest file.
30 * Create and populate the version and filepath interfaces.
31 *
32 * @param[in] tarballFilePath - Tarball path.
33 * @param[out] result - 0 if successful.
34 */
35 int processImage(const std::string& tarballFilePath);
Gunnar Mills3027bba2017-04-27 15:49:03 -050036
Adriana Kobylak2285fe02018-02-27 15:36:59 -060037 /**
38 * @brief Erase specified entry d-bus object
39 * and deletes the image file.
40 *
41 * @param[in] entryId - unique identifier of the entry
42 */
43 void erase(std::string entryId);
Leonel Gonzalez50d559c2017-07-07 14:38:25 -050044
Adriana Kobylak2285fe02018-02-27 15:36:59 -060045 private:
46 /** @brief Persistent map of Version dbus objects and their
47 * version id */
48 std::map<std::string, std::unique_ptr<Version>> versions;
Gunnar Mills3027bba2017-04-27 15:49:03 -050049
Adriana Kobylak2285fe02018-02-27 15:36:59 -060050 /** @brief Persistent sdbusplus DBus bus connection. */
51 sdbusplus::bus::bus& bus;
Gunnar Mills3027bba2017-04-27 15:49:03 -050052
Adriana Kobylak2285fe02018-02-27 15:36:59 -060053 /**
54 * @brief Untar the tarball.
55 *
56 * @param[in] tarballFilePath - Tarball path.
57 * @param[in] extractDirPath - Dir path to extract tarball ball to.
58 * @param[out] result - 0 if successful.
59 */
60 static int unTar(const std::string& tarballFilePath,
61 const std::string& extractDirPath);
Gunnar Mills3027bba2017-04-27 15:49:03 -050062};
Gunnar Mills19e4ce52017-04-27 11:24:19 -050063
Gunnar Millse91d3212017-04-19 15:42:47 -050064} // namespace manager
65} // namespace software
66} // namespace phosphor