blob: b66262894185f741a5094c3d8ed5827a9fbdf9e1 [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
Pavithra Barithaya864e1732023-04-11 04:30:23 -050016Objects::Objects(sdbusplus::bus_t& bus)
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050017{
George Liudc746c02022-09-02 11:10:55 +080018 Interfaces settingsIntfs = {timeSyncIntf};
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050019 MapperResponse result;
George Liuf344f842022-07-01 16:09:41 +080020
21 try
22 {
George Liudc746c02022-09-02 11:10:55 +080023 result = getSubTree(bus, root, settingsIntfs, 0);
George Liuf344f842022-07-01 16:09:41 +080024 }
Patrick Williams38679262022-07-22 19:26:55 -050025 catch (const sdbusplus::exception_t& ex)
George Liuf344f842022-07-01 16:09:41 +080026 {
Pavithra Barithayadd42c7f2022-08-11 05:09:02 -050027 error("Failed to invoke GetSubTree method: {ERROR}", "ERROR", ex);
George Liuf344f842022-07-01 16:09:41 +080028 }
29
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050030 if (result.empty())
31 {
Pavithra Barithayadd42c7f2022-08-11 05:09:02 -050032 error("Invalid response from mapper");
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050033 }
34
35 for (const auto& iter : result)
36 {
37 const Path& path = iter.first;
Pavithra Barithaya864e1732023-04-11 04:30:23 -050038 for (const auto& serviceIter : iter.second)
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050039 {
Pavithra Barithaya864e1732023-04-11 04:30:23 -050040 for (const Interface& interface : serviceIter.second)
Ed Tanous7aa715b2018-05-09 17:28:05 -070041 {
George Liu3c2f4492020-04-12 11:35:57 +080042 if (timeSyncIntf == interface)
Ed Tanous7aa715b2018-05-09 17:28:05 -070043 {
44 timeSyncMethod = path;
45 }
Ed Tanous7aa715b2018-05-09 17:28:05 -070046 }
Lei YUdebe1d82017-10-13 13:21:37 +080047 }
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050048 }
49}
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050050} // namespace settings