1 #pragma once 2 #include "version.hpp" 3 4 #include <sdbusplus/server.hpp> 5 6 #include <string> 7 8 namespace phosphor 9 { 10 namespace software 11 { 12 namespace manager 13 { 14 15 /** @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. 19 */ 20 class Manager 21 { 22 public: 23 /** @brief Constructs Manager Class 24 * 25 * @param[in] bus - The Dbus bus object 26 */ 27 Manager(sdbusplus::bus::bus& bus) : bus(bus){}; 28 29 /** 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); 37 38 /** 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); 45 46 private: 47 /** @brief Persistent map of Version dbus objects and their 48 * version id */ 49 std::map<std::string, std::unique_ptr<Version>> versions; 50 51 /** @brief Persistent sdbusplus DBus bus connection. */ 52 sdbusplus::bus::bus& bus; 53 54 /** 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); 63 }; 64 65 } // namespace manager 66 } // namespace software 67 } // namespace phosphor 68