Add multiple rabbit hosts support
* Use new oslo.messaging conf options for rabbit_hosts and rabbit_ha_queues for glance::notify::rabbitmq class * Warn on deprecated rabbit_durable_queues and use amqp_* instead * Fix/add rspecs * Fix a mess with wrong notification_driver usage * Update README with usage example DocImpact Closes-bug: #1259193 Closes-bug: #1312054 Closes-bug: #1312658 Closes-bug: #1313553 Change-Id: I16b8e71db20602986a7afe8d24e7faba91a0997f Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
This commit is contained in:
parent
f6c865a055
commit
d40f3d8622
13
README.md
13
README.md
|
@ -91,6 +91,19 @@ class { 'glance::keystone::auth':
|
|||
}
|
||||
```
|
||||
|
||||
**Setup up notifications for multiple RabbitMQ nodes**
|
||||
|
||||
```puppet
|
||||
class { 'glance::notify::rabbitmq':
|
||||
rabbit_password => 'pass',
|
||||
rabbit_userid => 'guest',
|
||||
rabbit_hosts => [
|
||||
'localhost:5672', 'remotehost:5672'
|
||||
],
|
||||
rabbit_use_ssl => false,
|
||||
}
|
||||
```
|
||||
|
||||
Implementation
|
||||
--------------
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ class glance::notify::rabbitmq(
|
|||
$rabbit_userid = 'guest',
|
||||
$rabbit_host = 'localhost',
|
||||
$rabbit_port = '5672',
|
||||
$rabbit_hosts = false,
|
||||
$rabbit_virtual_host = '/',
|
||||
$rabbit_use_ssl = false,
|
||||
$kombu_ssl_ca_certs = undef,
|
||||
|
@ -48,20 +49,40 @@ class glance::notify::rabbitmq(
|
|||
$kombu_ssl_version = 'SSLv3',
|
||||
$rabbit_notification_exchange = 'glance',
|
||||
$rabbit_notification_topic = 'notifications',
|
||||
$rabbit_durable_queues = false
|
||||
$rabbit_durable_queues = false,
|
||||
$amqp_durable_queues = false,
|
||||
) {
|
||||
|
||||
if $rabbit_durable_queues {
|
||||
warning('The rabbit_durable_queues parameter is deprecated, use amqp_durable_queues.')
|
||||
$amqp_durable_queues_real = $rabbit_durable_queues
|
||||
} else {
|
||||
$amqp_durable_queues_real = $amqp_durable_queues
|
||||
}
|
||||
|
||||
if $rabbit_hosts {
|
||||
glance_api_config {
|
||||
'DEFAULT/rabbit_hosts': value => join($rabbit_hosts, ',');
|
||||
'DEFAULT/rabbit_ha_queues': value => true
|
||||
}
|
||||
} else {
|
||||
glance_api_config {
|
||||
'DEFAULT/rabbit_host': value => $rabbit_host;
|
||||
'DEFAULT/rabbit_port': value => $rabbit_port;
|
||||
'DEFAULT/rabbit_hosts': value => "${rabbit_host}:${rabbit_port}";
|
||||
'DEFAULT/rabbit_ha_queues': value => false
|
||||
}
|
||||
}
|
||||
|
||||
glance_api_config {
|
||||
'DEFAULT/notifier_driver': value => 'rabbit';
|
||||
'DEFAULT/rabbit_host': value => $rabbit_host;
|
||||
'DEFAULT/rabbit_port': value => $rabbit_port;
|
||||
'DEFAULT/notification_driver': value => 'messaging';
|
||||
'DEFAULT/rabbit_virtual_host': value => $rabbit_virtual_host;
|
||||
'DEFAULT/rabbit_password': value => $rabbit_password;
|
||||
'DEFAULT/rabbit_userid': value => $rabbit_userid;
|
||||
'DEFAULT/rabbit_notification_exchange': value => $rabbit_notification_exchange;
|
||||
'DEFAULT/rabbit_notification_topic': value => $rabbit_notification_topic;
|
||||
'DEFAULT/rabbit_use_ssl': value => $rabbit_use_ssl;
|
||||
'DEFAULT/rabbit_durable_queues': value => $rabbit_durable_queues;
|
||||
'DEFAULT/amqp_durable_queues': value => $amqp_durable_queues_real;
|
||||
}
|
||||
|
||||
if $rabbit_use_ssl {
|
||||
|
|
|
@ -10,19 +10,23 @@ describe 'glance::notify::rabbitmq' do
|
|||
'class { "glance::api": keystone_password => "pass" }'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{:rabbit_password => 'pass'}
|
||||
describe 'when defaults with rabbit pass specified' do
|
||||
let :params do
|
||||
{:rabbit_password => 'pass'}
|
||||
end
|
||||
it { should contain_glance_api_config('DEFAULT/notification_driver').with_value('messaging') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_password').with_value('pass') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_userid').with_value('guest') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_port').with_value('5672') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_hosts').with_value('localhost:5672') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_ha_queues').with_value('false') }
|
||||
it { should contain_glance_api_config('DEFAULT/amqp_durable_queues').with_value('false') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_virtual_host').with_value('/') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_notification_exchange').with_value('glance') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_notification_topic').with_value('notifications') }
|
||||
end
|
||||
|
||||
it { should contain_glance_api_config('DEFAULT/notifier_driver').with_value('rabbit') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_password').with_value('pass') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_userid').with_value('guest') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_port').with_value('5672') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_virtual_host').with_value('/') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_notification_exchange').with_value('glance') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_notification_topic').with_value('notifications') }
|
||||
|
||||
describe 'when passing params and use ssl' do
|
||||
let :params do
|
||||
{
|
||||
|
@ -62,4 +66,49 @@ describe 'glance::notify::rabbitmq' do
|
|||
it { should contain_glance_api_config('DEFAULT/kombu_ssl_keyfile').with_value('/etc/key') }
|
||||
it { should contain_glance_api_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') }
|
||||
end
|
||||
|
||||
describe 'when passing params for single rabbit host' do
|
||||
let :params do
|
||||
{
|
||||
:rabbit_password => 'pass',
|
||||
:rabbit_userid => 'guest2',
|
||||
:rabbit_host => 'localhost2',
|
||||
:rabbit_port => '5673',
|
||||
:rabbit_use_ssl => true,
|
||||
:rabbit_durable_queues => true,
|
||||
}
|
||||
end
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_userid').with_value('guest2') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost2') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_port').with_value('5673') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_hosts').with_value('localhost2:5673') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_use_ssl').with_value('true') }
|
||||
it { should contain_glance_api_config('DEFAULT/amqp_durable_queues').with_value('true') }
|
||||
end
|
||||
|
||||
describe 'when passing params for multiple rabbit hosts' do
|
||||
let :params do
|
||||
{
|
||||
:rabbit_password => 'pass',
|
||||
:rabbit_userid => 'guest3',
|
||||
:rabbit_hosts => ['nonlocalhost3:5673', 'nonlocalhost4:5673']
|
||||
}
|
||||
end
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_userid').with_value('guest3') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_hosts').with_value(
|
||||
'nonlocalhost3:5673,nonlocalhost4:5673') }
|
||||
it { should contain_glance_api_config('DEFAULT/rabbit_ha_queues').with_value('true') }
|
||||
it { should_not contain_glance_api_config('DEFAULT/rabbit_port') }
|
||||
it { should_not contain_glance_api_config('DEFAULT/rabbit_host') }
|
||||
end
|
||||
|
||||
describe 'when using deprecated params' do
|
||||
let :params do
|
||||
{
|
||||
:rabbit_durable_queues => true,
|
||||
:rabbit_password => 'pass'
|
||||
}
|
||||
end
|
||||
it { should contain_glance_api_config('DEFAULT/amqp_durable_queues').with_value('true') }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue