diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-11-02 21:48:57 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-11-27 15:05:24 +0000 |
commit | 84041e3c3dd00cc1e96f09bd574ddbac8b573c75 (patch) | |
tree | 591ac364b7ce212ebdb422c4dd5bbefaf1905d5d | |
parent | b9b3ed5e4347898bc0e969c1e7a3ca99261d4cc9 (diff) | |
download | phosphor-objmgr-84041e3c3dd00cc1e96f09bd574ddbac8b573c75.tar.gz phosphor-objmgr-84041e3c3dd00cc1e96f09bd574ddbac8b573c75.zip |
server: Delegate association signal logic
Avoid emitting org.freedesktop.DBus.Properties.Properties
changed signals on association objects prior to an
org.freedesktop.DBus.ObjectManager.Interfaces removed signal.
Do this by dropping the Association append, remove, and emit_signal
methods and move their logic to the mapper.
Change-Id: Ibff3d7e0eb47de3ea992394e2122d39407aaf64e
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r-- | obmc/mapper/server.py | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/obmc/mapper/server.py b/obmc/mapper/server.py index 03400d6..6e46fc0 100644 --- a/obmc/mapper/server.py +++ b/obmc/mapper/server.py @@ -188,22 +188,6 @@ class Association(dbus.service.Object): super(Association, self).__init__(conn=bus, object_path=path) self.properties = {self.iface: {'endpoints': endpoints}} - def emit_signal(self, old): - new = self.properties[self.iface]['endpoints'] - if old != new: - self.PropertiesChanged( - self.iface, self.properties[self.iface], ['endpoints']) - - def append(self, endpoints): - old = self.endpoints - self.endpoints = list(set(endpoints).union(self.endpoints)) - self.emit_signal(old) - - def remove(self, endpoints): - old = self.endpoints - self.endpoints = list(set(self.endpoints).difference(endpoints)) - self.emit_signal(old) - @dbus.service.method(dbus.PROPERTIES_IFACE, 'ss', 'as') def Get(self, interface_name, property_name): if property_name != 'endpoints': @@ -680,23 +664,26 @@ class ObjectMapper(dbus.service.Object): def update_association(self, path, removed, added): iface = obmc.dbuslib.enums.OBMC_ASSOC_IFACE assoc = self.manager.get(path, None) - create = [] if assoc else [iface] - if added and create: - self.manager.add( - path, Association(self.bus, path, added)) - assoc = self.manager.get(path) - elif added: - assoc.append(added) + old_endpoints = assoc.properties[iface]['endpoints'] if assoc else [] + new_endpoints = list( + set(old_endpoints).union(added).difference(removed)) + + if old_endpoints == new_endpoints: + return - if assoc and removed: - assoc.remove(removed) + create = [] if old_endpoints else [iface] + delete = [] if new_endpoints else [iface] - delete = [] - endpoints = assoc.properties[iface]['endpoints'] - if assoc and not endpoints: + if create: + self.manager.add( + path, Association(self.bus, path, new_endpoints)) + elif delete: self.manager.remove(path) - delete = [iface] + else: + assoc.properties[iface]['endpoints'] = new_endpoints + assoc.PropertiesChanged( + iface, {'endpoints': new_endpoints}, ['endpoints']) if create != delete: self.update_interfaces( |