blob: 970a03c0740392b2e851009379c9c73cd4ec3a76 [file] [log] [blame]
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -06001#include "system_dump_entry.hpp"
2
Ramesh Iyyar22793862020-12-04 04:03:03 -06003#include "dump_utils.hpp"
Ramesh Iyyar131994b2020-12-03 08:35:36 -06004#include "host_transport_exts.hpp"
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -06005
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -06006#include <phosphor-logging/elog-errors.hpp>
7#include <xyz/openbmc_project/Common/error.hpp>
8
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -06009namespace phosphor
10{
11namespace dump
12{
13namespace system
14{
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -060015using namespace phosphor::logging;
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060016
17void Entry::initiateOffload(std::string uri)
18{
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -060019 using NotAllowed =
20 sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
21 using Reason = xyz::openbmc_project::Common::NotAllowed::REASON;
22
23 // Allow offloading only when the host is up.
24 if (!phosphor::dump::isHostRunning())
25 {
26 elog<NotAllowed>(
27 Reason("System dump can be offloaded only when the host is up"));
28 return;
29 }
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060030 phosphor::dump::Entry::initiateOffload(uri);
Dhruvaraj Subhashchandran59642e22020-03-19 03:37:44 -050031 phosphor::dump::host::requestOffload(sourceDumpId());
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060032}
33
Ramesh Iyyar22793862020-12-04 04:03:03 -060034void Entry::delete_()
35{
36 auto srcDumpID = sourceDumpId();
37
38 // Remove Dump entry D-bus object
39 phosphor::dump::Entry::delete_();
40
41 // Remove host system dump when host is up by using source dump id
42 // which is present in system dump entry dbus object as a property.
Dhruvaraj Subhashchandran6a54d9a2020-12-17 22:24:37 -060043 if (phosphor::dump::isHostRunning())
Ramesh Iyyar22793862020-12-04 04:03:03 -060044 {
45 phosphor::dump::host::requestDelete(srcDumpID);
46 }
47}
Dhruvaraj Subhashchandran69e61522020-02-04 06:39:11 -060048} // namespace system
49} // namespace dump
50} // namespace phosphor