Skip to content

Commit 9d22a27

Browse files
committed
Deprecate rabbitmq connection parameters
The rabbitmq connection parameters have been deprecated in favor of a transport url setting. Change-Id: I6aa29f7a70c4c1bfce8a09d8da5f88bb148d7d49 Related-Bug: #1625198
1 parent 22f32f8 commit 9d22a27

File tree

3 files changed

+83
-45
lines changed

3 files changed

+83
-45
lines changed

manifests/proxy/ceilometer.pp

Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,11 @@
77
#
88
# == Parameters
99
#
10-
# [*rabbit_host*]
11-
# (Optional) IP or hostname of the rabbit server.
12-
# Defaults to '127.0.0.1'.
13-
#
14-
# [*rabbit_port*]
15-
# (Optional) Port of the rabbit server.
16-
# Defaults to 5672.
17-
#
18-
# [*rabbit_hosts*]
19-
# (Optional) IP or hostname of the rabbits servers.
20-
# comma separated array (ex: ['1.0.0.10:5672','1.0.0.11:5672'])
21-
# Defaults to undef.
22-
#
23-
# [*rabbit_user*]
24-
# (Optional) Username for rabbit.
25-
# Defaults to 'guest'.
26-
#
27-
# [*rabbit_password*]
28-
# (Optional) Password for rabbit user.
29-
# Defaults to 'guest'.
30-
#
31-
# [*rabbit_virtual_host*]
32-
# (Optional) Virtual host to use.
33-
# Defaults to '/'.
10+
# [*default_transport_url*]
11+
# (optional) A URL representing the messaging driver to use and its full
12+
# configuration. Transport URLs take the form:
13+
# transport://user:pass@host1:port[,hostN:portN]/virtual_host
14+
# Defaults to $::os_service_default
3415
#
3516
# [*driver*]
3617
# (Optional) The Drivers(s) to handle sending notifications.
@@ -58,6 +39,33 @@
5839
# Whether to send events to messaging driver in a background thread
5940
# Defaults to false
6041
#
42+
# === DEPRECATED PARAMETERS
43+
#
44+
# [*rabbit_host*]
45+
# (Optional) IP or hostname of the rabbit server.
46+
# Defaults to '127.0.0.1'.
47+
#
48+
# [*rabbit_port*]
49+
# (Optional) Port of the rabbit server.
50+
# Defaults to 5672.
51+
#
52+
# [*rabbit_hosts*]
53+
# (Optional) IP or hostname of the rabbits servers.
54+
# comma separated array (ex: ['1.0.0.10:5672','1.0.0.11:5672'])
55+
# Defaults to undef.
56+
#
57+
# [*rabbit_user*]
58+
# (Optional) Username for rabbit.
59+
# Defaults to 'guest'.
60+
#
61+
# [*rabbit_password*]
62+
# (Optional) Password for rabbit user.
63+
# Defaults to 'guest'.
64+
#
65+
# [*rabbit_virtual_host*]
66+
# (Optional) Virtual host to use.
67+
# Defaults to '/'.
68+
#
6169
# == Examples
6270
#
6371
# == Authors
@@ -69,31 +77,43 @@
6977
# Copyright 2013 eNovance licensing@enovance.com
7078
#
7179
class swift::proxy::ceilometer(
72-
$rabbit_user = 'guest',
73-
$rabbit_password = 'guest',
74-
$rabbit_host = '127.0.0.1',
75-
$rabbit_port = '5672',
76-
$rabbit_hosts = undef,
77-
$rabbit_virtual_host = '/',
78-
$driver = undef,
79-
$topic = undef,
80-
$control_exchange = undef,
81-
$ensure = 'present',
82-
$group = 'ceilometer',
83-
$nonblocking_notify = false,
80+
$default_transport_url = undef,
81+
$driver = undef,
82+
$topic = undef,
83+
$control_exchange = undef,
84+
$ensure = 'present',
85+
$group = 'ceilometer',
86+
$nonblocking_notify = false,
87+
# DEPRECATED PARAMETERS
88+
$rabbit_user = 'guest',
89+
$rabbit_password = 'guest',
90+
$rabbit_host = '127.0.0.1',
91+
$rabbit_port = '5672',
92+
$rabbit_hosts = undef,
93+
$rabbit_virtual_host = '/',
8494
) inherits swift {
8595

8696
include ::swift::deps
8797

88-
if(is_array($rabbit_hosts)) {
89-
$rabbit_hosts_with_creds = prefix($rabbit_hosts, "${rabbit_user}:${rabbit_password}@")
90-
}
91-
92-
if !$rabbit_hosts {
93-
$url = "rabbit://${rabbit_user}:${rabbit_password}@${rabbit_host}:${rabbit_port}/${rabbit_virtual_host}"
98+
if $default_transport_url {
99+
$amqp_url = $default_transport_url
94100
} else {
95-
$hosts = join($rabbit_hosts_with_creds, ',')
96-
$url = "rabbit://${hosts}/${rabbit_virtual_host}"
101+
warning("swift::proxy::ceilometer::rabbit_host,
102+
swift::proxy::ceilometer::rabbit_hosts, swift::proxy::ceilometer::rabbit_password, \
103+
swift::proxy::ceilometer::rabbit_port, swift::proxy::ceilometer::rabbit_userid \
104+
and swift::proxy::ceilometer::rabbit_virtual_host are \
105+
deprecated. Please use swift::proxy::ceilometer::default_transport_url instead.")
106+
107+
if(is_array($rabbit_hosts)) {
108+
$rabbit_hosts_with_creds = prefix($rabbit_hosts, "${rabbit_user}:${rabbit_password}@")
109+
}
110+
111+
if !$rabbit_hosts {
112+
$amqp_url = "rabbit://${rabbit_user}:${rabbit_password}@${rabbit_host}:${rabbit_port}/${rabbit_virtual_host}"
113+
} else {
114+
$hosts = join($rabbit_hosts_with_creds, ',')
115+
$amqp_url = "rabbit://${hosts}/${rabbit_virtual_host}"
116+
}
97117
}
98118

99119
User['swift'] {
@@ -115,7 +135,7 @@
115135
swift_proxy_config {
116136
'filter:ceilometer/topic': value => $topic;
117137
'filter:ceilometer/driver': value => $driver;
118-
'filter:ceilometer/url': value => $url;
138+
'filter:ceilometer/url': value => $amqp_url;
119139
'filter:ceilometer/control_exchange': value => $control_exchange;
120140
'filter:ceilometer/paste.filter_factory': value => 'ceilometermiddleware.swift:filter_factory';
121141
'filter:ceilometer/nonblocking_notify': value => $nonblocking_notify;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
deprecations:
3+
- swift::proxy::ceilometer::rabbit_host,
4+
swift::proxy::ceilometer::rabbit_hosts,
5+
swift::proxy::ceilometer::rabbit_password,
6+
swift::proxy::ceilometer::rabbit_port,
7+
swift::proxy::ceilometer::rabbit_userid and
8+
swift::proxy::ceilometer::rabbit_virtual_host are deprecated.
9+
swift::proxy::ceilometer::default_transport_url should be used instead.
10+

spec/classes/swift_proxy_ceilometer_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@
5959
it { is_expected.to contain_swift_proxy_config('filter:ceilometer/nonblocking_notify').with_value('true') }
6060
end
6161

62+
context 'with default transport url' do
63+
before do
64+
params.merge!({ :default_transport_url => 'rabbit://user:pass@host:1234/virt' })
65+
end
66+
67+
it { is_expected.to contain_swift_proxy_config('filter:ceilometer/url').with_value('rabbit://user:pass@host:1234/virt') }
68+
end
69+
6270
end
6371

6472
end

0 commit comments

Comments
 (0)