Ad function to get uris when a prefix is being used

This commit is contained in:
Liam Young 2016-01-14 15:25:37 +00:00
parent ac3d716713
commit 8bfd5c8b13

View File

@ -78,7 +78,7 @@ class RabbitMQRelationAdapter(OpenStackRelationAdapter):
class DatabaseRelationAdapter(OpenStackRelationAdapter):
"""
Adapter for the RabbitMQRequires relation interface.
Adapter for the Database relation interface.
"""
interface_type = "database"
@ -98,8 +98,15 @@ class DatabaseRelationAdapter(OpenStackRelationAdapter):
def type(self):
return 'mysql'
@property
def uri(self):
def get_uri(self, prefix=None):
if prefix:
uri = 'mysql://{}:{}@{}/{}'.format(
self.relation.username(prefix=prefix),
self.relation.password(prefix=prefix),
self.host,
self.relation.database(prefix=prefix),
)
else:
uri = 'mysql://{}:{}@{}/{}'.format(
self.username,
self.password,
@ -114,6 +121,12 @@ class DatabaseRelationAdapter(OpenStackRelationAdapter):
return uri
@property
def uri(self):
return self.get_uri()
class ConfigurationAdapter(object):
"""
Configuration Adapter which provides python based access