[jamespage] Switch to using common vhost for all openstack services

This commit is contained in:
Adam Gandelman
2013-11-05 20:37:09 -08:00
4 changed files with 20 additions and 9 deletions

View File

@@ -27,8 +27,8 @@ options:
Note that quantum/neutron is only supported >= Folsom.
rabbit-user:
type: string
default: nova
default: neutron
rabbit-vhost:
type: string
default: nova
default: openstack

View File

@@ -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'))

View File

@@ -1 +1 @@
56
57

View File

@@ -26,6 +26,7 @@ TO_PATCH = [
'CONFIGS',
'configure_ovs',
'relation_set',
'relation_ids',
'unit_get',
'relation_get',
'install_ca_cert',
@@ -99,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'
@@ -118,8 +122,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):