Allow control of signal generation
Typically ObjectManager signals should remain masked
until a service has grabbed a well-known bus name to
avoid pointless dbus signal generation.
Change-Id: I26703ec7a8b946128fe5aa8ed1c830a2e8f23c21
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/obmc/dbuslib/bindings.py b/obmc/dbuslib/bindings.py
index 3dec5af..bced585 100644
--- a/obmc/dbuslib/bindings.py
+++ b/obmc/dbuslib/bindings.py
@@ -45,6 +45,19 @@
dbus.service.Object.__init__(self)
self.properties = {}
self.object_path = ""
+ self._export = False
+
+ def unmask_signals(self):
+ self._export = True
+ inst = super(DbusProperties, self)
+ if hasattr(inst, 'unmask_signals'):
+ inst.unmask_signals()
+
+ def mask_signals(self):
+ self._export = False
+ inst = super(DbusProperties, self)
+ if hasattr(inst, 'mask_signals'):
+ inst.mask_signals()
@dbus.service.method(
dbus.PROPERTIES_IFACE,
@@ -79,13 +92,15 @@
old_value = self.properties[interface_name][property_name]
if (old_value != new_value):
self.properties[interface_name][property_name] = new_value
- self.PropertiesChanged(
- interface_name, {property_name: new_value}, [])
+ if self._export:
+ self.PropertiesChanged(
+ interface_name, {property_name: new_value}, [])
except:
self.properties[interface_name][property_name] = new_value
- self.PropertiesChanged(
- interface_name, {property_name: new_value}, [])
+ if self._export:
+ self.PropertiesChanged(
+ interface_name, {property_name: new_value}, [])
@dbus.service.method(
"org.openbmc.Object.Properties", in_signature='sa{sv}')
@@ -105,7 +120,7 @@
except:
self.properties[interface_name][property_name] = new_value
value_changed = True
- if (value_changed is True):
+ if (value_changed is True and self._export):
self.PropertiesChanged(interface_name, prop_dict, [])
@dbus.service.signal(
@@ -119,15 +134,30 @@
def __init__(self):
dbus.service.Object.__init__(self)
self.objects = {}
+ self._export = False
+
+ def unmask_signals(self):
+ self._export = True
+ inst = super(DbusObjectManager, self)
+ if hasattr(inst, 'unmask_signals'):
+ inst.unmask_signals()
+
+ def mask_signals(self):
+ self._export = False
+ inst = super(DbusObjectManager, self)
+ if hasattr(inst, 'mask_signals'):
+ inst.mask_signals()
def add(self, object_path, obj):
self.objects[object_path] = obj
- self.InterfacesAdded(object_path, obj.properties)
+ if self._export:
+ self.InterfacesAdded(object_path, obj.properties)
def remove(self, object_path):
obj = self.objects.pop(object_path, None)
obj.remove_from_connection()
- self.InterfacesRemoved(object_path, obj.properties.keys())
+ if self._export:
+ self.InterfacesRemoved(object_path, obj.properties.keys())
def get(self, object_path, default=None):
return self.objects.get(object_path, default)