1 #include "system_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 
9 namespace openpower
10 {
11 namespace dump
12 {
13 namespace system
14 {
15 // 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,
18 constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3;
19 using namespace phosphor::logging;
20 
21 void 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     // Allow offloading only when the host is up.
28     if (!phosphor::dump::isHostRunning())
29     {
30         elog<NotAllowed>(
31             Reason("System 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 
38 void Entry::delete_()
39 {
40     auto srcDumpID = sourceDumpId();
41 
42     // Remove Dump entry D-bus object
43     phosphor::dump::Entry::delete_();
44 
45     // Remove host system dump when host is up by using source dump id
46     // which is present in system dump entry dbus object as a property.
47     if (phosphor::dump::isHostRunning())
48     {
49         phosphor::dump::host::requestDelete(srcDumpID,
50                                             TRANSPORT_DUMP_TYPE_IDENTIFIER);
51     }
52 }
53 } // namespace system
54 } // namespace dump
55 } // namespace openpower
56