server: Remove Association.__getattr__
Refactor the Association class in preparation for inheriting
from obmc.dbuslib.DbusProperties.
- Remove the __getattr__ override and its usage. It does not
appear to be necessary.
- Store endpoints in an interface/properties dictionary named
properties in alignment with obmc.dbuslib.DbusProperties.
- Refactor methods to use properties dictionary rather than the
endpoints list.
Change-Id: I4b8befa0d2e69a9f2266fa2818e0f81ae4cdcf56
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/obmc/mapper/server.py b/obmc/mapper/server.py
index 8befd0e..03400d6 100644
--- a/obmc/mapper/server.py
+++ b/obmc/mapper/server.py
@@ -175,6 +175,8 @@
class Association(dbus.service.Object):
"""Implementation of org.openbmc.Association."""
+ iface = obmc.dbuslib.enums.OBMC_ASSOC_IFACE
+
def __init__(self, bus, path, endpoints):
"""Construct an Association.
@@ -184,20 +186,13 @@
endpoints -- A list of the initial association endpoints
"""
super(Association, self).__init__(conn=bus, object_path=path)
- self.endpoints = endpoints
-
- def __getattr__(self, name):
- if name == 'properties':
- return {
- obmc.dbuslib.enums.OBMC_ASSOC_IFACE: {
- 'endpoints': self.endpoints}}
- return super(Association, self).__getattr__(name)
+ self.properties = {self.iface: {'endpoints': endpoints}}
def emit_signal(self, old):
- if old != self.endpoints:
+ new = self.properties[self.iface]['endpoints']
+ if old != new:
self.PropertiesChanged(
- obmc.dbuslib.enums.OBMC_ASSOC_IFACE,
- {'endpoints': self.endpoints}, ['endpoints'])
+ self.iface, self.properties[self.iface], ['endpoints'])
def append(self, endpoints):
old = self.endpoints
@@ -698,7 +693,8 @@
assoc.remove(removed)
delete = []
- if assoc and not assoc.endpoints:
+ endpoints = assoc.properties[iface]['endpoints']
+ if assoc and not endpoints:
self.manager.remove(path)
delete = [iface]