diff --git a/manifests/storage/incoming/file.pp b/manifests/storage/incoming/file.pp new file mode 100644 index 00000000..aab30b0c --- /dev/null +++ b/manifests/storage/incoming/file.pp @@ -0,0 +1,32 @@ +# +# gnocchi::storage::incoming::file +# +# File incoming storage driver for Gnocchi +# +# == Parameters +# +# [*file_basepath*] +# (optional) Path used to store gnocchi data files. +# This parameter can be used only when gnocchi::storage::file is not used. +# Defaults to undef +# +class gnocchi::storage::incoming::file( + $file_basepath = undef, +) { + + include gnocchi::deps + + # Because the file_basepath parameter is maintained by two classes, here we + # skip the parameter unless a user explicitly requests it, to avoid + # duplicated declaration. + if $file_basepath != undef { + gnocchi_config { + 'storage/file_basepath': value => $file_basepath; + } + } + + gnocchi_config { + 'incoming/driver': value => 'file'; + } + +} diff --git a/releasenotes/notes/file-incoming-driver-166fa94e9253781e.yaml b/releasenotes/notes/file-incoming-driver-166fa94e9253781e.yaml new file mode 100644 index 00000000..57b65345 --- /dev/null +++ b/releasenotes/notes/file-incoming-driver-166fa94e9253781e.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``gnocchi::storage::incoming::file`` class has been added. This + class can be used to set up the file incoming driver. diff --git a/spec/classes/gnocchi_storage_incoming_file_spec.rb b/spec/classes/gnocchi_storage_incoming_file_spec.rb new file mode 100644 index 00000000..8b79698f --- /dev/null +++ b/spec/classes/gnocchi_storage_incoming_file_spec.rb @@ -0,0 +1,47 @@ +# +# Unit tests for gnocchi::storage::incoming::file +# + +require 'spec_helper' + +describe 'gnocchi::storage::incoming::file' do + + let :params do + {} + end + + shared_examples_for 'gnocchi storage file' do + + context 'with file' do + it 'configures gnocchi incoming driver with file' do + is_expected.to contain_class('gnocchi::deps') + is_expected.to contain_gnocchi_config('incoming/driver').with_value('file') + is_expected.to_not contain_gnocchi_config('storage/file_basepath') + end + end + + context 'with file_basepath' do + let :params do + { :file_basepath => '/var/lib/gnocchi' } + end + + it 'configures gnocchi incoming driver with file' do + is_expected.to contain_gnocchi_config('incoming/driver').with_value('file') + is_expected.to contain_gnocchi_config('storage/file_basepath').with_value('/var/lib/gnocchi') + 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 'gnocchi storage file' + end + end + +end