Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "com/ibm/Dump/Entry/Resource/server.hpp" |
| 4 | #include "dump_entry.hpp" |
| 5 | |
| 6 | #include <chrono> |
| 7 | #include <sdbusplus/bus.hpp> |
| 8 | #include <sdbusplus/server/object.hpp> |
| 9 | |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 10 | namespace openpower |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 11 | { |
| 12 | namespace dump |
| 13 | { |
| 14 | namespace resource |
| 15 | { |
| 16 | template <typename T> |
| 17 | using ServerObject = typename sdbusplus::server::object::object<T>; |
| 18 | |
| 19 | using EntryIfaces = sdbusplus::server::object::object< |
| 20 | sdbusplus::com::ibm::Dump::Entry::server::Resource>; |
| 21 | |
| 22 | namespace fs = std::experimental::filesystem; |
| 23 | |
| 24 | class Manager; |
| 25 | |
| 26 | /** @class Entry |
| 27 | * @brief Resource Dump Entry implementation. |
| 28 | * @details An extension to Dump::Entry class and |
| 29 | * A concrete implementation for the |
| 30 | * com::ibm::Dump::Entry::Resource DBus API |
| 31 | */ |
| 32 | class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry |
| 33 | { |
| 34 | public: |
| 35 | Entry() = delete; |
| 36 | Entry(const Entry&) = delete; |
| 37 | Entry& operator=(const Entry&) = delete; |
| 38 | Entry(Entry&&) = delete; |
| 39 | Entry& operator=(Entry&&) = delete; |
| 40 | ~Entry() = default; |
| 41 | |
| 42 | /** @brief Constructor for the resource dump Entry Object |
| 43 | * @param[in] bus - Bus to attach to. |
| 44 | * @param[in] objPath - Object path to attach to |
| 45 | * @param[in] dumpId - Dump id. |
| 46 | * @param[in] timeStamp - Dump creation timestamp |
| 47 | * since the epoch. |
| 48 | * @param[in] dumpSize - Dump size in bytes. |
| 49 | * @param[in] sourceId - DumpId provided by the source. |
| 50 | * @param[in] vspString - Input to host to generate the resource dump. |
| 51 | * @param[in] pwd - Password needed by host to validate the request. |
| 52 | * @param[in] status - status of the dump. |
| 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 dumpSize, const uint32_t sourceId, |
| 57 | std::string vspString, std::string pwd, |
| 58 | phosphor::dump::OperationStatus status, |
| 59 | phosphor::dump::Manager& parent) : |
| 60 | EntryIfaces(bus, objPath.c_str(), true), |
| 61 | phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize, |
| 62 | status, parent) |
| 63 | { |
| 64 | sourceDumpId(sourceId); |
| 65 | vSPString(vspString); |
| 66 | password(pwd); |
Dhruvaraj Subhashchandran | 2f8e276 | 2021-02-11 07:22:35 -0600 | [diff] [blame] | 67 | // Emit deferred signal. |
| 68 | this->openpower::dump::resource::EntryIfaces::emit_object_added(); |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | /** @brief Method to initiate the offload of dump |
| 72 | * @param[in] uri - URI to offload dump. |
| 73 | */ |
Dhruvaraj Subhashchandran | 2f8e276 | 2021-02-11 07:22:35 -0600 | [diff] [blame] | 74 | void initiateOffload(std::string uri) override; |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 75 | |
| 76 | /** @brief Method to update an existing dump entry |
| 77 | * @param[in] timeStamp - Dump creation timestamp |
| 78 | * @param[in] dumpSize - Dump size in bytes. |
| 79 | * @param[in] sourceId - The id of dump in the origin. |
| 80 | */ |
| 81 | void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId) |
| 82 | { |
| 83 | sourceDumpId(sourceId); |
| 84 | elapsed(timeStamp); |
| 85 | size(dumpSize); |
| 86 | // TODO: Handled dump failure case with |
| 87 | // #bm-openbmc/2808 |
| 88 | status(OperationStatus::Completed); |
| 89 | completedTime(timeStamp); |
| 90 | } |
Dhruvaraj Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 91 | |
| 92 | /** |
| 93 | * @brief Delete resource dump in host memory and the entry dbus object |
| 94 | */ |
| 95 | void delete_() override; |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | } // namespace resource |
| 99 | } // namespace dump |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 100 | } // namespace openpower |