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