Support new [polling] options

Depends-on: https://review.opendev.org/921955
Change-Id: I9707273bd5bbe6a92ee6e2916f930f43d9fc81fe
This commit is contained in:
Takashi Kajinami 2024-10-04 11:27:32 +09:00
parent be33b5e0da
commit 86af102f74
3 changed files with 45 additions and 16 deletions

View File

@ -86,6 +86,20 @@
# (Optional) Identify user and project names from polled metrics.
# Defaults to $facts['os_service_default'].
#
# [*enable_notifications*]
# (Optional) Whether the polling service should be sending notifications.
# Defaults to $facts['os_service_default'].
#
# [*enable_prometheus_exporter*]
# (Optional) Alllow this polling instance to expose directly the retrieved
# metrics in Prometheus format.
# Defaults to $facts['os_service_default'].
#
# [*prometheus_listen_addresses*]
# (Optional) A list of ipaddr:port combintations on which the exported
# metrics will be exposed.
# Defaults to $facts['os_service_default'].
#
# [*pollsters_definitions_dirs*]
# (Optional) List of directories with YAML files used to create pollsters.
# Defaults to $facts['os_service_default'].
@ -109,6 +123,9 @@ class ceilometer::agent::polling (
$cfg_file = $facts['os_service_default'],
$batch_size = $facts['os_service_default'],
$tenant_name_discovery = $facts['os_service_default'],
$enable_notifications = $facts['os_service_default'],
$enable_prometheus_exporter = $facts['os_service_default'],
$prometheus_listen_addresses = $facts['os_service_default'],
$pollsters_definitions_dirs = $facts['os_service_default'],
) inherits ceilometer {
@ -219,9 +236,12 @@ class ceilometer::agent::polling (
}
ceilometer_config {
'polling/batch_size': value => $batch_size;
'polling/tenant_name_discovery': value => $tenant_name_discovery;
'polling/pollsters_definitions_dirs': value => join(any2array($pollsters_definitions_dirs), ',');
'polling/batch_size': value => $batch_size;
'polling/tenant_name_discovery': value => $tenant_name_discovery;
'polling/pollsters_definitions_dirs': value => join(any2array($pollsters_definitions_dirs), ',');
'polling/enable_notifications': value => $enable_notifications;
'polling/enable_prometheus_exporter': value => $enable_prometheus_exporter;
'polling/prometheus_listen_addresses': value => join(any2array($prometheus_listen_addresses), ',');
}
if $manage_service {

View File

@ -0,0 +1,10 @@
---
features:
- |
The following parameters have been added to
the ``ceilometer::agent::polling`` class.
- ``enable_notifications``
- ``enable_prometheus_exporter``
- ``prometheus_listen_addresses``

View File

@ -73,6 +73,9 @@ describe 'ceilometer::agent::polling' do
it { should contain_ceilometer_config('polling/batch_size').with_value('<SERVICE DEFAULT>') }
it { should_not contain_file('polling') }
it { should contain_ceilometer_config('polling/tenant_name_discovery').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/enable_notifications').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/enable_prometheus_exporter').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/prometheus_listen_addresses').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/pollsters_definitions_dirs').with_value('<SERVICE DEFAULT>') }
it { should contain_ceilometer_config('polling/cfg_file').with_value('<SERVICE DEFAULT>') }
end
@ -103,26 +106,22 @@ describe 'ceilometer::agent::polling' do
}
end
context 'when tenant_name_discovery is set' do
context 'when common parameters are set' do
before do
params.merge!(
:tenant_name_discovery => true
:tenant_name_discovery => true,
:enable_notifications => true,
:enable_prometheus_exporter => false,
:prometheus_listen_addresses => ['127.0.0.1:9101'],
:pollsters_definitions_dirs => ['/etc/ceilometer/pollsters.d', '/etc/ceilometer/mypollsters.d']
)
end
it {
should contain_ceilometer_config('polling/tenant_name_discovery').with_value(true)
}
end
context 'when pollsters_definitions_dirs is set' do
before do
params.merge!(
:pollsters_definitions_dirs => ['/etc/ceilometer/pollsters.d', '/etc/ceilometer/mypollsters.d']
)
end
it {
should contain_ceilometer_config('polling/enable_notifications').with_value(true)
should contain_ceilometer_config('polling/enable_prometheus_exporter').with_value(false)
should contain_ceilometer_config('polling/prometheus_listen_addresses').with_value('127.0.0.1:9101')
should contain_ceilometer_config('polling/pollsters_definitions_dirs').with_value(
'/etc/ceilometer/pollsters.d,/etc/ceilometer/mypollsters.d')
}