Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 3 | #include "xyz/openbmc_project/Dump/Entry/server.hpp" |
| 4 | #include "xyz/openbmc_project/Object/Delete/server.hpp" |
| 5 | #include "xyz/openbmc_project/Time/EpochTime/server.hpp" |
| 6 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 7 | #include <experimental/filesystem> |
| 8 | #include <sdbusplus/bus.hpp> |
| 9 | #include <sdbusplus/server/object.hpp> |
| 10 | |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 11 | namespace phosphor |
| 12 | { |
| 13 | namespace dump |
| 14 | { |
| 15 | |
| 16 | template <typename T> |
| 17 | using ServerObject = typename sdbusplus::server::object::object<T>; |
| 18 | |
| 19 | using EntryIfaces = sdbusplus::server::object::object< |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 20 | sdbusplus::xyz::openbmc_project::Dump::server::Entry, |
| 21 | sdbusplus::xyz::openbmc_project::Object::server::Delete, |
| 22 | sdbusplus::xyz::openbmc_project::Time::server::EpochTime>; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 23 | |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 24 | namespace fs = std::experimental::filesystem; |
| 25 | |
| 26 | class Manager; |
| 27 | |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 28 | /** @class Entry |
Dhruvaraj Subhashchandran | f140f66 | 2020-01-30 00:29:01 -0600 | [diff] [blame] | 29 | * @brief Base Dump Entry implementation. |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 30 | * @details A concrete implementation for the |
| 31 | * xyz.openbmc_project.Dump.Entry DBus API |
| 32 | */ |
| 33 | class Entry : public EntryIfaces |
| 34 | { |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 35 | public: |
| 36 | Entry() = delete; |
| 37 | Entry(const Entry&) = delete; |
| 38 | Entry& operator=(const Entry&) = delete; |
| 39 | Entry(Entry&&) = delete; |
| 40 | Entry& operator=(Entry&&) = delete; |
| 41 | ~Entry() = default; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 42 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 43 | /** @brief Constructor for the Dump Entry Object |
| 44 | * @param[in] bus - Bus to attach to. |
| 45 | * @param[in] objPath - Object path to attach to |
| 46 | * @param[in] dumpId - Dump id. |
| 47 | * @param[in] timeStamp - Dump creation timestamp |
| 48 | * since the epoch. |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 49 | * @param[in] dumpSize - Dump file size in bytes. |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 50 | * @param[in] parent - The dump entry's parent. |
| 51 | */ |
| 52 | Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId, |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 53 | uint64_t timeStamp, uint64_t dumpSize, Manager& parent) : |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 54 | EntryIfaces(bus, objPath.c_str(), true), |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 55 | parent(parent), id(dumpId) |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 56 | { |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 57 | size(dumpSize); |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 58 | elapsed(timeStamp); |
| 59 | // Emit deferred signal. |
| 60 | this->emit_object_added(); |
| 61 | }; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 62 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 63 | /** @brief Delete this d-bus object. |
| 64 | */ |
| 65 | void delete_() override; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 66 | |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 67 | /** @brief Method to initiate the offload of dump |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 68 | * @param[in] uri - URI to offload dump |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 69 | */ |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 70 | void initiateOffload(std::string uri) override |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 71 | { |
Dhruvaraj Subhashchandran | 69e6152 | 2020-02-04 06:39:11 -0600 | [diff] [blame] | 72 | offloadUri(uri); |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 73 | } |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 74 | |
Dhruvaraj Subhashchandran | 4a98e8f | 2020-01-29 07:11:08 -0600 | [diff] [blame] | 75 | protected: |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 76 | /** @brief This entry's parent */ |
| 77 | Manager& parent; |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 78 | |
Jayanth Othayoth | cb65ffc | 2018-10-16 08:29:32 -0500 | [diff] [blame] | 79 | /** @brief This entry's id */ |
| 80 | uint32_t id; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace dump |
| 84 | } // namespace phosphor |