blob: 0954e9ae654d9e9850b913e294a0f46597b5cc07 [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"
5
6#include <phosphor-logging/elog-errors.hpp>
7#include <xyz/openbmc_project/Common/error.hpp>
8
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -06009namespace openpower
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060010{
11namespace dump
12{
13namespace resource
14{
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060015// TODO #ibm-openbmc/issues/2859
16// Revisit host transport impelementation
17// This value is used to identify the dump in the transport layer to host,
Dhruvaraj Subhashchandran0c782d62021-03-24 13:27:13 -050018constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 9;
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060019using namespace phosphor::logging;
20
21void Entry::initiateOffload(std::string uri)
22{
23 using NotAllowed =
24 sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
25 using Reason = xyz::openbmc_project::Common::NotAllowed::REASON;
26
27 if (!phosphor::dump::isHostRunning())
28 {
29 elog<NotAllowed>(
30 Reason("This dump can be offloaded only when the host is up"));
31 return;
32 }
33 phosphor::dump::Entry::initiateOffload(uri);
34 phosphor::dump::host::requestOffload(sourceDumpId());
35}
36
Dhruvaraj Subhashchandran4c63ce52020-12-18 02:07:22 -060037void Entry::delete_()
38{
39 auto srcDumpID = sourceDumpId();
40
41 // Remove Dump entry D-bus object
42 phosphor::dump::Entry::delete_();
43
44 // Remove resource dump when host is up by using source dump id
45 // which is present in resource dump entry dbus object as a property.
46 if (phosphor::dump::isHostRunning())
47 {
48 phosphor::dump::host::requestDelete(srcDumpID,
49 TRANSPORT_DUMP_TYPE_IDENTIFIER);
50 }
51}
Dhruvaraj Subhashchandran62337a92020-11-22 21:24:30 -060052} // namespace resource
53} // namespace dump
Dhruvaraj Subhashchandran341d6832021-01-15 06:28:04 -060054} // namespace openpower