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