blob: 3f9df5de8c69cc5ece44b58980887131da7397a8 [file] [log] [blame]
Brad Bishop8ffe1e42016-02-11 16:15:40 -05001# Contributors Listed Below - COPYRIGHT 2016
2# [+] International Business Machines Corp.
3#
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14# implied. See the License for the specific language governing
15# permissions and limitations under the License.
16
17import dbus
18
19MAPPER_NAME = 'org.openbmc.objectmapper'
20MAPPER_IFACE = MAPPER_NAME + '.ObjectMapper'
21MAPPER_PATH = '/org/openbmc/objectmapper/objectmapper'
22ENUMERATE_IFACE = 'org.openbmc.Object.Enumerate'
23MAPPER_NOT_FOUND = 'org.openbmc.objectmapper.Error.NotFound'
24
25
26class Mapper:
27 def __init__(self, bus):
28 self.bus = bus
29 obj = bus.get_object(MAPPER_NAME, MAPPER_PATH, introspect=False)
30 self.iface = dbus.Interface(
31 obj, dbus_interface=MAPPER_IFACE)
32
33 def get_object(self, path):
34 return self.iface.GetObject(path)
35
36 def get_subtree_paths(self, path='/', depth=0):
37 return self.iface.GetSubTreePaths(path, depth)
38
39 def get_subtree(self, path='/', depth=0):
40 return self.iface.GetSubTree(path, depth)
41
42 def get_ancestors(self, path):
43 return self.iface.GetAncestors(path)