Merge lp:~openstack-charmers/charms/precise/cinder/ceilometer-support into lp:charms/raring/cinder

Proposed by James Page
Status: Merged
Merged at revision: 26
Proposed branch: lp:~openstack-charmers/charms/precise/cinder/ceilometer-support
Merge into: lp:charms/raring/cinder
Diff against target: 97 lines (+35/-4)
4 files modified
config.yaml (+1/-1)
hooks/cinder_hooks.py (+9/-2)
templates/cinder.conf (+2/-0)
unit_tests/test_cinder_hooks.py (+23/-1)
To merge this branch: bzr merge lp:~openstack-charmers/charms/precise/cinder/ceilometer-support
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Review via email: mp+192271@code.launchpad.net

Description of the change

Updates to support use of OpenStack with Ceilometer.

Ceilometer requires use of a common RabbitMQ vhost for all services so it can subscribed to notifications from other services about events happening in OpenStack.

This change switches the default vhost to cinder to 'openstack' and re-executes the amqp_joined hook on upgrade to refresh the access in rabbitmq-server

To post a comment you must log in.
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM +1, passes tests.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2013-10-17 21:48:08 +0000
+++ config.yaml 2013-10-23 00:51:05 +0000
@@ -61,7 +61,7 @@
61 type: string61 type: string
62 description: Username to request access on rabbitmq-server.62 description: Username to request access on rabbitmq-server.
63 rabbit-vhost:63 rabbit-vhost:
64 default: cinder64 default: openstack
65 type: string65 type: string
66 description: RabbitMQ virtual host to request access on rabbitmq-server.66 description: RabbitMQ virtual host to request access on rabbitmq-server.
67 api-listening-port:67 api-listening-port:
6868
=== modified file 'hooks/cinder_hooks.py'
--- hooks/cinder_hooks.py 2013-10-19 16:58:37 +0000
+++ hooks/cinder_hooks.py 2013-10-23 00:51:05 +0000
@@ -108,9 +108,10 @@
108108
109109
110@hooks.hook('amqp-relation-joined')110@hooks.hook('amqp-relation-joined')
111def amqp_joined():111def amqp_joined(relation_id=None):
112 conf = config()112 conf = config()
113 relation_set(username=conf['rabbit-user'], vhost=conf['rabbit-vhost'])113 relation_set(relation_id=relation_id,
114 username=conf['rabbit-user'], vhost=conf['rabbit-vhost'])
114115
115116
116@hooks.hook('amqp-relation-changed')117@hooks.hook('amqp-relation-changed')
@@ -265,6 +266,12 @@
265 identity_joined(rid=rid)266 identity_joined(rid=rid)
266267
267268
269@hooks.hook('upgrade-charm')
270def upgrade_charm():
271 for rel_id in relation_ids('amqp'):
272 amqp_joined(relation_id=rel_id)
273
274
268if __name__ == '__main__':275if __name__ == '__main__':
269 try:276 try:
270 hooks.execute(sys.argv)277 hooks.execute(sys.argv)
271278
=== modified file 'templates/cinder.conf'
--- templates/cinder.conf 2013-10-17 21:48:08 +0000
+++ templates/cinder.conf 2013-10-23 00:51:05 +0000
@@ -18,6 +18,8 @@
18sql_connection = mysql://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }}18sql_connection = mysql://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }}
19{% endif -%}19{% endif -%}
20{% if rabbitmq_host -%}20{% if rabbitmq_host -%}
21notification_driver = cinder.openstack.common.notifier.rabbit_notifier
22control_exchange = cinder
21rabbit_host = {{ rabbitmq_host }}23rabbit_host = {{ rabbitmq_host }}
22rabbit_userid = {{ rabbitmq_user }}24rabbit_userid = {{ rabbitmq_user }}
23rabbit_password = {{ rabbitmq_password }}25rabbit_password = {{ rabbitmq_password }}
2426
=== modified file 'unit_tests/test_cinder_hooks.py'
--- unit_tests/test_cinder_hooks.py 2013-10-20 18:31:12 +0000
+++ unit_tests/test_cinder_hooks.py 2013-10-23 00:51:05 +0000
@@ -126,6 +126,18 @@
126 super(TestChangedHooks, self).setUp(hooks, TO_PATCH)126 super(TestChangedHooks, self).setUp(hooks, TO_PATCH)
127 self.config.side_effect = self.test_config.get_all127 self.config.side_effect = self.test_config.get_all
128128
129 @patch.object(hooks, 'amqp_joined')
130 def test_upgrade_charm_no_amqp(self, _joined):
131 self.relation_ids.return_value = []
132 hooks.hooks.execute(['hooks/upgrade-charm'])
133 _joined.assert_not_called()
134
135 @patch.object(hooks, 'amqp_joined')
136 def test_upgrade_charm_with_amqp(self, _joined):
137 self.relation_ids.return_value = ['amqp:1']
138 hooks.hooks.execute(['hooks/upgrade-charm'])
139 _joined.assert_called_with(relation_id='amqp:1')
140
129 @patch.object(hooks, 'configure_https')141 @patch.object(hooks, 'configure_https')
130 def test_config_changed(self, conf_https):142 def test_config_changed(self, conf_https):
131 '''It writes out all config'''143 '''It writes out all config'''
@@ -234,7 +246,17 @@
234 def test_amqp_joined(self):246 def test_amqp_joined(self):
235 '''It properly requests access to an amqp service'''247 '''It properly requests access to an amqp service'''
236 hooks.hooks.execute(['hooks/amqp-relation-joined'])248 hooks.hooks.execute(['hooks/amqp-relation-joined'])
237 self.relation_set.assert_called_with(username='cinder', vhost='cinder')249 self.relation_set.assert_called_with(username='cinder',
250 vhost='openstack',
251 relation_id=None)
252
253 def test_amqp_joined_passes_relation_id(self):
254 ''' Ensures relation_id correct passed to relation_set for out of
255 hook execution '''
256 hooks.amqp_joined(relation_id='amqp:1')
257 self.relation_set.assert_called_with(username='cinder',
258 vhost='openstack',
259 relation_id='amqp:1')
238260
239 def test_identity_service_joined(self):261 def test_identity_service_joined(self):
240 '''It properly requests unclustered endpoint via identity-service'''262 '''It properly requests unclustered endpoint via identity-service'''

Subscribers

People subscribed via source and target branches