blob: a1d90a2b619555de0d5a372fcf02deecf395bb1f [file] [log] [blame]
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -06001#include "resource_dump_entry.hpp"
2
3#include "dump_utils.hpp"
4#include "host_transport_exts.hpp"
Dhruvaraj Subhashchandranad50d422022-01-18 05:54:02 -06005#include "op_dump_consts.hpp"
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -06006
7#include <phosphor-logging/elog-errors.hpp>
8#include <xyz/openbmc_project/Common/error.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{
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060016// TODO #ibm-openbmc/issues/2859
17// Revisit host transport impelementation
18// This value is used to identify the dump in the transport layer to host,
Dhruvaraj Subhashchandran0c782d62021-03-24 13:27:13 -050019constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 9;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060020using namespace phosphor::logging;
21
22void Entry::initiateOffload(std::string uri)
23{
24 using NotAllowed =
25 sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
26 using Reason = xyz::openbmc_project::Common::NotAllowed::REASON;
27
28 if (!phosphor::dump::isHostRunning())
29 {
30 elog<NotAllowed>(
31 Reason("This dump can be offloaded only when the host is up"));
32 return;
33 }
34 phosphor::dump::Entry::initiateOffload(uri);
35 phosphor::dump::host::requestOffload(sourceDumpId());
36}
37
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060038void Entry::delete_()
39{
40 auto srcDumpID = sourceDumpId();
41
42 // Remove Dump entry D-bus object
43 phosphor::dump::Entry::delete_();
44
45 // Remove resource dump when host is up by using source dump id
46 // which is present in resource dump entry dbus object as a property.
Dhruvaraj Subhashchandranad50d422022-01-18 05:54:02 -060047 if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID))
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060048 {
49 phosphor::dump::host::requestDelete(srcDumpID,
50 TRANSPORT_DUMP_TYPE_IDENTIFIER);
51 }
52}
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060053} // namespace resource
54} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060055} // namespace openpower