blob: e8b2497bf2ef29a410033828041fd4f199e102ce [file] [log] [blame]
Dhruvaraj Subhashchandran9e905372021-08-20 04:06:06 -05001#include "op_dump_util.hpp"
2
3#include "xyz/openbmc_project/Common/error.hpp"
4#include "xyz/openbmc_project/Dump/Create/error.hpp"
5
6#include <unistd.h>
7
8#include <phosphor-logging/elog-errors.hpp>
9#include <phosphor-logging/elog.hpp>
10#include <phosphor-logging/lg2.hpp>
11
12#include <filesystem>
13
14namespace openpower
15{
16namespace dump
17{
18namespace util
19{
20
21bool isOPDumpsEnabled(sdbusplus::bus::bus& bus)
22{
23 // Set isEnabled as true by default. In a field deployment, the system dump
24 // feature is usually enabled to facilitate effective debugging in the event
25 // of a failure. If due to some error, the settings service couldn't provide
26 // the actual value, the system assumes that the dump is enabled.
27 // This approach aligns with the principle of collecting as much data as
28 // possible for debugging in case of a system failure.
29 auto isEnabled = true;
30
31 constexpr auto enable = "xyz.openbmc_project.Object.Enable";
32 constexpr auto policy = "/xyz/openbmc_project/dump/system_dump_policy";
33 constexpr auto property = "org.freedesktop.DBus.Properties";
34
35 try
36 {
37 auto service = phosphor::dump::getService(bus, policy, enable);
38
39 auto method = bus.new_method_call(service.c_str(), policy, property,
40 "Get");
41 method.append(enable, "Enabled");
42 auto reply = bus.call(method);
43 std::variant<bool> v;
44 reply.read(v);
45 isEnabled = std::get<bool>(v);
46 }
47 catch (const sdbusplus::exception::SdBusError& e)
48 {
49 lg2::error("Error: {ERROR} in getting dump policy, default is enabled",
50 "ERROR", e);
51 }
52 return isEnabled;
53}
54
55} // namespace util
56} // namespace dump
57} // namespace openpower