blob: c68d90aa1cd8a92a0a17fc51035f1fdf76b5fd3d [file] [log] [blame]
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -06001#pragma once
2
3#include "com/ibm/Dump/Entry/Resource/server.hpp"
4#include "dump_entry.hpp"
5
6#include <chrono>
7#include <sdbusplus/bus.hpp>
8#include <sdbusplus/server/object.hpp>
9
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060010namespace openpower
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060011{
12namespace dump
13{
14namespace resource
15{
16template <typename T>
17using ServerObject = typename sdbusplus::server::object::object<T>;
18
19using EntryIfaces = sdbusplus::server::object::object<
20 sdbusplus::com::ibm::Dump::Entry::server::Resource>;
21
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060022class Manager;
23
24/** @class Entry
25 * @brief Resource Dump Entry implementation.
26 * @details An extension to Dump::Entry class and
27 * A concrete implementation for the
28 * com::ibm::Dump::Entry::Resource 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 resource 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.
47 * @param[in] sourceId - DumpId provided by the source.
48 * @param[in] vspString - Input to host to generate the resource dump.
49 * @param[in] pwd - Password needed by host to validate the request.
50 * @param[in] status - status of the dump.
51 * @param[in] parent - The dump entry's parent.
52 */
53 Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
54 uint64_t timeStamp, uint64_t dumpSize, const uint32_t sourceId,
55 std::string vspString, std::string pwd,
56 phosphor::dump::OperationStatus status,
57 phosphor::dump::Manager& parent) :
58 EntryIfaces(bus, objPath.c_str(), true),
59 phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, dumpSize,
60 status, parent)
61 {
62 sourceDumpId(sourceId);
63 vSPString(vspString);
64 password(pwd);
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060065 // Emit deferred signal.
66 this->openpower::dump::resource::EntryIfaces::emit_object_added();
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060067 };
68
69 /** @brief Method to initiate the offload of dump
70 * @param[in] uri - URI to offload dump.
71 */
Dhruvaraj Subhashchandran2f8e2762021-02-11 07:22:35 -060072 void initiateOffload(std::string uri) override;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060073
74 /** @brief Method to update an existing dump entry
75 * @param[in] timeStamp - Dump creation timestamp
76 * @param[in] dumpSize - Dump size in bytes.
77 * @param[in] sourceId - The id of dump in the origin.
78 */
79 void update(uint64_t timeStamp, uint64_t dumpSize, uint32_t sourceId)
80 {
81 sourceDumpId(sourceId);
82 elapsed(timeStamp);
83 size(dumpSize);
84 // TODO: Handled dump failure case with
85 // #bm-openbmc/2808
86 status(OperationStatus::Completed);
87 completedTime(timeStamp);
88 }
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060089
90 /**
91 * @brief Delete resource dump in host memory and the entry dbus object
92 */
93 void delete_() override;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060094};
95
96} // namespace resource
97} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060098} // namespace openpower