From 89923f7eb120a1139d13af84f15c04aef261db48 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 9 Nov 2021 00:10:06 +0900 Subject: [PATCH] Add support for the [service_types] parameters Change-Id: Ia81c9c3da067cacf131262a0ad9cfa575ff3c246 --- manifests/agent/polling/service_types.pp | 44 +++++++++++++++++ .../notes/service_types-2a672cdceff9227f.yaml | 5 ++ ...ometer_agent_polling_service_types_spec.rb | 47 +++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 manifests/agent/polling/service_types.pp create mode 100644 releasenotes/notes/service_types-2a672cdceff9227f.yaml create mode 100644 spec/classes/ceilometer_agent_polling_service_types_spec.rb diff --git a/manifests/agent/polling/service_types.pp b/manifests/agent/polling/service_types.pp new file mode 100644 index 00000000..19e017ea --- /dev/null +++ b/manifests/agent/polling/service_types.pp @@ -0,0 +1,44 @@ +# == Class: ceilometer::agent::polling::service_types +# +# Configure service_types parameters +# +# === Parameters +# +# [*glance*] +# (Optional) glance service type. +# Defaults to $::os_service_default +# +# [*neutron*] +# (Optional) neutron service type. +# Defaults to $::os_service_default +# +# [*nova*] +# (Optional) nova service type. +# Defaults to $::os_service_default +# +# [*swift*] +# (Optional) swift service type. +# Defaults to $::os_service_default +# +# [*cinder*] +# (Optional) cinder service type. +# Defaults to $::os_service_default +# +class ceilometer::agent::polling::service_types ( + $glance = $::os_service_default, + $neutron = $::os_service_default, + $nova = $::os_service_default, + $swift = $::os_service_default, + $cinder = $::os_service_default, +) { + + include ceilometer::deps + + ceilometer_config { + 'service_types/glance': value => $glance; + 'service_types/neutron': value => $neutron; + 'service_types/nova': value => $nova; + 'service_types/swift': value => $swift; + 'service_types/cinder': value => $cinder; + } +} diff --git a/releasenotes/notes/service_types-2a672cdceff9227f.yaml b/releasenotes/notes/service_types-2a672cdceff9227f.yaml new file mode 100644 index 00000000..7d15bb06 --- /dev/null +++ b/releasenotes/notes/service_types-2a672cdceff9227f.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``ceilometer::agent::polling::service_types`` class, to manage + parameters in the ``[service_types]`` section, has been added. diff --git a/spec/classes/ceilometer_agent_polling_service_types_spec.rb b/spec/classes/ceilometer_agent_polling_service_types_spec.rb new file mode 100644 index 00000000..aa7c21a2 --- /dev/null +++ b/spec/classes/ceilometer_agent_polling_service_types_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe 'ceilometer::agent::polling::service_types' do + shared_examples 'ceilometer::agent::polling::service_types' do + context 'with default parameters' do + it 'configures the default values' do + is_expected.to contain_ceilometer_config('service_types/glance').with_value('') + is_expected.to contain_ceilometer_config('service_types/neutron').with_value('') + is_expected.to contain_ceilometer_config('service_types/nova').with_value('') + is_expected.to contain_ceilometer_config('service_types/swift').with_value('') + is_expected.to contain_ceilometer_config('service_types/cinder').with_value('') + end + end + + context 'with overridden parameters' do + let :params do + { + :glance => 'image', + :neutron => 'network', + :nova => 'compute', + :swift => 'object-store', + :cinder => 'volumev3', + } + end + + it 'configures the overridden values' do + is_expected.to contain_ceilometer_config('service_types/glance').with_value('image') + is_expected.to contain_ceilometer_config('service_types/neutron').with_value('network') + is_expected.to contain_ceilometer_config('service_types/nova').with_value('compute') + is_expected.to contain_ceilometer_config('service_types/swift').with_value('object-store') + is_expected.to contain_ceilometer_config('service_types/cinder').with_value('volumev3') + end + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge(OSDefaults.get_facts()) + end + + it_behaves_like 'ceilometer::agent::polling::service_types' + end + end +end