blob: cf15157c426fd0801735260b114c3c89c11bb5ff [file] [log] [blame]
Jayanth Othayoth224882b2017-05-04 05:46:45 -05001#pragma once
2
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -05003#include "xyz/openbmc_project/Common/Progress/server.hpp"
Jayanth Othayoth224882b2017-05-04 05:46:45 -05004#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
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05008#include <sdbusplus/bus.hpp>
9#include <sdbusplus/server/object.hpp>
10
Jayanth Othayoth0af74a52021-04-08 03:55:21 -050011#include <filesystem>
12
Jayanth Othayoth224882b2017-05-04 05:46:45 -050013namespace phosphor
14{
15namespace dump
16{
17
18template <typename T>
Patrick Williams9b18bf22022-07-22 19:26:55 -050019using ServerObject = typename sdbusplus::server::object_t<T>;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050020
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050021// TODO Revisit whether sdbusplus::xyz::openbmc_project::Time::server::EpochTime
22// still needed in dump entry since start time and completed time are available
23// from sdbusplus::xyz::openbmc_project::Common::server::Progress
24// #ibm-openbmc/2809
Patrick Williams9b18bf22022-07-22 19:26:55 -050025using EntryIfaces = sdbusplus::server::object_t<
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050026 sdbusplus::xyz::openbmc_project::Common::server::Progress,
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050027 sdbusplus::xyz::openbmc_project::Dump::server::Entry,
28 sdbusplus::xyz::openbmc_project::Object::server::Delete,
29 sdbusplus::xyz::openbmc_project::Time::server::EpochTime>;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050030
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050031using OperationStatus =
32 sdbusplus::xyz::openbmc_project::Common::server::Progress::OperationStatus;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050033
34class Manager;
35
Jayanth Othayoth224882b2017-05-04 05:46:45 -050036/** @class Entry
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060037 * @brief Base Dump Entry implementation.
Jayanth Othayoth224882b2017-05-04 05:46:45 -050038 * @details A concrete implementation for the
39 * xyz.openbmc_project.Dump.Entry DBus API
40 */
41class Entry : public EntryIfaces
42{
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050043 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;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050050
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050051 /** @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.
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060057 * @param[in] dumpSize - Dump file size in bytes.
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050058 * @param[in] parent - The dump entry's parent.
59 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050060 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050061 uint64_t timeStamp, uint64_t dumpSize, OperationStatus dumpStatus,
62 Manager& parent) :
Patrick Williams73f64072022-04-01 17:04:47 -050063 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::emit_no_signals),
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060064 parent(parent), id(dumpId)
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050065 {
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060066 size(dumpSize);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050067 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 }
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050086 };
Jayanth Othayoth224882b2017-05-04 05:46:45 -050087
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050088 /** @brief Delete this d-bus object.
89 */
90 void delete_() override;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050091
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060092 /** @brief Method to initiate the offload of dump
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060093 * @param[in] uri - URI to offload dump
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060094 */
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060095 void initiateOffload(std::string uri) override
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060096 {
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060097 offloadUri(uri);
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060098 }
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050099
Dhruvaraj Subhashchandran270355b2022-02-01 02:44:43 -0600100 /** @brief Returns the dump id
101 * @return the id associated with entry
102 */
103 uint32_t getDumpId()
104 {
105 return id;
106 }
107
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -0600108 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -0500109 /** @brief This entry's parent */
110 Manager& parent;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -0500111
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -0500112 /** @brief This entry's id */
113 uint32_t id;
Jayanth Othayoth224882b2017-05-04 05:46:45 -0500114};
115
116} // namespace dump
117} // namespace phosphor