Merge "Allow OpenStackRelationAdapter to work with Endpoint-based interfaces"

This commit is contained in:
Zuul 2018-10-18 09:45:11 +00:00 committed by Gerrit Code Review
commit 78ce162e8c
1 changed files with 8 additions and 2 deletions

View File

@ -130,7 +130,10 @@ class OpenStackRelationAdapter(object):
Note that the accessor is dynamic as each access calls the underlying
getattr() for each property access.
"""
self.accessors.extend(self.relation.auto_accessors)
try:
self.accessors.extend(self.relation.auto_accessors)
except AttributeError:
self.accessors = []
for field in self.accessors:
meth_name = field.replace('-', '_')
# Get the relation property dynamically
@ -1107,7 +1110,10 @@ class OpenStackRelationAdapters(object):
:param relation: a RelationBase derived reactive relation
:returns (string, OpenstackRelationAdapter-derived): see above.
"""
relation_name = relation.relation_name.replace('-', '_')
try:
relation_name = relation.endpoint_name.replace('-', '_')
except AttributeError:
relation_name = relation.relation_name.replace('-', '_')
try:
adapter = self._adapters[relation_name](relation)
except KeyError: