blob: da63b25622002d61cb92db46c58078080d2866a2 [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
25namespace fs = std::experimental::filesystem;
26
27class Manager;
28
29/** @class Entry
30 * @brief OpenBMC Dump Entry implementation.
31 * @details A concrete implementation for the
32 * xyz.openbmc_project.Dump.Entry DBus API
33 */
34class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
35{
36 public:
37 Entry() = delete;
38 Entry(const Entry&) = delete;
39 Entry& operator=(const Entry&) = delete;
40 Entry(Entry&&) = delete;
41 Entry& operator=(Entry&&) = delete;
42 ~Entry() = default;
43
44 /** @brief Constructor for the Dump Entry Object
45 * @param[in] bus - Bus to attach to.
46 * @param[in] objPath - Object path to attach to
47 * @param[in] dumpId - Dump id.
48 * @param[in] timeStamp - Dump creation timestamp
49 * since the epoch.
50 * @param[in] fileSize - Dump file size in bytes.
51 * @param[in] file - Name of dump file.
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050052 * @param[in] status - status of the dump.
Dhruvaraj Subhashchandran4a98e8f2020-01-29 07:11:08 -060053 * @param[in] parent - The dump entry's parent.
54 */
55 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
56 uint64_t timeStamp, uint64_t fileSize, const fs::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) :
59 EntryIfaces(bus, objPath.c_str(), true),
60 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 */
84 void update(uint64_t timeStamp, uint64_t fileSize, const fs::path& filePath)
85 {
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 */
98 fs::path file;
99};
100
101} // namespace bmc
102} // namespace dump
103} // namespace phosphor