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
1=== modified file 'config.yaml'
2--- config.yaml 2013-10-17 21:48:08 +0000
3+++ config.yaml 2013-10-23 00:51:05 +0000
4@@ -61,7 +61,7 @@
5 type: string
6 description: Username to request access on rabbitmq-server.
7 rabbit-vhost:
8- default: cinder
9+ default: openstack
10 type: string
11 description: RabbitMQ virtual host to request access on rabbitmq-server.
12 api-listening-port:
13
14=== modified file 'hooks/cinder_hooks.py'
15--- hooks/cinder_hooks.py 2013-10-19 16:58:37 +0000
16+++ hooks/cinder_hooks.py 2013-10-23 00:51:05 +0000
17@@ -108,9 +108,10 @@
18
19
20 @hooks.hook('amqp-relation-joined')
21-def amqp_joined():
22+def amqp_joined(relation_id=None):
23 conf = config()
24- relation_set(username=conf['rabbit-user'], vhost=conf['rabbit-vhost'])
25+ relation_set(relation_id=relation_id,
26+ username=conf['rabbit-user'], vhost=conf['rabbit-vhost'])
27
28
29 @hooks.hook('amqp-relation-changed')
30@@ -265,6 +266,12 @@
31 identity_joined(rid=rid)
32
33
34+@hooks.hook('upgrade-charm')
35+def upgrade_charm():
36+ for rel_id in relation_ids('amqp'):
37+ amqp_joined(relation_id=rel_id)
38+
39+
40 if __name__ == '__main__':
41 try:
42 hooks.execute(sys.argv)
43
44=== modified file 'templates/cinder.conf'
45--- templates/cinder.conf 2013-10-17 21:48:08 +0000
46+++ templates/cinder.conf 2013-10-23 00:51:05 +0000
47@@ -18,6 +18,8 @@
48 sql_connection = mysql://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }}
49 {% endif -%}
50 {% if rabbitmq_host -%}
51+notification_driver = cinder.openstack.common.notifier.rabbit_notifier
52+control_exchange = cinder
53 rabbit_host = {{ rabbitmq_host }}
54 rabbit_userid = {{ rabbitmq_user }}
55 rabbit_password = {{ rabbitmq_password }}
56
57=== modified file 'unit_tests/test_cinder_hooks.py'
58--- unit_tests/test_cinder_hooks.py 2013-10-20 18:31:12 +0000
59+++ unit_tests/test_cinder_hooks.py 2013-10-23 00:51:05 +0000
60@@ -126,6 +126,18 @@
61 super(TestChangedHooks, self).setUp(hooks, TO_PATCH)
62 self.config.side_effect = self.test_config.get_all
63
64+ @patch.object(hooks, 'amqp_joined')
65+ def test_upgrade_charm_no_amqp(self, _joined):
66+ self.relation_ids.return_value = []
67+ hooks.hooks.execute(['hooks/upgrade-charm'])
68+ _joined.assert_not_called()
69+
70+ @patch.object(hooks, 'amqp_joined')
71+ def test_upgrade_charm_with_amqp(self, _joined):
72+ self.relation_ids.return_value = ['amqp:1']
73+ hooks.hooks.execute(['hooks/upgrade-charm'])
74+ _joined.assert_called_with(relation_id='amqp:1')
75+
76 @patch.object(hooks, 'configure_https')
77 def test_config_changed(self, conf_https):
78 '''It writes out all config'''
79@@ -234,7 +246,17 @@
80 def test_amqp_joined(self):
81 '''It properly requests access to an amqp service'''
82 hooks.hooks.execute(['hooks/amqp-relation-joined'])
83- self.relation_set.assert_called_with(username='cinder', vhost='cinder')
84+ self.relation_set.assert_called_with(username='cinder',
85+ vhost='openstack',
86+ relation_id=None)
87+
88+ def test_amqp_joined_passes_relation_id(self):
89+ ''' Ensures relation_id correct passed to relation_set for out of
90+ hook execution '''
91+ hooks.amqp_joined(relation_id='amqp:1')
92+ self.relation_set.assert_called_with(username='cinder',
93+ vhost='openstack',
94+ relation_id='amqp:1')
95
96 def test_identity_service_joined(self):
97 '''It properly requests unclustered endpoint via identity-service'''

Subscribers

People subscribed via source and target branches