Ad function to get uris when a prefix is being used
This commit is contained in:
parent
ac3d716713
commit
8bfd5c8b13
@ -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,14 +98,21 @@ class DatabaseRelationAdapter(OpenStackRelationAdapter):
|
||||
def type(self):
|
||||
return 'mysql'
|
||||
|
||||
@property
|
||||
def uri(self):
|
||||
uri = 'mysql://{}:{}@{}/{}'.format(
|
||||
self.username,
|
||||
self.password,
|
||||
self.host,
|
||||
self.database,
|
||||
)
|
||||
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,
|
||||
self.host,
|
||||
self.database,
|
||||
)
|
||||
if self.ssl_ca:
|
||||
uri = '{}?ssl_ca={}'.format(uri, self.ssl_ca)
|
||||
if self.ssl_cert:
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user