Brad Bishop | 8ffe1e4 | 2016-02-11 16:15:40 -0500 | [diff] [blame^] | 1 | # 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 | |
| 17 | import dbus |
| 18 | |
| 19 | MAPPER_NAME = 'org.openbmc.objectmapper' |
| 20 | MAPPER_IFACE = MAPPER_NAME + '.ObjectMapper' |
| 21 | MAPPER_PATH = '/org/openbmc/objectmapper/objectmapper' |
| 22 | ENUMERATE_IFACE = 'org.openbmc.Object.Enumerate' |
| 23 | MAPPER_NOT_FOUND = 'org.openbmc.objectmapper.Error.NotFound' |
| 24 | |
| 25 | |
| 26 | class 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) |