Add support for rabbitmq use for ceilometer notifications
This commit is contained in:
parent
c604ce5b45
commit
b556319df4
18
config.yaml
18
config.yaml
@ -70,14 +70,12 @@ options:
|
||||
ssl_key:
|
||||
type: string
|
||||
description: SSL key to use with certificate specified as ssl_cert.
|
||||
ceph-osd-replication-count:
|
||||
default: 2
|
||||
type: int
|
||||
description: |
|
||||
This value dictates the number of replicas ceph must make of any
|
||||
object it stores within the images rbd pool. Of course, this only
|
||||
applies if using Ceph as a backend store. Note that once the images
|
||||
rbd pool has been created, changing this value will not have any
|
||||
effect (although it can be changed in ceph by manually configuring
|
||||
your ceph cluster).
|
||||
rabbit-user:
|
||||
default: glance
|
||||
type: string
|
||||
description: Username to request access on rabbitmq-server.
|
||||
rabbit-vhost:
|
||||
default: glance
|
||||
type: string
|
||||
description: RabbitMQ virtual host to request access on rabbitmq-server.
|
||||
|
||||
|
1
hooks/amqp-relation-changed
Symbolic link
1
hooks/amqp-relation-changed
Symbolic link
@ -0,0 +1 @@
|
||||
glance_relations.py
|
1
hooks/amqp-relation-joined
Symbolic link
1
hooks/amqp-relation-joined
Symbolic link
@ -0,0 +1 @@
|
||||
glance_relations.py
|
@ -313,8 +313,22 @@ def configure_https():
|
||||
image_service_joined(relation_id=r_id)
|
||||
|
||||
|
||||
@hooks.hook('amqp-relation-joined')
|
||||
def amqp_joined():
|
||||
conf = config()
|
||||
relation_set(username=conf['rabbit-user'], vhost=conf['rabbit-vhost'])
|
||||
|
||||
|
||||
@hooks.hook('amqp-relation-changed')
|
||||
@restart_on_change(restart_map())
|
||||
def amqp_changed():
|
||||
if 'amqp' not in CONFIGS.complete_contexts():
|
||||
juju_log('amqp relation incomplete. Peer not ready?')
|
||||
return
|
||||
CONFIGS.write(GLANCE_API_CONF)
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
hooks.execute(sys.argv)
|
||||
except UnregisteredHookError as e:
|
||||
juju_log('Unknown hook {} - skiping.'.format(e))
|
||||
juju_log('Unknown hook {} - skipping.'.format(e))
|
||||
|
@ -66,6 +66,7 @@ CONFIG_FILES = OrderedDict([
|
||||
}),
|
||||
(GLANCE_API_CONF, {
|
||||
'hook_contexts': [context.SharedDBContext(),
|
||||
context.AMQPContext(),
|
||||
context.IdentityServiceContext(),
|
||||
glance_contexts.CephGlanceContext(),
|
||||
glance_contexts.ObjectStoreContext(),
|
||||
|
@ -14,6 +14,8 @@ provides:
|
||||
requires:
|
||||
shared-db:
|
||||
interface: mysql-shared
|
||||
amqp:
|
||||
interface: rabbitmq
|
||||
object-store:
|
||||
interface: swift-proxy
|
||||
identity-service:
|
||||
|
@ -29,31 +29,15 @@ use_syslog = False
|
||||
registry_host = 0.0.0.0
|
||||
registry_port = 9191
|
||||
registry_client_protocol = http
|
||||
notifier_strategy = noop
|
||||
rabbit_host = localhost
|
||||
rabbit_port = 5672
|
||||
rabbit_use_ssl = false
|
||||
rabbit_userid = guest
|
||||
rabbit_password = guest
|
||||
rabbit_virtual_host = /
|
||||
rabbit_notification_exchange = glance
|
||||
rabbit_notification_topic = glance_notifications
|
||||
rabbit_durable_queues = False
|
||||
qpid_notification_exchange = glance
|
||||
qpid_notification_topic = glance_notifications
|
||||
qpid_host = localhost
|
||||
qpid_port = 5672
|
||||
qpid_username =
|
||||
qpid_password =
|
||||
qpid_sasl_mechanisms =
|
||||
qpid_reconnect_timeout = 0
|
||||
qpid_reconnect_limit = 0
|
||||
qpid_reconnect_interval_min = 0
|
||||
qpid_reconnect_interval_max = 0
|
||||
qpid_reconnect_interval = 0
|
||||
qpid_heartbeat = 5
|
||||
qpid_protocol = tcp
|
||||
qpid_tcp_nodelay = True
|
||||
|
||||
{% if rabbitmq_host -%}
|
||||
notifier_strategy = rabbit
|
||||
rabbit_host = {{ rabbitmq_host }}
|
||||
rabbit_userid = {{ rabbitmq_user }}
|
||||
rabbit_password = {{ rabbitmq_password }}
|
||||
rabbit_virtual_host = {{ rabbitmq_virtual_host }}
|
||||
{% endif -%}
|
||||
|
||||
filesystem_store_datadir = /var/lib/glance/images/
|
||||
|
||||
{% if swift_store %}
|
||||
|
@ -399,3 +399,23 @@ class GlanceRelationTests(CharmTestCase):
|
||||
self.check_call.assert_called_with(cmd)
|
||||
image_service_joined.assert_called_with(relation_id='image-service:0')
|
||||
|
||||
def test_amqp_joined(self):
|
||||
relations.amqp_joined()
|
||||
self.relation_set.assert_called_with(username='glance', vhost='glance')
|
||||
|
||||
@patch.object(relations, 'CONFIGS')
|
||||
def test_amqp_changed_missing_relation_data(self, configs):
|
||||
configs.complete_contexts = MagicMock()
|
||||
configs.complete_contexts.return_value = []
|
||||
relations.amqp_changed()
|
||||
self.juju_log.assert_called()
|
||||
|
||||
@patch.object(relations, 'CONFIGS')
|
||||
def test_amqp_changed_relation_data(self, configs):
|
||||
configs.complete_contexts = MagicMock()
|
||||
configs.complete_contexts.return_value = ['amqp']
|
||||
configs.write = MagicMock()
|
||||
relations.amqp_changed()
|
||||
self.assertEquals([call('/etc/glance/glance-api.conf')],
|
||||
configs.write.call_args_list)
|
||||
self.juju_log.assert_called()
|
||||
|
Loading…
x
Reference in New Issue
Block a user