Dhruvaraj Subhashchandran | 860b8a3 | 2021-05-05 13:01:49 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "dump_entry.hpp" |
| 4 | #include "xyz/openbmc_project/Common/FilePath/server.hpp" |
| 5 | |
| 6 | #include <sdbusplus/bus.hpp> |
| 7 | #include <sdbusplus/server/object.hpp> |
| 8 | |
| 9 | #include <filesystem> |
| 10 | |
| 11 | namespace phosphor |
| 12 | { |
| 13 | namespace dump |
| 14 | { |
| 15 | namespace bmc_stored |
| 16 | { |
| 17 | |
| 18 | template <typename T> |
| 19 | using ServerObject = typename sdbusplus::server::object_t<T>; |
| 20 | using FileIfaces = sdbusplus::server::object_t< |
| 21 | sdbusplus::xyz::openbmc_project::Common::server::FilePath>; |
| 22 | |
| 23 | class Manager; |
| 24 | |
| 25 | /** @class Entry |
| 26 | * @brief Entry sase class for all dumps get stored on BMC. |
| 27 | * @details A concrete implementation for the |
| 28 | * xyz.openbmc_project.Dump.Entry DBus API |
| 29 | */ |
| 30 | class Entry : public phosphor::dump::Entry, public FileIfaces |
| 31 | { |
| 32 | public: |
| 33 | Entry() = delete; |
| 34 | Entry(const Entry&) = delete; |
| 35 | Entry& operator=(const Entry&) = delete; |
| 36 | Entry(Entry&&) = delete; |
| 37 | Entry& operator=(Entry&&) = delete; |
| 38 | ~Entry() = default; |
| 39 | |
| 40 | /** @brief Constructor for the Dump Entry Object |
| 41 | * @param[in] bus - Bus to attach to. |
| 42 | * @param[in] objPath - Object path to attach to |
| 43 | * @param[in] dumpId - Dump id. |
| 44 | * @param[in] timeStamp - Dump creation timestamp |
| 45 | * since the epoch. |
| 46 | * @param[in] fileSize - Dump file size in bytes. |
| 47 | * @param[in] file - Name of dump file. |
| 48 | * @param[in] status - status of the dump. |
| 49 | * @param[in] originId - Id of the originator of the dump |
| 50 | * @param[in] originType - Originator type |
| 51 | * @param[in] parent - The dump entry's parent. |
| 52 | */ |
| 53 | Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId, |
| 54 | uint64_t timeStamp, uint64_t fileSize, |
| 55 | const std::filesystem::path& file, |
| 56 | phosphor::dump::OperationStatus status, std::string originId, |
| 57 | originatorTypes originType, phosphor::dump::Manager& parent) : |
| 58 | phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, fileSize, |
| 59 | status, originId, originType, parent), |
| 60 | FileIfaces(bus, objPath.c_str()) |
| 61 | { |
| 62 | path(file); |
| 63 | } |
| 64 | |
| 65 | /** @brief Delete this d-bus object. |
| 66 | */ |
| 67 | void delete_() override; |
| 68 | |
| 69 | /** @brief Method to initiate the offload of dump |
| 70 | * @param[in] uri - URI to offload dump |
| 71 | */ |
| 72 | void initiateOffload(std::string uri) override; |
| 73 | |
| 74 | /** @brief Method to update an existing dump entry, once the dump creation |
| 75 | * is completed this function will be used to update the entry which got |
| 76 | * created during the dump request. |
| 77 | * @param[in] timeStamp - Dump creation timestamp |
| 78 | * @param[in] fileSize - Dump file size in bytes. |
| 79 | * @param[in] file - Name of dump file. |
| 80 | */ |
| 81 | void update(uint64_t timeStamp, uint64_t fileSize, |
| 82 | const std::filesystem::path& filePath) |
| 83 | { |
| 84 | elapsed(timeStamp); |
| 85 | size(fileSize); |
| 86 | // TODO: Handled dump failed case with #ibm-openbmc/2808 |
| 87 | status(OperationStatus::Completed); |
| 88 | path(filePath); |
| 89 | // TODO: serialization of this property will be handled with |
| 90 | // #ibm-openbmc/2597 |
| 91 | completedTime(timeStamp); |
| 92 | } |
| 93 | |
| 94 | protected: |
| 95 | /** @Dump file name */ |
| 96 | std::filesystem::path file; |
| 97 | }; |
| 98 | |
| 99 | } // namespace bmc_stored |
| 100 | } // namespace dump |
| 101 | } // namespace phosphor |