Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 1 | #include "settings.hpp" |
2 | |||||
3 | #include "xyz/openbmc_project/Common/error.hpp" | ||||
4 | |||||
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 5 | #include <phosphor-logging/elog-errors.hpp> |
George Liu | 947b534 | 2022-07-01 16:12:18 +0800 | [diff] [blame] | 6 | #include <phosphor-logging/lg2.hpp> |
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 7 | |
8 | namespace settings | ||||
9 | { | ||||
10 | |||||
Pavithra Barithaya | dd42c7f | 2022-08-11 05:09:02 -0500 | [diff] [blame] | 11 | PHOSPHOR_LOG2_USING; |
12 | |||||
Pavithra Barithaya | b267024 | 2023-11-30 04:22:08 -0600 | [diff] [blame] | 13 | using namespace phosphor::time::utils; |
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 14 | using namespace phosphor::logging; |
15 | using namespace sdbusplus::xyz::openbmc_project::Common::Error; | ||||
16 | |||||
Pavithra Barithaya | 864e173 | 2023-04-11 04:30:23 -0500 | [diff] [blame] | 17 | Objects::Objects(sdbusplus::bus_t& bus) |
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 18 | { |
George Liu | dc746c0 | 2022-09-02 11:10:55 +0800 | [diff] [blame] | 19 | Interfaces settingsIntfs = {timeSyncIntf}; |
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 20 | MapperResponse result; |
George Liu | f344f84 | 2022-07-01 16:09:41 +0800 | [diff] [blame] | 21 | |
22 | try | ||||
23 | { | ||||
George Liu | dc746c0 | 2022-09-02 11:10:55 +0800 | [diff] [blame] | 24 | result = getSubTree(bus, root, settingsIntfs, 0); |
George Liu | f344f84 | 2022-07-01 16:09:41 +0800 | [diff] [blame] | 25 | } |
Patrick Williams | 3867926 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 26 | catch (const sdbusplus::exception_t& ex) |
George Liu | f344f84 | 2022-07-01 16:09:41 +0800 | [diff] [blame] | 27 | { |
Pavithra Barithaya | dd42c7f | 2022-08-11 05:09:02 -0500 | [diff] [blame] | 28 | error("Failed to invoke GetSubTree method: {ERROR}", "ERROR", ex); |
George Liu | f344f84 | 2022-07-01 16:09:41 +0800 | [diff] [blame] | 29 | } |
30 | |||||
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 31 | if (result.empty()) |
32 | { | ||||
Pavithra Barithaya | dd42c7f | 2022-08-11 05:09:02 -0500 | [diff] [blame] | 33 | error("Invalid response from mapper"); |
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 34 | } |
35 | |||||
36 | for (const auto& iter : result) | ||||
37 | { | ||||
38 | const Path& path = iter.first; | ||||
Pavithra Barithaya | 864e173 | 2023-04-11 04:30:23 -0500 | [diff] [blame] | 39 | for (const auto& serviceIter : iter.second) |
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 40 | { |
Pavithra Barithaya | 864e173 | 2023-04-11 04:30:23 -0500 | [diff] [blame] | 41 | for (const Interface& interface : serviceIter.second) |
Ed Tanous | 7aa715b | 2018-05-09 17:28:05 -0700 | [diff] [blame] | 42 | { |
George Liu | 3c2f449 | 2020-04-12 11:35:57 +0800 | [diff] [blame] | 43 | if (timeSyncIntf == interface) |
Ed Tanous | 7aa715b | 2018-05-09 17:28:05 -0700 | [diff] [blame] | 44 | { |
45 | timeSyncMethod = path; | ||||
46 | } | ||||
Ed Tanous | 7aa715b | 2018-05-09 17:28:05 -0700 | [diff] [blame] | 47 | } |
Lei YU | debe1d8 | 2017-10-13 13:21:37 +0800 | [diff] [blame] | 48 | } |
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 49 | } |
50 | } | ||||
Deepak Kodihalli | 20ed79e | 2017-07-25 05:48:58 -0500 | [diff] [blame] | 51 | } // namespace settings |