Update ceilometer proxy template

Now for using Ceilometer notifications from Swift we should
use Ceilometer middleware. Hence we need update template for Swift
to account for incoming and outgoing traffic notifications.

[1] I686e5d94fb72fd2a00973c91673edc417142ee2f
[2] http://docs.openstack.org/developer/oslo.messaging/transport.html#oslo_messaging.TransportURL

Change-Id: Ib6efd4a1ab4b76c74cffc546383f5382c24a8c43
Related-bug: #1510064
This commit is contained in:
Denis Egorenko
2015-11-18 18:30:35 +03:00
parent 82b0a90dd9
commit e8ad981eff
3 changed files with 106 additions and 6 deletions

View File

@@ -7,6 +7,43 @@
#
# == 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 '/'.
#
# [*driver*]
# (Optional) The Drivers(s) to handle sending notifications.
# Defaults to undef.
#
# [*topic*]
# (Optional) AMQP topic used for OpenStack notifications.
# Defaults to undef.
#
# [*control_exchange*]
# (Optional) The default exchange under which topics are scoped.
# Defaults to undef.
#
# [*ensure*]
# Enable or not ceilometer fragment
# Defaults to 'present'
@@ -28,6 +65,15 @@
# Copyright 2013 eNovance licensing@enovance.com
#
class swift::proxy::ceilometer(
$rabbit_user = 'guest',
$rabbit_password = 'guest',
$rabbit_host = '127.0.0.1',
$rabbit_port = '5672',
$rabbit_hosts = undef,
$rabbit_virtual_host = '/',
$driver = undef,
$topic = undef,
$control_exchange = undef,
$ensure = 'present',
$group = 'ceilometer',
) inherits swift {
@@ -54,4 +100,9 @@ class swift::proxy::ceilometer(
require => Class['::ceilometer'],
}
package { 'python-ceilometermiddleware':
ensure => $ensure,
tag => 'openstack',
}
}

View File

@@ -22,7 +22,8 @@ describe 'swift::proxy::ceilometer' do
describe "when using default parameters" do
it { is_expected.to contain_file(fragment_file).with_content(/[filter:ceilometer]/) }
it { is_expected.to contain_file(fragment_file).with_content(/use = egg:ceilometer#swift/) }
it { is_expected.to contain_file(fragment_file).with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) }
it { is_expected.to contain_file(fragment_file).with_content(/url = rabbit:\/\/guest:guest@127.0.0.1:5672\//) }
if Puppet.version.to_f < 4.0
it { is_expected.to contain_concat__fragment('swift_ceilometer').with_require('Class[Ceilometer]')}
else
@@ -34,9 +35,42 @@ describe 'swift::proxy::ceilometer' do
describe "when overriding default parameters" do
let :params do
{ :group => 'www-data' }
{ :group => 'www-data',
:rabbit_user => 'user_1',
:rabbit_password => 'user_1_passw',
:rabbit_host => '1.1.1.1',
:rabbit_port => '5673',
:rabbit_virtual_host => 'rabbit',
:driver => 'messagingv2',
:topic => 'notifications',
:control_exchange => 'swift',
}
end
context 'with single rabbit host' do
it { is_expected.to contain_user('swift').with_groups('www-data') }
it { is_expected.to contain_file(fragment_file).with_content(/[filter:ceilometer]/) }
it { is_expected.to contain_file(fragment_file).with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) }
it { is_expected.to contain_file(fragment_file).with_content(/url = rabbit:\/\/user_1:user_1_passw@1.1.1.1:5673\/rabbit/) }
it { is_expected.to contain_file(fragment_file).with_content(/driver = messagingv2/) }
it { is_expected.to contain_file(fragment_file).with_content(/topic = notifications/) }
it { is_expected.to contain_file(fragment_file).with_content(/control_exchange = swift/) }
end
context 'with multiple rabbit hosts' do
before do
params.merge!({ :rabbit_hosts => ['127.0.0.1:5672', '127.0.0.2:5672'] })
end
it { is_expected.to contain_user('swift').with_groups('www-data') }
it { is_expected.to contain_file(fragment_file).with_content(/[filter:ceilometer]/) }
it { is_expected.to contain_file(fragment_file).with_content(/paste.filter_factory = ceilometermiddleware.swift:filter_factory/) }
it { is_expected.to contain_file(fragment_file).with_content(/url = rabbit:\/\/user_1:user_1_passw@127.0.0.1:5672,127.0.0.2:5672\/rabbit/) }
it { is_expected.to contain_file(fragment_file).with_content(/driver = messagingv2/) }
it { is_expected.to contain_file(fragment_file).with_content(/topic = notifications/) }
it { is_expected.to contain_file(fragment_file).with_content(/control_exchange = swift/) }
end
end
end

View File

@@ -1,3 +1,18 @@
[filter:ceilometer]
use = egg:ceilometer#swift
paste.filter_factory = ceilometermiddleware.swift:filter_factory
<% if @rabbit_hosts.nil? %>
url = rabbit://<%= @rabbit_user %>:<%= @rabbit_password %>@<%= @rabbit_host %>:<%= @rabbit_port %>/<%= @rabbit_virtual_host %>
<% else %>
<% hosts=Array(@rabbit_hosts).join(",") -%>
url = rabbit://<%= @rabbit_user %>:<%= @rabbit_password %>@<%= hosts %>/<%= @rabbit_virtual_host %>
<% end %>
<% if @driver %>
driver = <%= @driver %>
<% end %>
<% if @topic %>
topic = <%= @topic %>
<% end %>
<% if @control_exchange %>
control_exchange = <%= @control_exchange %>
<% end %>