Allow OpenStackRelationAdapter to work with Endpoint-based interfaces

Change-Id: I9d52243ab0ccc60eade6c8023d9c5831a1637338
Closes-Bug: #1798335
This commit is contained in:
Frode Nordahl 2018-10-17 12:28:37 +02:00
parent ad407c9912
commit 39fc35b68d
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
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 Note that the accessor is dynamic as each access calls the underlying
getattr() for each property access. 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: for field in self.accessors:
meth_name = field.replace('-', '_') meth_name = field.replace('-', '_')
# Get the relation property dynamically # Get the relation property dynamically
@ -1107,7 +1110,10 @@ class OpenStackRelationAdapters(object):
:param relation: a RelationBase derived reactive relation :param relation: a RelationBase derived reactive relation
:returns (string, OpenstackRelationAdapter-derived): see above. :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: try:
adapter = self._adapters[relation_name](relation) adapter = self._adapters[relation_name](relation)
except KeyError: except KeyError: