Collectd QDR connection

This patch enables to configure collectd to QDR by utilizing
collectd-amqp1 plugin.

Partial-Bug: #1822054
Change-Id: I4cb6aa95e253b7fd19ed265fbcba0dfe6663592d
(cherry picked from commit 6c60a0f21f)
This commit is contained in:
Martin Mágr 2018-05-30 11:35:26 +02:00 committed by Martin Magr
parent 85692a695b
commit 22e61c50b1
3 changed files with 124 additions and 26 deletions

View File

@ -1,6 +1,10 @@
## TripleO Puppet modules ## TripleO Puppet modules
mod 'stdlib',
:git => 'https://github.com/puppetlabs/puppetlabs-stdlib',
:ref => '127b2f9b36b6f41a62db0d68f3908e7c227871a0'
mod 'haproxy', mod 'haproxy',
:git => 'https://github.com/puppetlabs/puppetlabs-haproxy', :git => 'https://github.com/puppetlabs/puppetlabs-haproxy',
:ref => 'master' :ref => 'master'
@ -79,5 +83,4 @@ mod 'pacemaker',
# Note(bandini): Pinned due to LP#1756890 # Note(bandini): Pinned due to LP#1756890
mod 'collectd', mod 'collectd',
:git => 'https://github.com/voxpupuli/puppet-collectd', :git => 'https://github.com/voxpupuli/puppet-collectd',
:ref => '93c8d0bd32bb5610652f30e785ba6644fc82a8b6' :ref => '0f9f525f967930620437afb050d58570d129ee85'

View File

@ -142,6 +142,52 @@
# (Optional) Boolean. Whether let collectd enable manage repositories. # (Optional) Boolean. Whether let collectd enable manage repositories.
# If it is set to true the epel repository will be used # If it is set to true the epel repository will be used
# #
# [*amqp_transport_name*]
# (Optional) String. Name of the transport.
# Default to 'metrics'
#
# [*amqp_host*]
# (Optional) String. Hostname or IP address of the AMQP 1.0 intermediary.
# Defaults to the undef
#
# [*amqp_port*]
# (Optional) String. Service name or port number on which the AMQP 1.0
# intermediary accepts connections. This argument must be a string,
# even if the numeric form is used.
# Defaults to undef
#
# [*amqp_user*]
# (Optional) String. User part of credentials used to authenticate to the
# AMQP 1.0 intermediary.
# Defaults to undef
#
# [*amqp_password*]
# (Optional) String. Password part of credentials used to authenticate
# to the AMQP 1.0 intermediary.
# Defaults to undef
#
# [*amqp_address*]
# (Optional) String. This option specifies the prefix for the send-to value
# in the message.
# Defaults to 'collectd'
#
# [*amqp_retry_delay*]
# (Optional) Number. When the AMQP1 connection is lost, defines the time
# in seconds to wait before attempting to reconnect. If not set 1 second
# is the implicit default.
# Defaults to undef
#
# [*amqp_interval*]
# (Optional) Number. Interval on which metrics should be sent to AMQP
# intermediary. If not set the default for all collectd plugins is used.
# Defaults to undef
#
# [*amqp_instances*]
# (Optional) Hash of hashes. Each inner hash represent Instance block in plugin
# configuration file. Key of outter hash represents instance name.
# The 'address' value concatenated with the 'name' given will be used
# as the send-to address for communications over the messaging link.
# Defaults to {}.
class tripleo::profile::base::metrics::collectd ( class tripleo::profile::base::metrics::collectd (
$step = Integer(hiera('step')), $step = Integer(hiera('step')),
@ -171,6 +217,15 @@ class tripleo::profile::base::metrics::collectd (
$gnocchi_keystone_endpoint = undef, $gnocchi_keystone_endpoint = undef,
$gnocchi_resource_type = 'collectd', $gnocchi_resource_type = 'collectd',
$gnocchi_batch_size = 10, $gnocchi_batch_size = 10,
$amqp_transport_name = 'metrics',
$amqp_host = undef,
$amqp_port = undef,
$amqp_user = undef,
$amqp_password = undef,
$amqp_address = 'collectd',
$amqp_instances = {},
$amqp_retry_delay = undef,
$amqp_interval = undef,
$service_names = hiera('service_names', []), $service_names = hiera('service_names', []),
$collectd_manage_repo = false $collectd_manage_repo = false
) { ) {
@ -221,6 +276,20 @@ class tripleo::profile::base::metrics::collectd (
port => $_collectd_port, port => $_collectd_port,
securitylevel => $_collectd_securitylevel, securitylevel => $_collectd_securitylevel,
} }
} elsif !empty($amqp_host) {
class { '::collectd::plugin::amqp1':
ensure => 'present',
manage_package => true,
transport => $amqp_transport_name,
host => $amqp_host,
port => $amqp_port,
user => $amqp_user,
password => $amqp_password,
address => $amqp_address,
instances => $amqp_instances,
retry_delay => $amqp_retry_delay,
interval => $amqp_interval,
}
} elsif !empty($gnocchi_server) or !empty($gnocchi_keystone_auth_url) { } elsif !empty($gnocchi_server) or !empty($gnocchi_keystone_auth_url) {
if !empty($gnocchi_server) { if !empty($gnocchi_server) {
$gci_server = $gnocchi_server $gci_server = $gnocchi_server

View File

@ -18,42 +18,68 @@ require 'spec_helper'
describe 'tripleo::profile::base::metrics::collectd' do describe 'tripleo::profile::base::metrics::collectd' do
shared_examples_for 'tripleo::profile::base::metrics::collectd' do shared_examples_for 'tripleo::profile::base::metrics::collectd' do
context 'with step less than 3' do context 'with step less than 3' do
let(:params) { { :step => 2 } } let(:params) { { :step => 2, :gnocchi_server => 'localhost' } }
it 'should do nothing' do it 'should do nothing' do
is_expected.to_not contain_class('collectd') is_expected.to_not contain_class('collectd')
is_expected.to_not contain_class('collectd::plugin::logfile') end
end
end end
context 'with defaults and step greater than 3' do context 'with defaults and step greater than 3, gnocchi deploy' do
let(:params) { { :step => 3 } } let(:params) { { :step => 3, :gnocchi_server => 'localhost' } }
it 'only have the collectd' do it 'has collectd class with gnocchi plugin and python plugin' do
is_expected.to compile.with_all_deps
is_expected.to contain_class('collectd').with(
:manage_repo => false,
)
is_expected.to contain_service('collectd').with(
:ensure => 'running',
:enable => true,
)
is_expected.to contain_package('python-collectd-gnocchi').with(
:ensure => 'present',
)
is_expected.to contain_package('collectd-python').with(
:ensure => 'present',
)
is_expected.to_not contain_class('epel')
is_expected.to_not contain_class('collectd::plugin::amqp1')
is_expected.to_not contain_class('collectd::plugin::logfile')
end
end
context 'with enabled file_logging and step greater than 3' do
let(:params) do
{ :step => 3,
:enable_file_logging => true,
:gnocchi_server => 'localhost' }
end
it 'Contains both' do
is_expected.to compile.with_all_deps
is_expected.to contain_class('collectd')
is_expected.to contain_class('collectd::plugin::logfile')
end
end
context 'with defaults and step greater than 3, amqp deploy' do
let(:params) do
{ :step => 3,
:amqp_host => 'localhost',
}
end
it 'has amqp class' do
is_expected.to compile.with_all_deps is_expected.to compile.with_all_deps
is_expected.to contain_class('collectd') is_expected.to contain_class('collectd')
is_expected.to_not contain_class('collectd::plugin::logfile') is_expected.to contain_class('collectd::plugin::amqp1').with(
is_expected.to contain_class('collectd').with( :manage_package => true,
:manage_repo => false,
) )
is_expected.to contain_service('collectd').with( is_expected.to contain_service('collectd').with(
:ensure => 'running', :ensure => 'running',
:enable => true, :enable => true,
) )
is_expected.to_not contain_class('epel')
end end
end end
context 'Enabled file_logging and step greater than 3' do
let(:params) { {
:step => 3,
:enable_file_logging => true
} }
it 'Contains both' do
is_expected.to compile.with_all_deps
is_expected.to contain_class('collectd')
is_expected.to contain_class('collectd::plugin::logfile')
end
end
end end
on_supported_os.each do |os, facts| on_supported_os.each do |os, facts|