fixes
This commit is contained in:
parent
48383f6c18
commit
909bd71fb5
|
@ -13,8 +13,12 @@ class OpenStackRelationAdapter(object):
|
||||||
The generic type of the interface the adapter is wrapping.
|
The generic type of the interface the adapter is wrapping.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, relation):
|
def __init__(self, relation, accessors=None):
|
||||||
self.relation = relation
|
self.relation = relation
|
||||||
|
if accessors:
|
||||||
|
self.accessors = accessors
|
||||||
|
else:
|
||||||
|
self.accessors = []
|
||||||
self._setup_properties()
|
self._setup_properties()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -29,7 +33,8 @@ class OpenStackRelationAdapter(object):
|
||||||
Setup property based accessors for an interfaces
|
Setup property based accessors for an interfaces
|
||||||
auto accessors
|
auto accessors
|
||||||
"""
|
"""
|
||||||
for field in self.relation.auto_accessors:
|
self.accessors.extend(self.relation.auto_accessors)
|
||||||
|
for field in self.accessors:
|
||||||
meth_name = field.replace('-', '_')
|
meth_name = field.replace('-', '_')
|
||||||
# TODO: see if we can make this dynamic, rather
|
# TODO: see if we can make this dynamic, rather
|
||||||
# than making all calls on setup.
|
# than making all calls on setup.
|
||||||
|
@ -44,6 +49,10 @@ class RabbitMQRelationAdapter(OpenStackRelationAdapter):
|
||||||
|
|
||||||
interface_type = "messaging"
|
interface_type = "messaging"
|
||||||
|
|
||||||
|
def __init__(self, relation):
|
||||||
|
add_accessors = ['vhost', 'username']
|
||||||
|
super(RabbitMQRelationAdapter,self).__init__(relation, add_accessors)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self):
|
def host(self):
|
||||||
"""
|
"""
|
||||||
|
@ -66,13 +75,29 @@ class RabbitMQRelationAdapter(OpenStackRelationAdapter):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def vhost(self):
|
class DatabaseRelationAdapter(OpenStackRelationAdapter):
|
||||||
return self.relation.vhost()
|
"""
|
||||||
|
Adapter for the RabbitMQRequires relation interface.
|
||||||
|
"""
|
||||||
|
|
||||||
|
interface_type = "database"
|
||||||
|
|
||||||
|
def __init__(self, relation):
|
||||||
|
add_accessors = ['password', 'username', 'database']
|
||||||
|
super(DatabaseRelationAdapter,self).__init__(relation, add_accessors)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def username(self):
|
def host(self):
|
||||||
return self.relation.username()
|
"""
|
||||||
|
Hostname that should be used to access RabbitMQ.
|
||||||
|
"""
|
||||||
|
return self.relation.db_host()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self):
|
||||||
|
return 'mysql'
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationAdapter(object):
|
class ConfigurationAdapter(object):
|
||||||
"""
|
"""
|
||||||
|
@ -109,6 +134,7 @@ class OpenStackRelationAdapters(object):
|
||||||
|
|
||||||
_adapters = {
|
_adapters = {
|
||||||
'amqp': RabbitMQRelationAdapter,
|
'amqp': RabbitMQRelationAdapter,
|
||||||
|
'shared_db': DatabaseRelationAdapter,
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
Default adapter mappings; may be overridden by relation adapters
|
Default adapter mappings; may be overridden by relation adapters
|
||||||
|
@ -119,7 +145,7 @@ class OpenStackRelationAdapters(object):
|
||||||
self._adapters.update(self.relation_adapters)
|
self._adapters.update(self.relation_adapters)
|
||||||
self._relations = []
|
self._relations = []
|
||||||
for relation in relations:
|
for relation in relations:
|
||||||
relation_name = relation.relation_name
|
relation_name = relation.relation_name.replace('-', '_')
|
||||||
if relation_name in self._adapters:
|
if relation_name in self._adapters:
|
||||||
self.__dict__[relation_name] = (
|
self.__dict__[relation_name] = (
|
||||||
self._adapters[relation_name](relation)
|
self._adapters[relation_name](relation)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{% if shared_db.host -%}
|
||||||
|
[database]
|
||||||
|
|
||||||
|
connection = {{ shared_db.type }}://{{ shared_db.username }}:{{ shared_db.password }}@{{ shared_db.host }}/{{ shared_db.database }}{% if database_ssl_ca %}?ssl_ca={{ database_ssl_ca }}{% if database_ssl_cert %}&ssl_cert={{ database_ssl_cert }}&ssl_key={{ database_ssl_key }}{% endif %}{% endif %}
|
||||||
|
{% endif -%}
|
|
@ -0,0 +1,22 @@
|
||||||
|
{% if amqp.host or amqp.hosts -%}
|
||||||
|
[oslo_messaging_rabbit]
|
||||||
|
rabbit_userid = {{ amqp.username }}
|
||||||
|
rabbit_virtual_host = {{ amqp.vhost }}
|
||||||
|
rabbit_password = {{ amqp.password }}
|
||||||
|
{% if amqp.hosts -%}
|
||||||
|
rabbit_hosts = {{ amqp.hosts }}
|
||||||
|
{% if amqp.ha_queues -%}
|
||||||
|
rabbit_ha_queues = True
|
||||||
|
rabbit_durable_queues = False
|
||||||
|
{% endif -%}
|
||||||
|
{% else -%}
|
||||||
|
rabbit_host = {{ amqp.host }}
|
||||||
|
{% endif -%}
|
||||||
|
{% if amqp.ssl_data_complete == True -%}
|
||||||
|
rabbit_use_ssl = True
|
||||||
|
rabbit_port = {{ amqp.ssl_port }}
|
||||||
|
{% if amqp.ssl_ca -%}
|
||||||
|
kombu_ssl_ca_certs = {{ amqp.ssl_ca }}
|
||||||
|
{% endif -%}
|
||||||
|
{% endif -%}
|
||||||
|
{% endif -%}
|
|
@ -1,4 +0,0 @@
|
||||||
{% if database_host -%}
|
|
||||||
[database]
|
|
||||||
connection = {{ database_type }}://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }}{% if database_ssl_ca %}?ssl_ca={{ database_ssl_ca }}{% if database_ssl_cert %}&ssl_cert={{ database_ssl_cert }}&ssl_key={{ database_ssl_key }}{% endif %}{% endif %}
|
|
||||||
{% endif -%}
|
|
|
@ -1,22 +0,0 @@
|
||||||
{% if rabbitmq_host or rabbitmq_hosts -%}
|
|
||||||
[oslo_messaging_rabbit]
|
|
||||||
rabbit_userid = {{ rabbitmq_user }}
|
|
||||||
rabbit_virtual_host = {{ rabbitmq_virtual_host }}
|
|
||||||
rabbit_password = {{ rabbitmq_password }}
|
|
||||||
{% if rabbitmq_hosts -%}
|
|
||||||
rabbit_hosts = {{ rabbitmq_hosts }}
|
|
||||||
{% if rabbitmq_ha_queues -%}
|
|
||||||
rabbit_ha_queues = True
|
|
||||||
rabbit_durable_queues = False
|
|
||||||
{% endif -%}
|
|
||||||
{% else -%}
|
|
||||||
rabbit_host = {{ rabbitmq_host }}
|
|
||||||
{% endif -%}
|
|
||||||
{% if rabbit_ssl_port -%}
|
|
||||||
rabbit_use_ssl = True
|
|
||||||
rabbit_port = {{ rabbit_ssl_port }}
|
|
||||||
{% if rabbit_ssl_ca -%}
|
|
||||||
kombu_ssl_ca_certs = {{ rabbit_ssl_ca }}
|
|
||||||
{% endif -%}
|
|
||||||
{% endif -%}
|
|
||||||
{% endif -%}
|
|
Loading…
Reference in New Issue