Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 1 | #pragma once |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 2 | #include "version.hpp" |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 3 | |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 4 | #include <sdbusplus/server.hpp> |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 5 | |
Adriana Kobylak | 59b640b | 2022-01-21 19:45:22 +0000 | [diff] [blame] | 6 | #include <chrono> |
| 7 | #include <random> |
Andrew Geissler | 9155b71 | 2020-05-16 13:04:44 -0500 | [diff] [blame] | 8 | #include <string> |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 9 | |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 10 | namespace phosphor |
| 11 | { |
| 12 | namespace software |
| 13 | { |
| 14 | namespace manager |
| 15 | { |
| 16 | |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 17 | /** @class Manager |
| 18 | * @brief Contains a map of Version dbus objects. |
| 19 | * @details The software image manager class that contains the Version dbus |
| 20 | * objects and their version ids. |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 21 | */ |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 22 | class Manager |
| 23 | { |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 24 | public: |
| 25 | /** @brief Constructs Manager Class |
| 26 | * |
| 27 | * @param[in] bus - The Dbus bus object |
| 28 | */ |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 29 | explicit Manager(sdbusplus::bus_t& bus) : bus(bus){}; |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 30 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 31 | /** |
| 32 | * @brief Verify and untar the tarball. Verify the manifest file. |
| 33 | * Create and populate the version and filepath interfaces. |
| 34 | * |
| 35 | * @param[in] tarballFilePath - Tarball path. |
| 36 | * @param[out] result - 0 if successful. |
| 37 | */ |
| 38 | int processImage(const std::string& tarballFilePath); |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 39 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 40 | /** |
| 41 | * @brief Erase specified entry d-bus object |
| 42 | * and deletes the image file. |
| 43 | * |
| 44 | * @param[in] entryId - unique identifier of the entry |
| 45 | */ |
Pavithra Barithaya | 6d17852 | 2024-06-24 04:17:29 -0500 | [diff] [blame] | 46 | void erase(const std::string& entryId); |
Leonel Gonzalez | 50d559c | 2017-07-07 14:38:25 -0500 | [diff] [blame] | 47 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 48 | private: |
| 49 | /** @brief Persistent map of Version dbus objects and their |
| 50 | * version id */ |
| 51 | std::map<std::string, std::unique_ptr<Version>> versions; |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 52 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 53 | /** @brief Persistent sdbusplus DBus bus connection. */ |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 54 | sdbusplus::bus_t& bus; |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 55 | |
Adriana Kobylak | 59b640b | 2022-01-21 19:45:22 +0000 | [diff] [blame] | 56 | /** @brief The random generator to get the version salt */ |
| 57 | std::mt19937 randomGen{static_cast<unsigned>( |
| 58 | std::chrono::system_clock::now().time_since_epoch().count())}; |
| 59 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 60 | /** |
| 61 | * @brief Untar the tarball. |
| 62 | * |
| 63 | * @param[in] tarballFilePath - Tarball path. |
| 64 | * @param[in] extractDirPath - Dir path to extract tarball ball to. |
| 65 | * @param[out] result - 0 if successful. |
| 66 | */ |
| 67 | static int unTar(const std::string& tarballFilePath, |
| 68 | const std::string& extractDirPath); |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 69 | }; |
Gunnar Mills | 19e4ce5 | 2017-04-27 11:24:19 -0500 | [diff] [blame] | 70 | |
Gunnar Mills | e91d321 | 2017-04-19 15:42:47 -0500 | [diff] [blame] | 71 | } // namespace manager |
| 72 | } // namespace software |
| 73 | } // namespace phosphor |