From 6e30f33f4ad91d7ca2db57619d9dc2b39ee973e2 Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 17 Oct 2013 17:28:24 +0100 Subject: [PATCH 1/4] Updates for shared virtual host and quantum user --- config.yaml | 4 ++-- hooks/quantum_hooks.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config.yaml b/config.yaml index 83d3d5d9..cb030243 100644 --- a/config.yaml +++ b/config.yaml @@ -27,8 +27,8 @@ options: Note that quantum/neutron is only supported >= Folsom. rabbit-user: type: string - default: nova + default: quantum rabbit-vhost: type: string - default: nova + default: openstack diff --git a/hooks/quantum_hooks.py b/hooks/quantum_hooks.py index c32f7e61..cbed3db2 100755 --- a/hooks/quantum_hooks.py +++ b/hooks/quantum_hooks.py @@ -5,6 +5,7 @@ from charmhelpers.core.hookenv import ( config, relation_get, relation_set, + relation_ids, unit_get, Hooks, UnregisteredHookError ) @@ -84,6 +85,10 @@ def config_changed(): @hooks.hook('upgrade-charm') def upgrade_charm(): + # NOTE(jamespage): Deal with changes to rabbitmq configuration for + # common virtual host across services + for r_id in relation_ids('amqp'): + amqp_joined(relation_id=r_id) install() config_changed() @@ -99,8 +104,9 @@ def db_joined(): @hooks.hook('amqp-relation-joined') -def amqp_joined(): - relation_set(username=config('rabbit-user'), +def amqp_joined(relation_id=None): + relation_set(relation_id=relation_id, + username=config('rabbit-user'), vhost=config('rabbit-vhost')) From f470f11abf576c0daa0171ee23f466e9b4e95d89 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 22 Oct 2013 16:38:56 -0700 Subject: [PATCH 2/4] Update rabbit user --- config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index cb030243..875058b0 100644 --- a/config.yaml +++ b/config.yaml @@ -27,7 +27,7 @@ options: Note that quantum/neutron is only supported >= Folsom. rabbit-user: type: string - default: quantum + default: neutron rabbit-vhost: type: string default: openstack From 23b57930ed1a6f1e0f6269afc593677e43acfdfd Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 22 Oct 2013 17:35:30 -0700 Subject: [PATCH 3/4] Fixup tests --- unit_tests/test_quantum_hooks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unit_tests/test_quantum_hooks.py b/unit_tests/test_quantum_hooks.py index bc0e4e11..c2a28589 100644 --- a/unit_tests/test_quantum_hooks.py +++ b/unit_tests/test_quantum_hooks.py @@ -26,6 +26,7 @@ TO_PATCH = [ 'CONFIGS', 'configure_ovs', 'relation_set', + 'relation_ids', 'unit_get', 'relation_get', 'install_ca_cert', @@ -118,8 +119,9 @@ class TestQuantumHooks(CharmTestCase): def test_amqp_joined(self): self._call_hook('amqp-relation-joined') self.relation_set.assert_called_with( - username='nova', - vhost='nova', + username='neutron', + vhost='openstack', + relation_id=None ) def test_amqp_changed(self): From 16a8d7c48c0483f6ab28bce4302b06f6ff48bc78 Mon Sep 17 00:00:00 2001 From: James Page Date: Tue, 22 Oct 2013 17:38:53 -0700 Subject: [PATCH 4/4] Update upgrade-test --- unit_tests/test_quantum_hooks.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unit_tests/test_quantum_hooks.py b/unit_tests/test_quantum_hooks.py index c2a28589..3004934a 100644 --- a/unit_tests/test_quantum_hooks.py +++ b/unit_tests/test_quantum_hooks.py @@ -100,9 +100,12 @@ class TestQuantumHooks(CharmTestCase): def test_upgrade_charm(self): _install = self.patch('install') _config_changed = self.patch('config_changed') + _amqp_joined = self.patch('amqp_joined') + self.relation_ids.return_value = ['amqp:0'] self._call_hook('upgrade-charm') - _install.assert_called() - _config_changed.assert_called() + self.assertTrue(_install.called) + self.assertTrue(_config_changed.called) + _amqp_joined.assert_called_with(relation_id='amqp:0') def test_db_joined(self): self.unit_get.return_value = 'myhostname'