Deprecate rabbitmq connection parameters

The rabbitmq connection parameters have been deprecated in favor of a
transport url setting.

Change-Id: I6aa29f7a70c4c1bfce8a09d8da5f88bb148d7d49
Related-Bug: #1625198
This commit is contained in:
Alex Schultz 2016-11-08 15:32:20 -07:00
parent 22f32f8ea1
commit 9d22a27038
3 changed files with 83 additions and 45 deletions

View File

@ -7,30 +7,11 @@
# #
# == Parameters # == Parameters
# #
# [*rabbit_host*] # [*default_transport_url*]
# (Optional) IP or hostname of the rabbit server. # (optional) A URL representing the messaging driver to use and its full
# Defaults to '127.0.0.1'. # configuration. Transport URLs take the form:
# # transport://user:pass@host1:port[,hostN:portN]/virtual_host
# [*rabbit_port*] # Defaults to $::os_service_default
# (Optional) Port of the rabbit server.
# Defaults to 5672.
#
# [*rabbit_hosts*]
# (Optional) IP or hostname of the rabbits servers.
# comma separated array (ex: ['1.0.0.10:5672','1.0.0.11:5672'])
# Defaults to undef.
#
# [*rabbit_user*]
# (Optional) Username for rabbit.
# Defaults to 'guest'.
#
# [*rabbit_password*]
# (Optional) Password for rabbit user.
# Defaults to 'guest'.
#
# [*rabbit_virtual_host*]
# (Optional) Virtual host to use.
# Defaults to '/'.
# #
# [*driver*] # [*driver*]
# (Optional) The Drivers(s) to handle sending notifications. # (Optional) The Drivers(s) to handle sending notifications.
@ -58,6 +39,33 @@
# Whether to send events to messaging driver in a background thread # Whether to send events to messaging driver in a background thread
# Defaults to false # Defaults to false
# #
# === DEPRECATED PARAMETERS
#
# [*rabbit_host*]
# (Optional) IP or hostname of the rabbit server.
# Defaults to '127.0.0.1'.
#
# [*rabbit_port*]
# (Optional) Port of the rabbit server.
# Defaults to 5672.
#
# [*rabbit_hosts*]
# (Optional) IP or hostname of the rabbits servers.
# comma separated array (ex: ['1.0.0.10:5672','1.0.0.11:5672'])
# Defaults to undef.
#
# [*rabbit_user*]
# (Optional) Username for rabbit.
# Defaults to 'guest'.
#
# [*rabbit_password*]
# (Optional) Password for rabbit user.
# Defaults to 'guest'.
#
# [*rabbit_virtual_host*]
# (Optional) Virtual host to use.
# Defaults to '/'.
#
# == Examples # == Examples
# #
# == Authors # == Authors
@ -69,31 +77,43 @@
# Copyright 2013 eNovance licensing@enovance.com # Copyright 2013 eNovance licensing@enovance.com
# #
class swift::proxy::ceilometer( class swift::proxy::ceilometer(
$rabbit_user = 'guest', $default_transport_url = undef,
$rabbit_password = 'guest', $driver = undef,
$rabbit_host = '127.0.0.1', $topic = undef,
$rabbit_port = '5672', $control_exchange = undef,
$rabbit_hosts = undef, $ensure = 'present',
$rabbit_virtual_host = '/', $group = 'ceilometer',
$driver = undef, $nonblocking_notify = false,
$topic = undef, # DEPRECATED PARAMETERS
$control_exchange = undef, $rabbit_user = 'guest',
$ensure = 'present', $rabbit_password = 'guest',
$group = 'ceilometer', $rabbit_host = '127.0.0.1',
$nonblocking_notify = false, $rabbit_port = '5672',
$rabbit_hosts = undef,
$rabbit_virtual_host = '/',
) inherits swift { ) inherits swift {
include ::swift::deps include ::swift::deps
if(is_array($rabbit_hosts)) { if $default_transport_url {
$rabbit_hosts_with_creds = prefix($rabbit_hosts, "${rabbit_user}:${rabbit_password}@") $amqp_url = $default_transport_url
}
if !$rabbit_hosts {
$url = "rabbit://${rabbit_user}:${rabbit_password}@${rabbit_host}:${rabbit_port}/${rabbit_virtual_host}"
} else { } else {
$hosts = join($rabbit_hosts_with_creds, ',') warning("swift::proxy::ceilometer::rabbit_host,
$url = "rabbit://${hosts}/${rabbit_virtual_host}" swift::proxy::ceilometer::rabbit_hosts, swift::proxy::ceilometer::rabbit_password, \
swift::proxy::ceilometer::rabbit_port, swift::proxy::ceilometer::rabbit_userid \
and swift::proxy::ceilometer::rabbit_virtual_host are \
deprecated. Please use swift::proxy::ceilometer::default_transport_url instead.")
if(is_array($rabbit_hosts)) {
$rabbit_hosts_with_creds = prefix($rabbit_hosts, "${rabbit_user}:${rabbit_password}@")
}
if !$rabbit_hosts {
$amqp_url = "rabbit://${rabbit_user}:${rabbit_password}@${rabbit_host}:${rabbit_port}/${rabbit_virtual_host}"
} else {
$hosts = join($rabbit_hosts_with_creds, ',')
$amqp_url = "rabbit://${hosts}/${rabbit_virtual_host}"
}
} }
User['swift'] { User['swift'] {
@ -115,7 +135,7 @@ class swift::proxy::ceilometer(
swift_proxy_config { swift_proxy_config {
'filter:ceilometer/topic': value => $topic; 'filter:ceilometer/topic': value => $topic;
'filter:ceilometer/driver': value => $driver; 'filter:ceilometer/driver': value => $driver;
'filter:ceilometer/url': value => $url; 'filter:ceilometer/url': value => $amqp_url;
'filter:ceilometer/control_exchange': value => $control_exchange; 'filter:ceilometer/control_exchange': value => $control_exchange;
'filter:ceilometer/paste.filter_factory': value => 'ceilometermiddleware.swift:filter_factory'; 'filter:ceilometer/paste.filter_factory': value => 'ceilometermiddleware.swift:filter_factory';
'filter:ceilometer/nonblocking_notify': value => $nonblocking_notify; 'filter:ceilometer/nonblocking_notify': value => $nonblocking_notify;

View File

@ -0,0 +1,10 @@
---
deprecations:
- swift::proxy::ceilometer::rabbit_host,
swift::proxy::ceilometer::rabbit_hosts,
swift::proxy::ceilometer::rabbit_password,
swift::proxy::ceilometer::rabbit_port,
swift::proxy::ceilometer::rabbit_userid and
swift::proxy::ceilometer::rabbit_virtual_host are deprecated.
swift::proxy::ceilometer::default_transport_url should be used instead.

View File

@ -59,6 +59,14 @@ describe 'swift::proxy::ceilometer' do
it { is_expected.to contain_swift_proxy_config('filter:ceilometer/nonblocking_notify').with_value('true') } it { is_expected.to contain_swift_proxy_config('filter:ceilometer/nonblocking_notify').with_value('true') }
end end
context 'with default transport url' do
before do
params.merge!({ :default_transport_url => 'rabbit://user:pass@host:1234/virt' })
end
it { is_expected.to contain_swift_proxy_config('filter:ceilometer/url').with_value('rabbit://user:pass@host:1234/virt') }
end
end end
end end