blob: 9f4c2a6bd4cb8fda7ffa3dc57c161a669f577841 [file] [log] [blame]
Jayanth Othayoth224882b2017-05-04 05:46:45 -05001#pragma once
2
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -05003#include "xyz/openbmc_project/Common/OriginatedBy/server.hpp"
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -05004#include "xyz/openbmc_project/Common/Progress/server.hpp"
Jayanth Othayoth224882b2017-05-04 05:46:45 -05005#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
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05009#include <sdbusplus/bus.hpp>
10#include <sdbusplus/server/object.hpp>
11
Jayanth Othayoth0af74a52021-04-08 03:55:21 -050012#include <filesystem>
13
Jayanth Othayoth224882b2017-05-04 05:46:45 -050014namespace phosphor
15{
16namespace dump
17{
18
19template <typename T>
Patrick Williams9b18bf22022-07-22 19:26:55 -050020using ServerObject = typename sdbusplus::server::object_t<T>;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050021
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050022// TODO Revisit whether sdbusplus::xyz::openbmc_project::Time::server::EpochTime
23// still needed in dump entry since start time and completed time are available
24// from sdbusplus::xyz::openbmc_project::Common::server::Progress
25// #ibm-openbmc/2809
Patrick Williams9b18bf22022-07-22 19:26:55 -050026using EntryIfaces = sdbusplus::server::object_t<
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050027 sdbusplus::xyz::openbmc_project::Common::server::OriginatedBy,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050028 sdbusplus::xyz::openbmc_project::Common::server::Progress,
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050029 sdbusplus::xyz::openbmc_project::Dump::server::Entry,
30 sdbusplus::xyz::openbmc_project::Object::server::Delete,
31 sdbusplus::xyz::openbmc_project::Time::server::EpochTime>;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050032
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050033using OperationStatus =
34 sdbusplus::xyz::openbmc_project::Common::server::Progress::OperationStatus;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050035
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050036using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
37 OriginatedBy::OriginatorTypes;
38
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050039class Manager;
40
Jayanth Othayoth224882b2017-05-04 05:46:45 -050041/** @class Entry
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060042 * @brief Base Dump Entry implementation.
Jayanth Othayoth224882b2017-05-04 05:46:45 -050043 * @details A concrete implementation for the
44 * xyz.openbmc_project.Dump.Entry DBus API
45 */
46class Entry : public EntryIfaces
47{
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050048 public:
49 Entry() = delete;
50 Entry(const Entry&) = delete;
51 Entry& operator=(const Entry&) = delete;
52 Entry(Entry&&) = delete;
53 Entry& operator=(Entry&&) = delete;
54 ~Entry() = default;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050055
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050056 /** @brief Constructor for the Dump Entry Object
57 * @param[in] bus - Bus to attach to.
58 * @param[in] objPath - Object path to attach to
59 * @param[in] dumpId - Dump id.
60 * @param[in] timeStamp - Dump creation timestamp
61 * since the epoch.
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060062 * @param[in] dumpSize - Dump file size in bytes.
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050063 * @param[in] originId - Id of the originator of the dump
64 * @param[in] originType - Originator type
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050065 * @param[in] parent - The dump entry's parent.
66 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050067 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050068 uint64_t timeStamp, uint64_t dumpSize, OperationStatus dumpStatus,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050069 std::string originId, originatorTypes originType, Manager& parent) :
Patrick Williams73f64072022-04-01 17:04:47 -050070 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::emit_no_signals),
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060071 parent(parent), id(dumpId)
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050072 {
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050073 originatorId(originId);
74 originatorType(originType);
75
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060076 size(dumpSize);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050077 status(dumpStatus);
78
79 // If the object is created after the dump creation keep
80 // all same as timeStamp
81 // if the object created before the dump creation, update
82 // only the start time. Completed and elapsed time will
83 // be updated once the dump is completed.
84 if (dumpStatus == OperationStatus::Completed)
85 {
86 elapsed(timeStamp);
87 startTime(timeStamp);
88 completedTime(timeStamp);
89 }
90 else
91 {
92 elapsed(0);
93 startTime(timeStamp);
94 completedTime(0);
95 }
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050096 };
Jayanth Othayoth224882b2017-05-04 05:46:45 -050097
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050098 /** @brief Delete this d-bus object.
99 */
100 void delete_() override;
Jayanth Othayoth224882b2017-05-04 05:46:45 -0500101
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -0600102 /** @brief Method to initiate the offload of dump
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -0600103 * @param[in] uri - URI to offload dump
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -0600104 */
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -0600105 void initiateOffload(std::string uri) override
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -0600106 {
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -0600107 offloadUri(uri);
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -0600108 }
Jayanth Othayotha320c7c2017-06-14 07:17:21 -0500109
Dhruvaraj Subhashchandran270355b2022-02-01 02:44:43 -0600110 /** @brief Returns the dump id
111 * @return the id associated with entry
112 */
113 uint32_t getDumpId()
114 {
115 return id;
116 }
117
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -0600118 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -0500119 /** @brief This entry's parent */
120 Manager& parent;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -0500121
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -0500122 /** @brief This entry's id */
123 uint32_t id;
Jayanth Othayoth224882b2017-05-04 05:46:45 -0500124};
125
126} // namespace dump
127} // namespace phosphor