commit 91133480d8824b35a2ebfbc69f81c57993913099 Author: Benedikt Trefzer Date: Fri Oct 2 15:42:54 2020 +0200 add fetcher::gnocchi class to configure the gnocchi tenant fetcher Change-Id: I4fd3366755c19ce95498442291ee4be1952f3853 diff --git a/manifests/fetcher/gnocchi.pp b/manifests/fetcher/gnocchi.pp new file mode 100644 index 0000000..f6dc9d8 --- /dev/null +++ b/manifests/fetcher/gnocchi.pp @@ -0,0 +1,57 @@ +# +# Class to configure the gnocchi tenant/project fetcher +# +# == Parameters +# [*scope_attribute*] +# Attribute from which scope_ids should be collected. (string value) +# +# [*resource_types*] +# List of gnocchi resource types. All if left blank (list value) +# +# [*gnocchi_auth_type*] +# Gnocchi auth type (keystone or basic). Keystone credentials can be +# specified through the "auth_section" parameter (string value) +# +# [*gnocchi_user*] +# Gnocchi user (for basic auth only) (string value) +# +# [*gnocchi_endpoint*] +# Gnocchi endpoint (for basic auth only) (string value) +# +# [*interface*] +# Endpoint URL type (for keystone auth only) (string value) +# +# [*region_name*] +# Region Name (string value) +# +# [*auth_type*] +# Authentication type to load (string value) +# [*auth_section*] +# Config Section from which to load plugin specific options (string +# value) +# +class cloudkitty::fetcher::gnocchi( + String $scope_attribute = $::os_service_default, + String $resource_types = $::os_service_default, + String $gnocchi_auth_type = $::os_service_default, + String $gnocchi_user = $::os_service_default, + String $gnocchi_endpoint = $::os_service_default, + String $interface = $::os_service_default, + String $region_name = $::os_service_default, + String $auth_type = $::os_service_default, + String $auth_section = $::os_service_default, +){ + include cloudkitty::deps + + cloudkitty_config { + 'fetcher_gnocchi/scope_attribute': value => $scope_attribute; + 'fetcher_gnocchi/resource_types': value => $resource_types; + 'fetcher_gnocchi/gnocchi_auth_type': value => $gnocchi_auth_type; + 'fetcher_gnocchi/gnocchi_user': value => $gnocchi_user; + 'fetcher_gnocchi/gnocchi_endpoint': value => $gnocchi_endpoint; + 'fetcher_gnocchi/interface': value => $interface; + 'fetcher_gnocchi/region_name': value => $region_name; + 'fetcher_gnocchi/auth_type': value => $auth_type; + 'fetcher_gnocchi/auth_section': value => $auth_section; + } +} diff --git a/releasenotes/notes/add_fetcher_gnocchi-cb561f1ee3371658.yaml b/releasenotes/notes/add_fetcher_gnocchi-cb561f1ee3371658.yaml new file mode 100644 index 0000000..c5c737b --- /dev/null +++ b/releasenotes/notes/add_fetcher_gnocchi-cb561f1ee3371658.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add cloudkitty::fetcher::gnocchi class to configure the gnocchi tenant fetcher. diff --git a/spec/classes/cloudkitty_fetcher_gnocchi_spec.rb b/spec/classes/cloudkitty_fetcher_gnocchi_spec.rb new file mode 100644 index 0000000..c94ffe6 --- /dev/null +++ b/spec/classes/cloudkitty_fetcher_gnocchi_spec.rb @@ -0,0 +1,63 @@ +require 'spec_helper' + +describe 'cloudkitty::fetcher::gnocchi' do + + let :params do + { :scope_attribute => '', + :resource_types => '', + :gnocchi_auth_type => '', + :gnocchi_user => '', + :gnocchi_endpoint => '', + :interface => '', + :region_name => '', + :auth_type => '', + :auth_section => '', + } + end + + + shared_examples_for 'cloudkitty::fetcher::gnocchi' do + it { should contain_class('cloudkitty::deps') } + + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/scope_attribute').with_value( params[:scope_attribute])} + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/resource_types').with_value( params[:resource_types])} + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/gnocchi_auth_type').with_value( params[:gnocchi_auth_type])} + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/gnocchi_user').with_value( params[:gnocchi_user])} + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/gnocchi_endpoint').with_value( params[:gnocchi_endpoint])} + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/interface').with_value( params[:interface])} + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/region_name').with_value( params[:region_name])} + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/auth_type').with_value( params[:auth_type])} + it { is_expected.to contain_cloudkitty_config('fetcher_gnocchi/auth_section').with_value( params[:auth_section])} + 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 + + context 'with default parameters' do + it_behaves_like 'cloudkitty::fetcher::gnocchi' + end + + context 'when overriding parameters' do + before do + params.merge!({ + :scope_attribute => 'project_id', + :resource_types => 'some_types', + :gnocchi_auth_type => 'basic', + :gnocchi_user => 'myuser', + :gnocchi_endpoint => 'https://somwhere/', + :interface => 'external', + :region_name => 'myregion', + :auth_type => 'typeA', + :auth_section => 'ks_auth', + }) + end + it_behaves_like 'cloudkitty::fetcher::gnocchi' + end + end + end +end