Merge "Add udp_address/udp_port parameters for collector."
This commit is contained in:
commit
1c3a3aeddd
@ -13,16 +13,38 @@
|
||||
# (optional) ensure state for package.
|
||||
# Defaults to 'present'
|
||||
#
|
||||
# [*udp_address*]
|
||||
# (optional) the ceilometer collector udp bind address.
|
||||
# Set it empty to disable the collector listener.
|
||||
# Defaults to '0.0.0.0'
|
||||
#
|
||||
# [*udp_port*]
|
||||
# (optional) the ceilometer collector udp bind port.
|
||||
# Defaults to '4952'
|
||||
#
|
||||
class ceilometer::collector (
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$package_ensure = 'present',
|
||||
$udp_address = '0.0.0.0',
|
||||
$udp_port = '4952',
|
||||
) {
|
||||
|
||||
include ::ceilometer::params
|
||||
|
||||
Ceilometer_config<||> ~> Service['ceilometer-collector']
|
||||
|
||||
# We accept udp_address to be set to empty instead of the usual undef to stay
|
||||
# close to the "strange" upstream interface.
|
||||
if (is_ip_address($udp_address) != true and $udp_address != '' ){
|
||||
fail("${udp_address} is not a valid ip and is not empty")
|
||||
}
|
||||
|
||||
ceilometer_config {
|
||||
'collector/udp_address' : value => $udp_address;
|
||||
'collector/udp_port' : value => $udp_port;
|
||||
}
|
||||
|
||||
Package[$::ceilometer::params::collector_package_name] -> Service['ceilometer-collector']
|
||||
ensure_resource( 'package', [$::ceilometer::params::collector_package_name],
|
||||
{ ensure => $package_ensure }
|
||||
|
@ -8,6 +8,39 @@ describe 'ceilometer::collector' do
|
||||
|
||||
shared_examples_for 'ceilometer-collector' do
|
||||
|
||||
context 'when invalid ip is passed' do
|
||||
let :params do
|
||||
{ :udp_address => '300.0.0.0' }
|
||||
end
|
||||
it 'should fail' do
|
||||
is_expected.to raise_error(Puppet::Error, /is not a valid ip and is not empty/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a valid ipv6 is passed' do
|
||||
before do
|
||||
pre_condition << "class { 'ceilometer::db': }"
|
||||
end
|
||||
let :params do
|
||||
{ :udp_address => '::1' }
|
||||
end
|
||||
it 'shouldn\'t fail' do
|
||||
is_expected.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context 'when an empty string passed' do
|
||||
before do
|
||||
pre_condition << "class { 'ceilometer::db': }"
|
||||
end
|
||||
let :params do
|
||||
{ :udp_address => '' }
|
||||
end
|
||||
it 'should disable the listener' do
|
||||
is_expected.to contain_ceilometer_config('collector/udp_address').with_value( '' )
|
||||
end
|
||||
end
|
||||
|
||||
context 'when enabled' do
|
||||
before do
|
||||
pre_condition << "class { 'ceilometer::db': }"
|
||||
@ -15,6 +48,11 @@ describe 'ceilometer::collector' do
|
||||
|
||||
it { is_expected.to contain_class('ceilometer::params') }
|
||||
|
||||
it 'configures ceilometer-collector server' do
|
||||
is_expected.to contain_ceilometer_config('collector/udp_address').with_value( '0.0.0.0' )
|
||||
is_expected.to contain_ceilometer_config('collector/udp_port').with_value( '4952' )
|
||||
end
|
||||
|
||||
it 'installs ceilometer-collector package' do
|
||||
is_expected.to contain_package(platform_params[:collector_package_name]).with(
|
||||
:ensure => 'present'
|
||||
@ -44,7 +82,6 @@ describe 'ceilometer::collector' do
|
||||
|
||||
# Catalog compilation does not crash for lack of ceilometer::db
|
||||
it { is_expected.to compile }
|
||||
|
||||
it 'configures ceilometer-collector service' do
|
||||
is_expected.to contain_service('ceilometer-collector').with(
|
||||
:ensure => 'stopped',
|
||||
|
Loading…
x
Reference in New Issue
Block a user