blob: c7fde0552f116844b93933b2ee102602cab1aa84 [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
Pavithra Barithayab2670242023-11-30 04:22:08 -060013using namespace phosphor::time::utils;
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050014using namespace phosphor::logging;
15using namespace sdbusplus::xyz::openbmc_project::Common::Error;
16
Pavithra Barithaya864e1732023-04-11 04:30:23 -050017Objects::Objects(sdbusplus::bus_t& bus)
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050018{
George Liudc746c02022-09-02 11:10:55 +080019 Interfaces settingsIntfs = {timeSyncIntf};
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050020 MapperResponse result;
George Liuf344f842022-07-01 16:09:41 +080021
22 try
23 {
George Liudc746c02022-09-02 11:10:55 +080024 result = getSubTree(bus, root, settingsIntfs, 0);
George Liuf344f842022-07-01 16:09:41 +080025 }
Patrick Williams38679262022-07-22 19:26:55 -050026 catch (const sdbusplus::exception_t& ex)
George Liuf344f842022-07-01 16:09:41 +080027 {
Pavithra Barithayadd42c7f2022-08-11 05:09:02 -050028 error("Failed to invoke GetSubTree method: {ERROR}", "ERROR", ex);
George Liuf344f842022-07-01 16:09:41 +080029 }
30
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050031 if (result.empty())
32 {
Pavithra Barithayadd42c7f2022-08-11 05:09:02 -050033 error("Invalid response from mapper");
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050034 }
35
36 for (const auto& iter : result)
37 {
38 const Path& path = iter.first;
Pavithra Barithaya864e1732023-04-11 04:30:23 -050039 for (const auto& serviceIter : iter.second)
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050040 {
Pavithra Barithaya864e1732023-04-11 04:30:23 -050041 for (const Interface& interface : serviceIter.second)
Ed Tanous7aa715b2018-05-09 17:28:05 -070042 {
George Liu3c2f4492020-04-12 11:35:57 +080043 if (timeSyncIntf == interface)
Ed Tanous7aa715b2018-05-09 17:28:05 -070044 {
45 timeSyncMethod = path;
46 }
Ed Tanous7aa715b2018-05-09 17:28:05 -070047 }
Lei YUdebe1d82017-10-13 13:21:37 +080048 }
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050049 }
50}
Deepak Kodihalli20ed79e2017-07-25 05:48:58 -050051} // namespace settings