Add support for rabbitmq use for ceilometer notifications

This commit is contained in:
James Page 2013-10-17 15:15:56 +01:00
parent c604ce5b45
commit b556319df4
8 changed files with 57 additions and 36 deletions

View File

@ -70,14 +70,12 @@ options:
ssl_key: ssl_key:
type: string type: string
description: SSL key to use with certificate specified as ssl_cert. description: SSL key to use with certificate specified as ssl_cert.
ceph-osd-replication-count: rabbit-user:
default: 2 default: glance
type: int type: string
description: | description: Username to request access on rabbitmq-server.
This value dictates the number of replicas ceph must make of any rabbit-vhost:
object it stores within the images rbd pool. Of course, this only default: glance
applies if using Ceph as a backend store. Note that once the images type: string
rbd pool has been created, changing this value will not have any description: RabbitMQ virtual host to request access on rabbitmq-server.
effect (although it can be changed in ceph by manually configuring
your ceph cluster).

1
hooks/amqp-relation-changed Symbolic link
View File

@ -0,0 +1 @@
glance_relations.py

1
hooks/amqp-relation-joined Symbolic link
View File

@ -0,0 +1 @@
glance_relations.py

View File

@ -313,8 +313,22 @@ def configure_https():
image_service_joined(relation_id=r_id) 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__': if __name__ == '__main__':
try: try:
hooks.execute(sys.argv) hooks.execute(sys.argv)
except UnregisteredHookError as e: except UnregisteredHookError as e:
juju_log('Unknown hook {} - skiping.'.format(e)) juju_log('Unknown hook {} - skipping.'.format(e))

View File

@ -66,6 +66,7 @@ CONFIG_FILES = OrderedDict([
}), }),
(GLANCE_API_CONF, { (GLANCE_API_CONF, {
'hook_contexts': [context.SharedDBContext(), 'hook_contexts': [context.SharedDBContext(),
context.AMQPContext(),
context.IdentityServiceContext(), context.IdentityServiceContext(),
glance_contexts.CephGlanceContext(), glance_contexts.CephGlanceContext(),
glance_contexts.ObjectStoreContext(), glance_contexts.ObjectStoreContext(),

View File

@ -14,6 +14,8 @@ provides:
requires: requires:
shared-db: shared-db:
interface: mysql-shared interface: mysql-shared
amqp:
interface: rabbitmq
object-store: object-store:
interface: swift-proxy interface: swift-proxy
identity-service: identity-service:

View File

@ -29,31 +29,15 @@ use_syslog = False
registry_host = 0.0.0.0 registry_host = 0.0.0.0
registry_port = 9191 registry_port = 9191
registry_client_protocol = http registry_client_protocol = http
notifier_strategy = noop
rabbit_host = localhost {% if rabbitmq_host -%}
rabbit_port = 5672 notifier_strategy = rabbit
rabbit_use_ssl = false rabbit_host = {{ rabbitmq_host }}
rabbit_userid = guest rabbit_userid = {{ rabbitmq_user }}
rabbit_password = guest rabbit_password = {{ rabbitmq_password }}
rabbit_virtual_host = / rabbit_virtual_host = {{ rabbitmq_virtual_host }}
rabbit_notification_exchange = glance {% endif -%}
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
filesystem_store_datadir = /var/lib/glance/images/ filesystem_store_datadir = /var/lib/glance/images/
{% if swift_store %} {% if swift_store %}

View File

@ -399,3 +399,23 @@ class GlanceRelationTests(CharmTestCase):
self.check_call.assert_called_with(cmd) self.check_call.assert_called_with(cmd)
image_service_joined.assert_called_with(relation_id='image-service:0') 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()