Matt Spinler | bc99749 | 2018-03-27 11:24:45 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2018 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include <phosphor-logging/log.hpp> |
| 17 | #include "dbus.hpp" |
| 18 | |
| 19 | namespace ibm |
| 20 | { |
| 21 | namespace logging |
| 22 | { |
| 23 | |
Matt Spinler | 259e727 | 2018-03-29 10:57:17 -0500 | [diff] [blame^] | 24 | ObjectValueTree getManagedObjects(sdbusplus::bus::bus& bus, |
| 25 | const std::string& service, |
| 26 | const std::string& objPath) |
Matt Spinler | bc99749 | 2018-03-27 11:24:45 -0500 | [diff] [blame] | 27 | { |
| 28 | ObjectValueTree interfaces; |
| 29 | |
Matt Spinler | 259e727 | 2018-03-29 10:57:17 -0500 | [diff] [blame^] | 30 | auto method = bus.new_method_call(service.c_str(), objPath.c_str(), |
| 31 | "org.freedesktop.DBus.ObjectManager", |
| 32 | "GetManagedObjects"); |
Matt Spinler | bc99749 | 2018-03-27 11:24:45 -0500 | [diff] [blame] | 33 | |
| 34 | auto reply = bus.call(method); |
| 35 | |
| 36 | if (reply.is_method_error()) |
| 37 | { |
| 38 | using namespace phosphor::logging; |
| 39 | log<level::ERR>("Failed to get managed objects", |
Matt Spinler | 259e727 | 2018-03-29 10:57:17 -0500 | [diff] [blame^] | 40 | entry("PATH=%s", objPath.c_str())); |
Matt Spinler | bc99749 | 2018-03-27 11:24:45 -0500 | [diff] [blame] | 41 | } |
| 42 | else |
| 43 | { |
| 44 | reply.read(interfaces); |
| 45 | } |
| 46 | |
| 47 | return interfaces; |
| 48 | } |
Matt Spinler | bc99749 | 2018-03-27 11:24:45 -0500 | [diff] [blame] | 49 | } |
| 50 | } |