blob: d0d50269b91e70e9f67ceb5953c18ac2492a5d73 [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
Pavithra Barithayadd42c7f2022-08-11 05:09:02 -050011PHOSPHOR_LOG2_USING;
12
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050013using namespace phosphor::logging;
14using namespace sdbusplus::xyz::openbmc_project::Common::Error;
15
16constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper";
17constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper";
18constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper";
19
Patrick Williams38679262022-07-22 19:26:55 -050020Objects::Objects(sdbusplus::bus_t& bus) : bus(bus)
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050021{
George Liudc746c02022-09-02 11:10:55 +080022 Interfaces settingsIntfs = {timeSyncIntf};
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050023 MapperResponse result;
George Liuf344f842022-07-01 16:09:41 +080024
25 try
26 {
George Liudc746c02022-09-02 11:10:55 +080027 result = getSubTree(bus, root, settingsIntfs, 0);
George Liuf344f842022-07-01 16:09:41 +080028 }
Patrick Williams38679262022-07-22 19:26:55 -050029 catch (const sdbusplus::exception_t& ex)
George Liuf344f842022-07-01 16:09:41 +080030 {
Pavithra Barithayadd42c7f2022-08-11 05:09:02 -050031 error("Failed to invoke GetSubTree method: {ERROR}", "ERROR", ex);
George Liuf344f842022-07-01 16:09:41 +080032 }
33
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050034 if (result.empty())
35 {
Pavithra Barithayadd42c7f2022-08-11 05:09:02 -050036 error("Invalid response from mapper");
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050037 }
38
39 for (const auto& iter : result)
40 {
41 const Path& path = iter.first;
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050042 for (const auto& service_iter : iter.second)
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050043 {
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050044 for (const Interface& interface : service_iter.second)
Ed Tanous7aa715b2018-05-09 17:28:05 -070045 {
George Liu3c2f4492020-04-12 11:35:57 +080046 if (timeSyncIntf == interface)
Ed Tanous7aa715b2018-05-09 17:28:05 -070047 {
48 timeSyncMethod = path;
49 }
Ed Tanous7aa715b2018-05-09 17:28:05 -070050 }
Lei YUdebe1d82017-10-13 13:21:37 +080051 }
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050052 }
53}
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050054} // namespace settings