server: refactor valid_signal
Change the method name to bus_normalize to more accurately reflect what
it does, which is normalize unique and well-known bus names to a
well-known name.
Provide the normalized name to callers.
Fix-up call sites with the new name.
Tested: Manually verified mapper content is the same for a test object
after adding and removing interfaces from the test object, after new
service discovery and after bus name owner loss.
Change-Id: I4bc194b3d5537eadf3e6b0a874fe72caaf615372
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/obmc/mapper/server.py b/obmc/mapper/server.py
index 3837a17..e11f0fe 100644
--- a/obmc/mapper/server.py
+++ b/obmc/mapper/server.py
@@ -390,7 +390,7 @@
def bus_handler(self, owned_name, old, new):
valid = False
if not obmc.dbuslib.bindings.is_unique(owned_name):
- valid = self.valid_signal(owned_name)
+ valid = self.bus_normalize(owned_name)
if valid and new:
self.process_new_owner(owned_name, new)
@@ -480,7 +480,7 @@
owners = list(
filter(bool, [get_owner(name) for name in owned_names]))
for owned_name, o in owners:
- if not self.valid_signal(owned_name):
+ if not self.bus_normalize(owned_name):
continue
self.bus_map[o] = owned_name
self.defer_signals[o] = []
@@ -491,15 +491,23 @@
subtree_match=self.path_match,
iface_match=self.interface_match)
- def valid_signal(self, name):
+ def bus_normalize(self, name):
+ '''
+ Normalize on well-known names and filter signals
+ originating from the mapper.
+ '''
+
if obmc.dbuslib.bindings.is_unique(name):
name = self.bus_map.get(name)
- return name is not None and name != obmc.mapper.MAPPER_NAME
+ if name == obmc.mapper.MAPPER_NAME:
+ return None
+
+ return name
def get_signal_interfaces(self, owner, interfaces):
filtered = []
- if self.valid_signal(owner):
+ if self.bus_normalize(owner):
filtered = [str(x) for x in interfaces if self.interface_match(x)]
return filtered