[PATCH phosphor-objmgr 7/7] Add ObjectManager interfaces automatically
OpenBMC Patches
openbmc-patches at stwcx.xyz
Fri Apr 15 23:00:47 AEST 2016
From: Brad Bishop <bradleyb at us.ibm.com>
We don't get signals for the ObjectManager itself, so if one is
detected (from one of its signals) that we don't know about add
it to the cache.
---
phosphor-mapper | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/phosphor-mapper b/phosphor-mapper
index 77b0f7c..fa6bb60 100644
--- a/phosphor-mapper
+++ b/phosphor-mapper
@@ -116,12 +116,14 @@ class ObjectMapper(dbus.service.Object):
dbus_interface=
dbus.BUS_DAEMON_IFACE + '.ObjectManager',
signal_name='InterfacesAdded',
- sender_keyword='sender')
+ sender_keyword='sender',
+ path_keyword='sender_path')
self.bus.dbus.add_signal_receiver(
self.interfaces_removed_handler,
dbus_interface=dbus.BUS_DAEMON_IFACE + '.ObjectManager',
signal_name='InterfacesRemoved',
- sender_keyword='sender')
+ sender_keyword='sender',
+ path_keyword='sender_path')
self.bus.dbus.add_signal_receiver(
self.properties_changed_handler,
dbus_interface=dbus.PROPERTIES_IFACE,
@@ -137,9 +139,20 @@ class ObjectMapper(dbus.service.Object):
def discovery_pending(self):
return not bool(self.service)
+ def add_new_objmgr(self, path, owner):
+ # We don't get a signal for the ObjectManager
+ # interface itself, so if we see a signal from
+ # make sure its in our cache, and add it if not.
+ cache_entry = self.cache.get(path, {})
+ cache_entry = cache_entry if cache_entry is not None else {}
+ old = self.interfaces_get(cache_entry, owner)
+ new = list(set(old).union([dbus.BUS_DAEMON_IFACE + '.ObjectManager']))
+ self.update_interfaces(path, owner, old, new)
+
def interfaces_added_handler(self, path, iprops, **kw):
path = str(path)
owner = str(kw['sender'])
+ self.add_new_objmgr(str(kw['sender_path']), owner)
interfaces = self.get_signal_interfaces(owner, iprops.iterkeys())
cache_entry = self.cache.get(path, {})
old = self.interfaces_get(cache_entry, owner)
@@ -149,6 +162,7 @@ class ObjectMapper(dbus.service.Object):
def interfaces_removed_handler(self, path, interfaces, **kw):
path = str(path)
owner = str(kw['sender'])
+ self.add_new_objmgr(str(kw['sender_path']), owner)
interfaces = self.get_signal_interfaces(owner, interfaces)
cache_entry = self.cache.get(path, {})
old = self.interfaces_get(cache_entry, owner)
--
2.7.1
More information about the openbmc
mailing list