diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-11-02 22:23:09 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-11-27 15:05:43 +0000 |
commit | c33ae65c829038c29a76070f22ab8feebd688c95 (patch) | |
tree | bc9028972c8e49e85de3e8e857f085b00001de76 | |
parent | 84041e3c3dd00cc1e96f09bd574ddbac8b573c75 (diff) | |
download | phosphor-objmgr-c33ae65c829038c29a76070f22ab8feebd688c95.tar.gz phosphor-objmgr-c33ae65c829038c29a76070f22ab8feebd688c95.zip |
server: Fix missing Association interface
Prior to this patch org.openbmc.Association is not included
in the introspection result. This prevents clients using
D-Bus language bindings that actually validate the interface
prior to attempt to read a property.
The custom org.freedesktop.Dbus.Properties implementation on
the Association class used the wrong signature for the Get
and GetAll methods, violating the D-Bus specification.
Fix this by using the implementation in the pyphosphor
dbus binding add-ons module.
The association interface does not have any methods or signals.
Without help, dbus-python won't find these interfaces when
using the Introspect implementation from dbus-python. Use the
new add_interfaces decorator in the pyphosphor dbus bindings
to help dbus-python find it and include it in the introspection
result.
Change-Id: I21fcd651e762c727a8d442ab6075ac7fa7e552d2
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r-- | obmc/mapper/server.py | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/obmc/mapper/server.py b/obmc/mapper/server.py index 6e46fc0..182cf2c 100644 --- a/obmc/mapper/server.py +++ b/obmc/mapper/server.py @@ -172,7 +172,8 @@ def find_dbus_interfaces(conn, service, path, callback, error_callback, **kw): return _FindInterfaces()(path) -class Association(dbus.service.Object): +@obmc.dbuslib.bindings.add_interfaces([obmc.dbuslib.enums.OBMC_ASSOC_IFACE]) +class Association(obmc.dbuslib.bindings.DbusProperties): """Implementation of org.openbmc.Association.""" iface = obmc.dbuslib.enums.OBMC_ASSOC_IFACE @@ -188,24 +189,6 @@ class Association(dbus.service.Object): super(Association, self).__init__(conn=bus, object_path=path) self.properties = {self.iface: {'endpoints': endpoints}} - @dbus.service.method(dbus.PROPERTIES_IFACE, 'ss', 'as') - def Get(self, interface_name, property_name): - if property_name != 'endpoints': - raise dbus.exceptions.DBusException(name=DBUS_UNKNOWN_PROPERTY) - return self.GetAll(interface_name)[property_name] - - @dbus.service.method(dbus.PROPERTIES_IFACE, 's', 'a{sas}') - def GetAll(self, interface_name): - if interface_name != obmc.dbuslib.enums.OBMC_ASSOC_IFACE: - raise dbus.exceptions.DBusException(DBUS_UNKNOWN_INTERFACE) - return {'endpoints': self.endpoints} - - @dbus.service.signal( - dbus.PROPERTIES_IFACE, signature='sa{sas}as') - def PropertiesChanged( - self, interface_name, changed_properties, invalidated_properties): - pass - class Manager(obmc.dbuslib.bindings.DbusObjectManager): def __init__(self, bus, path): @@ -665,7 +648,7 @@ class ObjectMapper(dbus.service.Object): iface = obmc.dbuslib.enums.OBMC_ASSOC_IFACE assoc = self.manager.get(path, None) - old_endpoints = assoc.properties[iface]['endpoints'] if assoc else [] + old_endpoints = assoc.Get(iface, 'endpoints') if assoc else [] new_endpoints = list( set(old_endpoints).union(added).difference(removed)) @@ -681,9 +664,7 @@ class ObjectMapper(dbus.service.Object): elif delete: self.manager.remove(path) else: - assoc.properties[iface]['endpoints'] = new_endpoints - assoc.PropertiesChanged( - iface, {'endpoints': new_endpoints}, ['endpoints']) + assoc.Set(iface, 'endpoints', new_endpoints) if create != delete: self.update_interfaces( |