blob: f227641cd6e3147fc4844c32bcbf0db0679e5c8f [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 Subhashchandran580d91d2020-04-22 12:29:18 -05009#include <filesystem>
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060010#include <sdbusplus/bus.hpp>
11#include <sdbusplus/server/object.hpp>
12
13namespace phosphor
14{
15namespace dump
16{
17namespace bmc
18{
19template <typename T>
20using ServerObject = typename sdbusplus::server::object::object<T>;
21
22using EntryIfaces = sdbusplus::server::object::object<
23 sdbusplus::xyz::openbmc_project::Dump::Entry::server::BMC>;
24
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060025class Manager;
26
27/** @class Entry
28 * @brief OpenBMC Dump Entry implementation.
29 * @details A concrete implementation for the
30 * xyz.openbmc_project.Dump.Entry DBus API
31 */
32class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
33{
34 public:
35 Entry() = delete;
36 Entry(const Entry&) = delete;
37 Entry& operator=(const Entry&) = delete;
38 Entry(Entry&&) = delete;
39 Entry& operator=(Entry&&) = delete;
40 ~Entry() = default;
41
42 /** @brief Constructor for the Dump Entry Object
43 * @param[in] bus - Bus to attach to.
44 * @param[in] objPath - Object path to attach to
45 * @param[in] dumpId - Dump id.
46 * @param[in] timeStamp - Dump creation timestamp
47 * since the epoch.
48 * @param[in] fileSize - Dump file size in bytes.
49 * @param[in] file - Name of dump file.
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050050 * @param[in] status - status of the dump.
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060051 * @param[in] parent - The dump entry's parent.
52 */
53 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
Jayanth Othayoth3fc6df42021-04-08 03:45:24 -050054 uint64_t timeStamp, uint64_t fileSize,
55 const std::filesystem::path& file,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050056 phosphor::dump::OperationStatus status,
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060057 phosphor::dump::Manager& parent) :
58 EntryIfaces(bus, objPath.c_str(), true),
59 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, fileSize,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050060 status, parent),
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060061 file(file)
62 {
63 // Emit deferred signal.
64 this->phosphor::dump::bmc::EntryIfaces::emit_object_added();
65 }
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060066
67 /** @brief Delete this d-bus object.
68 */
69 void delete_() override;
70
Dhruvaraj Subhashchandran580d91d2020-04-22 12:29:18 -050071 /** @brief Method to initiate the offload of dump
72 * @param[in] uri - URI to offload dump
73 */
74 void initiateOffload(std::string uri) override;
75
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050076 /** @brief Method to update an existing dump entry, once the dump creation
77 * is completed this function will be used to update the entry which got
78 * created during the dump request.
79 * @param[in] timeStamp - Dump creation timestamp
80 * @param[in] fileSize - Dump file size in bytes.
81 * @param[in] file - Name of dump file.
82 */
Jayanth Othayoth3fc6df42021-04-08 03:45:24 -050083 void update(uint64_t timeStamp, uint64_t fileSize,
84 const std::filesystem::path& filePath)
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050085 {
86 elapsed(timeStamp);
87 size(fileSize);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050088 // TODO: Handled dump failed case with #ibm-openbmc/2808
89 status(OperationStatus::Completed);
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050090 file = filePath;
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050091 // TODO: serialization of this property will be handled with
92 // #ibm-openbmc/2597
93 completedTime(timeStamp);
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050094 }
95
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060096 private:
97 /** @Dump file name */
Jayanth Othayoth3fc6df42021-04-08 03:45:24 -050098 std::filesystem::path file;
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060099};
100
101} // namespace bmc
102} // namespace dump
103} // namespace phosphor