1 #include "system_dump_entry.hpp"
2 
3 #include "dump_utils.hpp"
4 #include "host_transport_exts.hpp"
5 #include "op_dump_consts.hpp"
6 
7 #include <fmt/core.h>
8 
9 #include <phosphor-logging/elog-errors.hpp>
10 #include <xyz/openbmc_project/Common/error.hpp>
11 
12 namespace openpower
13 {
14 namespace dump
15 {
16 namespace system
17 {
18 // TODO #ibm-openbmc/issues/2859
19 // Revisit host transport impelementation
20 // This value is used to identify the dump in the transport layer to host,
21 constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 3;
22 using namespace phosphor::logging;
23 
24 void Entry::initiateOffload(std::string uri)
25 {
26     log<level::INFO>(
27         fmt::format(
28             "System dump offload request id({}) uri({}) source dumpid()", id,
29             uri, sourceDumpId())
30             .c_str());
31     phosphor::dump::Entry::initiateOffload(uri);
32     phosphor::dump::host::requestOffload(sourceDumpId());
33 }
34 
35 void Entry::delete_()
36 {
37     auto srcDumpID = sourceDumpId();
38     auto dumpId = id;
39 
40     if ((!offloadUri().empty()) && (phosphor::dump::isHostRunning()))
41     {
42         log<level::ERR>(
43             fmt::format("Dump offload is in progress id({}) srcdumpid({})",
44                         dumpId, srcDumpID)
45                 .c_str());
46         elog<sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed>(
47             xyz::openbmc_project::Common::NotAllowed::REASON(
48                 "Dump offload is in progress"));
49     }
50 
51     log<level::INFO>(fmt::format("System dump delete id({}) srcdumpid({})",
52                                  dumpId, srcDumpID)
53                          .c_str());
54 
55     // Remove Dump entry D-bus object
56     phosphor::dump::Entry::delete_();
57 
58     // Remove host system dump when host is up by using source dump id
59     // which is present in system dump entry dbus object as a property.
60     if ((phosphor::dump::isHostRunning()) && (srcDumpID != INVALID_SOURCE_ID))
61     {
62         phosphor::dump::host::requestDelete(srcDumpID,
63                                             TRANSPORT_DUMP_TYPE_IDENTIFIER);
64     }
65 }
66 } // namespace system
67 } // namespace dump
68 } // namespace openpower
69