blob: 821be37068b6ef77fcb10cfc32395e57f4da36f5 [file] [log] [blame]
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -06001#pragma once
2
3#include "dump_entry.hpp"
4#include "xyz/openbmc_project/Dump/Entry/System/server.hpp"
5
6#include <sdbusplus/bus.hpp>
7#include <sdbusplus/server/object.hpp>
8
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -06009namespace openpower
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060010{
11namespace dump
12{
13namespace system
14{
15template <typename T>
16using ServerObject = typename sdbusplus::server::object::object<T>;
17
18using EntryIfaces = sdbusplus::server::object::object<
19 sdbusplus::xyz::openbmc_project::Dump::Entry::server::System>;
20
21namespace fs = std::experimental::filesystem;
22
23class Manager;
24
25/** @class Entry
26 * @brief System Dump Entry implementation.
27 * @details A concrete implementation for the
28 * xyz.openbmc_project.Dump.Entry DBus API
29 */
30class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
31{
32 public:
33 Entry() = delete;
34 Entry(const Entry&) = delete;
35 Entry& operator=(const Entry&) = delete;
36 Entry(Entry&&) = delete;
37 Entry& operator=(Entry&&) = delete;
38 ~Entry() = default;
39
40 /** @brief Constructor for the Dump Entry Object
41 * @param[in] bus - Bus to attach to.
42 * @param[in] objPath - Object path to attach to
43 * @param[in] dumpId - Dump id.
44 * @param[in] timeStamp - Dump creation timestamp
45 * since the epoch.
46 * @param[in] dumpSize - Dump size in bytes.
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050047 * @param[in] sourceId - DumpId provided by the source.
48 * @param[in] status - status of the dump.
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060049 * @param[in] parent - The dump entry's parent.
50 */
51 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
52 uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050053 phosphor::dump::OperationStatus status,
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060054 phosphor::dump::Manager& parent) :
55 EntryIfaces(bus, objPath.c_str(), true),
56 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050057 status, parent)
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060058 {
59 sourceDumpId(sourceId);
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060060 // Emit deferred signal.
61 this->openpower::dump::system::EntryIfaces::emit_object_added();
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060062 };
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060063
64 /** @brief Method to initiate the offload of dump
65 * @param[in] uri - URI to offload dump.
66 */
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060067 void initiateOffload(std::string uri) override;
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050068
69 /** @brief Method to update an existing dump entry
70 * @param[in] timeStamp - Dump creation timestamp
71 * @param[in] dumpSize - Dump size in bytes.
72 * @param[in] sourceId - DumpId provided by the source.
73 */
74 void update(uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId)
75 {
76 elapsed(timeStamp);
77 size(dumpSize);
78 sourceDumpId(sourceId);
Dhruvaraj Subhashchandrana6ab8062020-10-29 15:29:10 -050079 // TODO: Handled dump failure case with
80 // #bm-openbmc/2808
81 status(OperationStatus::Completed);
82 completedTime(timeStamp);
Dhruvaraj Subhashchandran6ccb50e2020-10-29 09:33:18 -050083 }
Ramesh Iyyar22793862020-12-04 04:03:03 -060084
85 /**
86 * @brief Delete host system dump and it entry dbus object
87 */
88 void delete_() override;
Dhruvaraj Subhashchandranf140f662020-01-30 00:29:01 -060089};
90
91} // namespace system
92} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060093} // namespace openpower