blob: 50081b721d30bd10064027da2aef48c1fe05473c [file] [log] [blame]
Gunnar Millsab4cc6a2018-09-14 14:42:39 -05001#include "settings.hpp"
2
3#include "xyz/openbmc_project/Common/error.hpp"
4
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -05005#include <phosphor-logging/elog-errors.hpp>
George Liu947b5342022-07-01 16:12:18 +08006#include <phosphor-logging/lg2.hpp>
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -05007
8namespace settings
9{
10
11using namespace phosphor::logging;
12using namespace sdbusplus::xyz::openbmc_project::Common::Error;
13
14constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper";
15constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
16constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
17
Patrick Williams38679262022-07-22 19:26:55 -050018Objects::Objects(sdbusplus::bus_t& bus) : bus(bus)
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050019{
George Liudc746c02022-09-02 11:10:55 +080020 Interfaces settingsIntfs = {timeSyncIntf};
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050021 MapperResponse result;
George Liuf344f842022-07-01 16:09:41 +080022
23 try
24 {
George Liudc746c02022-09-02 11:10:55 +080025 result = getSubTree(bus, root, settingsIntfs, 0);
George Liuf344f842022-07-01 16:09:41 +080026 }
Patrick Williams38679262022-07-22 19:26:55 -050027 catch (const sdbusplus::exception_t& ex)
George Liuf344f842022-07-01 16:09:41 +080028 {
George Liu947b5342022-07-01 16:12:18 +080029 lg2::error("Failed to invoke GetSubTree method: {ERROR}", "ERROR", ex);
George Liuf344f842022-07-01 16:09:41 +080030 }
31
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050032 if (result.empty())
33 {
George Liu947b5342022-07-01 16:12:18 +080034 lg2::error("Invalid response from mapper");
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050035 }
36
37 for (const auto& iter : result)
38 {
39 const Path& path = iter.first;
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050040 for (const auto& service_iter : iter.second)
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050041 {
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050042 for (const Interface& interface : service_iter.second)
Ed Tanous7aa715b2018-05-09 17:28:05 -070043 {
George Liu3c2f4492020-04-12 11:35:57 +080044 if (timeSyncIntf == interface)
Ed Tanous7aa715b2018-05-09 17:28:05 -070045 {
46 timeSyncMethod = path;
47 }
Ed Tanous7aa715b2018-05-09 17:28:05 -070048 }
Lei YUdebe1d82017-10-13 13:21:37 +080049 }
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050050 }
51}
52
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050053} // namespace settings