blob: 964f3a70ef1a1b30118520fac4a1a400c69e4d6f [file] [log] [blame]
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -06001#pragma once
2
3#include "dump_entry.hpp"
4#include "xyz/openbmc_project/Dump/Entry/BMC/server.hpp"
5#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
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -06009#include <sdbusplus/bus.hpp>
10#include <sdbusplus/server/object.hpp>
11
Jayanth Othayoth0af74a52021-04-08 03:55:21 -050012#include <filesystem>
13
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060014namespace phosphor
15{
16namespace dump
17{
18namespace bmc
19{
20template <typename T>
Patrick Williams9b18bf22022-07-22 19:26:55 -050021using ServerObject = typename sdbusplus::server::object_t<T>;
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060022
Patrick Williams9b18bf22022-07-22 19:26:55 -050023using EntryIfaces = sdbusplus::server::object_t<
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060024 sdbusplus::xyz::openbmc_project::Dump::Entry::server::BMC>;
25
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060026class Manager;
27
28/** @class Entry
29 * @brief OpenBMC Dump Entry implementation.
30 * @details A concrete implementation for the
31 * xyz.openbmc_project.Dump.Entry DBus API
32 */
33class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
34{
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;
42
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.
49 * @param[in] fileSize - Dump file size in bytes.
50 * @param[in] file - Name of dump file.
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050051 * @param[in] status - status of the dump.
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060052 * @param[in] parent - The dump entry's parent.
53 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050054 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
Jayanth Othayoth3fc6df42021-04-08 03:45:24 -050055 uint64_t timeStamp, uint64_t fileSize,
56 const std::filesystem::path& file,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050057 phosphor::dump::OperationStatus status,
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060058 phosphor::dump::Manager& parent) :
Patrick Williams73f64072022-04-01 17:04:47 -050059 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060060 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, fileSize,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050061 status, parent),
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060062 file(file)
63 {
64 // Emit deferred signal.
65 this->phosphor::dump::bmc::EntryIfaces::emit_object_added();
66 }
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060067
68 /** @brief Delete this d-bus object.
69 */
70 void delete_() override;
71
Dhruvaraj Subhashchandran580d91d2020-04-22 12:29:18 -050072 /** @brief Method to initiate the offload of dump
73 * @param[in] uri - URI to offload dump
74 */
75 void initiateOffload(std::string uri) override;
76
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050077 /** @brief Method to update an existing dump entry, once the dump creation
78 * is completed this function will be used to update the entry which got
79 * created during the dump request.
80 * @param[in] timeStamp - Dump creation timestamp
81 * @param[in] fileSize - Dump file size in bytes.
82 * @param[in] file - Name of dump file.
83 */
Jayanth Othayoth3fc6df42021-04-08 03:45:24 -050084 void update(uint64_t timeStamp, uint64_t fileSize,
85 const std::filesystem::path& filePath)
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050086 {
87 elapsed(timeStamp);
88 size(fileSize);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050089 // TODO: Handled dump failed case with #ibm-openbmc/2808
90 status(OperationStatus::Completed);
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050091 file = filePath;
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050092 // TODO: serialization of this property will be handled with
93 // #ibm-openbmc/2597
94 completedTime(timeStamp);
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050095 }
96
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060097 private:
98 /** @Dump file name */
Jayanth Othayoth3fc6df42021-04-08 03:45:24 -050099 std::filesystem::path file;
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -0600100};
101
102} // namespace bmc
103} // namespace dump
104} // namespace phosphor