xref: /openbmc/ibm-logging/dbus.cpp (revision bc997490)
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 
24 ObjectValueTree getManagedObjects(
25         sdbusplus::bus::bus& bus,
26         const std::string& service,
27         const std::string& objPath)
28 {
29     ObjectValueTree interfaces;
30 
31     auto method = bus.new_method_call(
32                       service.c_str(),
33                       objPath.c_str(),
34                       "org.freedesktop.DBus.ObjectManager",
35                       "GetManagedObjects");
36 
37     auto reply = bus.call(method);
38 
39     if (reply.is_method_error())
40     {
41         using namespace phosphor::logging;
42         log<level::ERR>("Failed to get managed objects",
43                 entry("PATH=%s", objPath.c_str()));
44     }
45     else
46     {
47         reply.read(interfaces);
48     }
49 
50     return interfaces;
51 }
52 
53 }
54 }
55