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