blob: 17ad21064a79e9db916fbcde04c9cd8ff7666ebe [file] [log] [blame]
Matt Spinlerbc997492018-03-27 11:24:45 -05001/**
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
19namespace ibm
20{
21namespace logging
22{
23
Matt Spinler259e7272018-03-29 10:57:17 -050024ObjectValueTree getManagedObjects(sdbusplus::bus::bus& bus,
25 const std::string& service,
26 const std::string& objPath)
Matt Spinlerbc997492018-03-27 11:24:45 -050027{
28 ObjectValueTree interfaces;
29
Matt Spinler259e7272018-03-29 10:57:17 -050030 auto method = bus.new_method_call(service.c_str(), objPath.c_str(),
31 "org.freedesktop.DBus.ObjectManager",
32 "GetManagedObjects");
Matt Spinlerbc997492018-03-27 11:24:45 -050033
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 Spinler259e7272018-03-29 10:57:17 -050040 entry("PATH=%s", objPath.c_str()));
Matt Spinlerbc997492018-03-27 11:24:45 -050041 }
42 else
43 {
44 reply.read(interfaces);
45 }
46
47 return interfaces;
48}
Matt Spinlerbc997492018-03-27 11:24:45 -050049}
50}