Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 1 | #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 Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 9 | namespace openpower |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 10 | { |
| 11 | namespace dump |
| 12 | { |
| 13 | namespace resource |
| 14 | { |
Dhruvaraj Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 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, |
Dhruvaraj Subhashchandran | 0c782d6 | 2021-03-24 13:27:13 -0500 | [diff] [blame^] | 18 | constexpr auto TRANSPORT_DUMP_TYPE_IDENTIFIER = 9; |
Dhruvaraj Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 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 | 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 Subhashchandran | 4c63ce5 | 2020-12-18 02:07:22 -0600 | [diff] [blame] | 37 | void 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 Subhashchandran | 62337a9 | 2020-11-22 21:24:30 -0600 | [diff] [blame] | 52 | } // namespace resource |
| 53 | } // namespace dump |
Dhruvaraj Subhashchandran | 341d683 | 2021-01-15 06:28:04 -0600 | [diff] [blame] | 54 | } // namespace openpower |