blob: eb140e8854632d3d58c9e583acc648080daf58f9 [file] [log] [blame]
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -06001#pragma once
2
3#include "dump_entry.hpp"
Dhruvaraj Subhashchandran9420f482021-12-08 03:48:23 -06004#include "xyz/openbmc_project/Common/FilePath/server.hpp"
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -06005#include "xyz/openbmc_project/Dump/Entry/BMC/server.hpp"
6#include "xyz/openbmc_project/Dump/Entry/server.hpp"
7#include "xyz/openbmc_project/Object/Delete/server.hpp"
8#include "xyz/openbmc_project/Time/EpochTime/server.hpp"
9
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060010#include <sdbusplus/bus.hpp>
11#include <sdbusplus/server/object.hpp>
12
Jayanth Othayoth0af74a52021-04-08 03:55:21 -050013#include <filesystem>
14
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060015namespace phosphor
16{
17namespace dump
18{
19namespace bmc
20{
21template <typename T>
Patrick Williams9b18bf22022-07-22 19:26:55 -050022using ServerObject = typename sdbusplus::server::object_t<T>;
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060023
Patrick Williams9b18bf22022-07-22 19:26:55 -050024using EntryIfaces = sdbusplus::server::object_t<
Dhruvaraj Subhashchandran9420f482021-12-08 03:48:23 -060025 sdbusplus::xyz::openbmc_project::Dump::Entry::server::BMC,
26 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060027
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050028using originatorTypes = sdbusplus::xyz::openbmc_project::Common::server::
29 OriginatedBy::OriginatorTypes;
30
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060031class Manager;
32
33/** @class Entry
34 * @brief OpenBMC Dump Entry implementation.
35 * @details A concrete implementation for the
36 * xyz.openbmc_project.Dump.Entry DBus API
37 */
38class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
39{
40 public:
41 Entry() = delete;
42 Entry(const Entry&) = delete;
43 Entry& operator=(const Entry&) = delete;
44 Entry(Entry&&) = delete;
45 Entry& operator=(Entry&&) = delete;
46 ~Entry() = default;
47
48 /** @brief Constructor for the Dump Entry Object
49 * @param[in] bus - Bus to attach to.
50 * @param[in] objPath - Object path to attach to
51 * @param[in] dumpId - Dump id.
52 * @param[in] timeStamp - Dump creation timestamp
53 * since the epoch.
54 * @param[in] fileSize - Dump file size in bytes.
55 * @param[in] file - Name of dump file.
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050056 * @param[in] status - status of the dump.
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050057 * @param[in] originatorId - Id of the originator of the dump
58 * @param[in] originatorType - Originator type
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060059 * @param[in] parent - The dump entry's parent.
60 */
Patrick Williams9b18bf22022-07-22 19:26:55 -050061 Entry(sdbusplus::bus_t& bus, const std::string& objPath, uint32_t dumpId,
Jayanth Othayoth3fc6df42021-04-08 03:45:24 -050062 uint64_t timeStamp, uint64_t fileSize,
63 const std::filesystem::path& file,
Asmitha Karunanithi74a1f392021-10-27 03:23:59 -050064 phosphor::dump::OperationStatus status, std::string originatorId,
65 originatorTypes originatorType, phosphor::dump::Manager& parent) :
Patrick Williams73f64072022-04-01 17:04:47 -050066 EntryIfaces(bus, objPath.c_str(), EntryIfaces::action::defer_emit),
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060067 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, fileSize,
Dhruvaraj Subhashchandran9420f482021-12-08 03:48:23 -060068 status, originatorId, originatorType, parent)
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060069 {
Dhruvaraj Subhashchandran9420f482021-12-08 03:48:23 -060070 path(file);
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060071 // Emit deferred signal.
72 this->phosphor::dump::bmc::EntryIfaces::emit_object_added();
73 }
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060074
75 /** @brief Delete this d-bus object.
76 */
77 void delete_() override;
78
Dhruvaraj Subhashchandran580d91d2020-04-22 12:29:18 -050079 /** @brief Method to initiate the offload of dump
80 * @param[in] uri - URI to offload dump
81 */
82 void initiateOffload(std::string uri) override;
83
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050084 /** @brief Method to update an existing dump entry, once the dump creation
85 * is completed this function will be used to update the entry which got
86 * created during the dump request.
87 * @param[in] timeStamp - Dump creation timestamp
88 * @param[in] fileSize - Dump file size in bytes.
89 * @param[in] file - Name of dump file.
90 */
Jayanth Othayoth3fc6df42021-04-08 03:45:24 -050091 void update(uint64_t timeStamp, uint64_t fileSize,
92 const std::filesystem::path& filePath)
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050093 {
94 elapsed(timeStamp);
95 size(fileSize);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050096 // TODO: Handled dump failed case with #ibm-openbmc/2808
97 status(OperationStatus::Completed);
Dhruvaraj Subhashchandran9420f482021-12-08 03:48:23 -060098 path(filePath);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050099 // TODO: serialization of this property will be handled with
100 // #ibm-openbmc/2597
101 completedTime(timeStamp);
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -0500102 }
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -0600103};
104
105} // namespace bmc
106} // namespace dump
107} // namespace phosphor