blob: 98502b4532bc59d3c3e3e9800d706d064c75fe02 [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 Othayoth3fc6df42021-04-08 03:45:24 -05008#include <filesystem>
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05009#include <sdbusplus/bus.hpp>
10#include <sdbusplus/server/object.hpp>
11
Jayanth Othayoth224882b2017-05-04 05:46:45 -050012namespace phosphor
13{
14namespace dump
15{
16
17template <typename T>
18using ServerObject = typename sdbusplus::server::object::object<T>;
19
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050020// 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
Jayanth Othayoth224882b2017-05-04 05:46:45 -050024using EntryIfaces = sdbusplus::server::object::object<
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050025 sdbusplus::xyz::openbmc_project::Common::server::Progress,
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050026 sdbusplus::xyz::openbmc_project::Dump::server::Entry,
27 sdbusplus::xyz::openbmc_project::Object::server::Delete,
28 sdbusplus::xyz::openbmc_project::Time::server::EpochTime>;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050029
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050030using OperationStatus =
31 sdbusplus::xyz::openbmc_project::Common::server::Progress::OperationStatus;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050032
33class Manager;
34
Jayanth Othayoth224882b2017-05-04 05:46:45 -050035/** @class Entry
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060036 * @brief Base Dump Entry implementation.
Jayanth Othayoth224882b2017-05-04 05:46:45 -050037 * @details A concrete implementation for the
38 * xyz.openbmc_project.Dump.Entry DBus API
39 */
40class Entry : public EntryIfaces
41{
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050042 public:
43 Entry() = delete;
44 Entry(const Entry&) = delete;
45 Entry& operator=(const Entry&) = delete;
46 Entry(Entry&&) = delete;
47 Entry& operator=(Entry&&) = delete;
48 ~Entry() = default;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050049
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050050 /** @brief Constructor for the Dump Entry Object
51 * @param[in] bus - Bus to attach to.
52 * @param[in] objPath - Object path to attach to
53 * @param[in] dumpId - Dump id.
54 * @param[in] timeStamp - Dump creation timestamp
55 * since the epoch.
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060056 * @param[in] dumpSize - Dump file size in bytes.
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050057 * @param[in] parent - The dump entry's parent.
58 */
59 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050060 uint64_t timeStamp, uint64_t dumpSize, OperationStatus dumpStatus,
61 Manager& parent) :
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050062 EntryIfaces(bus, objPath.c_str(), true),
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060063 parent(parent), id(dumpId)
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050064 {
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060065 size(dumpSize);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050066 status(dumpStatus);
67
68 // If the object is created after the dump creation keep
69 // all same as timeStamp
70 // if the object created before the dump creation, update
71 // only the start time. Completed and elapsed time will
72 // be updated once the dump is completed.
73 if (dumpStatus == OperationStatus::Completed)
74 {
75 elapsed(timeStamp);
76 startTime(timeStamp);
77 completedTime(timeStamp);
78 }
79 else
80 {
81 elapsed(0);
82 startTime(timeStamp);
83 completedTime(0);
84 }
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050085 };
Jayanth Othayoth224882b2017-05-04 05:46:45 -050086
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050087 /** @brief Delete this d-bus object.
88 */
89 void delete_() override;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050090
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060091 /** @brief Method to initiate the offload of dump
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060092 * @param[in] uri - URI to offload dump
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060093 */
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060094 void initiateOffload(std::string uri) override
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060095 {
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060096 offloadUri(uri);
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060097 }
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050098
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060099 protected:
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -0500100 /** @brief This entry's parent */
101 Manager& parent;
Jayanth Othayotha320c7c2017-06-14 07:17:21 -0500102
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -0500103 /** @brief This entry's id */
104 uint32_t id;
Jayanth Othayoth224882b2017-05-04 05:46:45 -0500105};
106
107} // namespace dump
108} // namespace phosphor