1 #pragma once 2 3 #include "xyz/openbmc_project/Common/Progress/server.hpp" 4 #include "xyz/openbmc_project/Dump/Entry/server.hpp" 5 #include "xyz/openbmc_project/Object/Delete/server.hpp" 6 #include "xyz/openbmc_project/Time/EpochTime/server.hpp" 7 8 #include <experimental/filesystem> 9 #include <sdbusplus/bus.hpp> 10 #include <sdbusplus/server/object.hpp> 11 12 namespace phosphor 13 { 14 namespace dump 15 { 16 17 template <typename T> 18 using ServerObject = typename sdbusplus::server::object::object<T>; 19 20 // TODO Revisit whether sdbusplus::xyz::openbmc_project::Time::server::EpochTime 21 // still needed in dump entry since start time and completed time are available 22 // from sdbusplus::xyz::openbmc_project::Common::server::Progress 23 // #ibm-openbmc/2809 24 using EntryIfaces = sdbusplus::server::object::object< 25 sdbusplus::xyz::openbmc_project::Common::server::Progress, 26 sdbusplus::xyz::openbmc_project::Dump::server::Entry, 27 sdbusplus::xyz::openbmc_project::Object::server::Delete, 28 sdbusplus::xyz::openbmc_project::Time::server::EpochTime>; 29 30 using OperationStatus = 31 sdbusplus::xyz::openbmc_project::Common::server::Progress::OperationStatus; 32 namespace fs = std::experimental::filesystem; 33 34 class Manager; 35 36 /** @class Entry 37 * @brief Base Dump Entry implementation. 38 * @details A concrete implementation for the 39 * xyz.openbmc_project.Dump.Entry DBus API 40 */ 41 class Entry : public EntryIfaces 42 { 43 public: 44 Entry() = delete; 45 Entry(const Entry&) = delete; 46 Entry& operator=(const Entry&) = delete; 47 Entry(Entry&&) = delete; 48 Entry& operator=(Entry&&) = delete; 49 ~Entry() = default; 50 51 /** @brief Constructor for the Dump Entry Object 52 * @param[in] bus - Bus to attach to. 53 * @param[in] objPath - Object path to attach to 54 * @param[in] dumpId - Dump id. 55 * @param[in] timeStamp - Dump creation timestamp 56 * since the epoch. 57 * @param[in] dumpSize - Dump file size in bytes. 58 * @param[in] parent - The dump entry's parent. 59 */ 60 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId, 61 uint64_t timeStamp, uint64_t dumpSize, OperationStatus dumpStatus, 62 Manager& parent) : 63 EntryIfaces(bus, objPath.c_str(), true), 64 parent(parent), id(dumpId) 65 { 66 size(dumpSize); 67 status(dumpStatus); 68 69 // If the object is created after the dump creation keep 70 // all same as timeStamp 71 // if the object created before the dump creation, update 72 // only the start time. Completed and elapsed time will 73 // be updated once the dump is completed. 74 if (dumpStatus == OperationStatus::Completed) 75 { 76 elapsed(timeStamp); 77 startTime(timeStamp); 78 completedTime(timeStamp); 79 } 80 else 81 { 82 elapsed(0); 83 startTime(timeStamp); 84 completedTime(0); 85 } 86 // Emit deferred signal. 87 this->emit_object_added(); 88 }; 89 90 /** @brief Delete this d-bus object. 91 */ 92 void delete_() override; 93 94 /** @brief Method to initiate the offload of dump 95 * @param[in] uri - URI to offload dump 96 */ 97 void initiateOffload(std::string uri) override 98 { 99 offloadUri(uri); 100 } 101 102 protected: 103 /** @brief This entry's parent */ 104 Manager& parent; 105 106 /** @brief This entry's id */ 107 uint32_t id; 108 }; 109 110 } // namespace dump 111 } // namespace phosphor 112