From 0f17f7553071d0c8abbcdf89ea4cd85aece7113a Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 19 Aug 2021 21:19:58 +0900 Subject: [PATCH] Support more _client options Change-Id: Iab36bc2ab6bb065035dbf4c88dbfabf6f5b4349e --- manifests/gnocchi_client.pp | 34 ++++++++++++++ manifests/ironic_client.pp | 34 ++++++++++++++ manifests/keystone_client.pp | 28 +++++++++++ manifests/placement_client.pp | 34 ++++++++++++++ .../notes/new-client-9f675a778c7da5b0.yaml | 9 ++++ spec/classes/watcher_gnocchi_client_spec.rb | 46 +++++++++++++++++++ spec/classes/watcher_ironic_client_spec.rb | 46 +++++++++++++++++++ spec/classes/watcher_keystone_client_spec.rb | 43 +++++++++++++++++ spec/classes/watcher_placement_client_spec.rb | 46 +++++++++++++++++++ 9 files changed, 320 insertions(+) create mode 100644 manifests/gnocchi_client.pp create mode 100644 manifests/ironic_client.pp create mode 100644 manifests/keystone_client.pp create mode 100644 manifests/placement_client.pp create mode 100644 releasenotes/notes/new-client-9f675a778c7da5b0.yaml create mode 100644 spec/classes/watcher_gnocchi_client_spec.rb create mode 100644 spec/classes/watcher_ironic_client_spec.rb create mode 100644 spec/classes/watcher_keystone_client_spec.rb create mode 100644 spec/classes/watcher_placement_client_spec.rb diff --git a/manifests/gnocchi_client.pp b/manifests/gnocchi_client.pp new file mode 100644 index 0000000..b11bb5a --- /dev/null +++ b/manifests/gnocchi_client.pp @@ -0,0 +1,34 @@ +# == Class: watcher::gnocchi_client +# +# Configure the gnocchi_client options +# +# === Parameters +# +# [*api_version*] +# (Optional) Version of Gnocchi API to use in gnocchiclient. +# Defaults to $::os_service_default +# +# [*endpoint_type*] +# (Optional) Type of endpoint to use in gnocchiclient. +# Defaults to $::os_service_default +# +# [*region_name*] +# (Optional) Region in Identify service catalog to use for communication +# with the OpenStack service. +# Defaults to $::os_service_default. +# +class watcher::gnocchi_client ( + $api_version = $::os_service_default, + $endpoint_type = $::os_service_default, + $region_name = $::os_service_default, +) { + + include watcher::deps + include watcher::params + + watcher_config { + 'gnocchi_client/api_version': value => $api_version; + 'gnocchi_client/endpoint_type': value => $endpoint_type; + 'gnocchi_client/region_name': value => $region_name; + } +} diff --git a/manifests/ironic_client.pp b/manifests/ironic_client.pp new file mode 100644 index 0000000..3d4cf82 --- /dev/null +++ b/manifests/ironic_client.pp @@ -0,0 +1,34 @@ +# == Class: watcher::ironic_client +# +# Configure the ironic_client options +# +# === Parameters +# +# [*api_version*] +# (Optional) Version of Ironic API to use in ironicclient. +# Defaults to $::os_service_default +# +# [*endpoint_type*] +# (Optional) Type of endpoint to use in ironicclient. +# Defaults to $::os_service_default +# +# [*region_name*] +# (Optional) Region in Identify service catalog to use for communication +# with the OpenStack service. +# Defaults to $::os_service_default. +# +class watcher::ironic_client ( + $api_version = $::os_service_default, + $endpoint_type = $::os_service_default, + $region_name = $::os_service_default, +) { + + include watcher::deps + include watcher::params + + watcher_config { + 'ironic_client/api_version': value => $api_version; + 'ironic_client/endpoint_type': value => $endpoint_type; + 'ironic_client/region_name': value => $region_name; + } +} diff --git a/manifests/keystone_client.pp b/manifests/keystone_client.pp new file mode 100644 index 0000000..c8b01ba --- /dev/null +++ b/manifests/keystone_client.pp @@ -0,0 +1,28 @@ +# == Class: watcher::keystone_client +# +# Configure the keystone_client options +# +# === Parameters +# +# [*endpoint_type*] +# (Optional) Type of endpoint to use in keystoneclient. +# Defaults to $::os_service_default +# +# [*region_name*] +# (Optional) Region in Identify service catalog to use for communication +# with the OpenStack service. +# Defaults to $::os_service_default. +# +class watcher::keystone_client ( + $endpoint_type = $::os_service_default, + $region_name = $::os_service_default, +) { + + include watcher::deps + include watcher::params + + watcher_config { + 'keystone_client/endpoint_type': value => $endpoint_type; + 'keystone_client/region_name': value => $region_name; + } +} diff --git a/manifests/placement_client.pp b/manifests/placement_client.pp new file mode 100644 index 0000000..4223809 --- /dev/null +++ b/manifests/placement_client.pp @@ -0,0 +1,34 @@ +# == Class: watcher::placement_client +# +# Configure the placement_client options +# +# === Parameters +# +# [*api_version*] +# (Optional) Microversion of placement API when using placement service. +# Defaults to $::os_service_default +# +# [*interface*] +# (Optional) Type of endpoint when using placement service. +# Defaults to $::os_service_default +# +# [*region_name*] +# (Optional) Region in Identify service catalog to use for communication +# with the OpenStack service. +# Defaults to $::os_service_default. +# +class watcher::placement_client ( + $api_version = $::os_service_default, + $interface = $::os_service_default, + $region_name = $::os_service_default, +) { + + include watcher::deps + include watcher::params + + watcher_config { + 'placement_client/api_version': value => $api_version; + 'placement_client/interface': value => $interface; + 'placement_client/region_name': value => $region_name; + } +} diff --git a/releasenotes/notes/new-client-9f675a778c7da5b0.yaml b/releasenotes/notes/new-client-9f675a778c7da5b0.yaml new file mode 100644 index 0000000..02d0279 --- /dev/null +++ b/releasenotes/notes/new-client-9f675a778c7da5b0.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + The following new classes have been added. + + - ``watcher::gnocchi_client`` + - ``watcher::ironic_client`` + - ``watcher::keystone_client`` + - ``watcher::placement_client`` diff --git a/spec/classes/watcher_gnocchi_client_spec.rb b/spec/classes/watcher_gnocchi_client_spec.rb new file mode 100644 index 0000000..73fd763 --- /dev/null +++ b/spec/classes/watcher_gnocchi_client_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe 'watcher::gnocchi_client' do + + shared_examples 'watcher::gnocchi_client' do + context 'with defaults' do + let :params do + {} + end + + it 'should set the defaults' do + should contain_watcher_config('gnocchi_client/api_version').with_value('') + should contain_watcher_config('gnocchi_client/endpoint_type').with_value('') + should contain_watcher_config('gnocchi_client/region_name').with_value('') + end + end + + context 'with parameters overridden' do + let :params do + { + :api_version => 1, + :endpoint_type => 'publicURL', + :region_name => 'regionOne' + } + end + + it 'should set the defaults' do + should contain_watcher_config('gnocchi_client/api_version').with_value(1) + should contain_watcher_config('gnocchi_client/endpoint_type').with_value('publicURL') + should contain_watcher_config('gnocchi_client/region_name').with_value('regionOne') + 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 'watcher::gnocchi_client' + end + end + +end diff --git a/spec/classes/watcher_ironic_client_spec.rb b/spec/classes/watcher_ironic_client_spec.rb new file mode 100644 index 0000000..10b2bb2 --- /dev/null +++ b/spec/classes/watcher_ironic_client_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe 'watcher::ironic_client' do + + shared_examples 'watcher::ironic_client' do + context 'with defaults' do + let :params do + {} + end + + it 'should set the defaults' do + should contain_watcher_config('ironic_client/api_version').with_value('') + should contain_watcher_config('ironic_client/endpoint_type').with_value('') + should contain_watcher_config('ironic_client/region_name').with_value('') + end + end + + context 'with parameters overridden' do + let :params do + { + :api_version => 1, + :endpoint_type => 'publicURL', + :region_name => 'regionOne' + } + end + + it 'should set the defaults' do + should contain_watcher_config('ironic_client/api_version').with_value(1) + should contain_watcher_config('ironic_client/endpoint_type').with_value('publicURL') + should contain_watcher_config('ironic_client/region_name').with_value('regionOne') + 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 'watcher::ironic_client' + end + end + +end diff --git a/spec/classes/watcher_keystone_client_spec.rb b/spec/classes/watcher_keystone_client_spec.rb new file mode 100644 index 0000000..1d0f7ca --- /dev/null +++ b/spec/classes/watcher_keystone_client_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe 'watcher::keystone_client' do + + shared_examples 'watcher::keystone_client' do + context 'with defaults' do + let :params do + {} + end + + it 'should set the defaults' do + should contain_watcher_config('keystone_client/endpoint_type').with_value('') + should contain_watcher_config('keystone_client/region_name').with_value('') + end + end + + context 'with parameters overridden' do + let :params do + { + :endpoint_type => 'publicURL', + :region_name => 'regionOne' + } + end + + it 'should set the defaults' do + should contain_watcher_config('keystone_client/endpoint_type').with_value('publicURL') + should contain_watcher_config('keystone_client/region_name').with_value('regionOne') + 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 'watcher::keystone_client' + end + end + +end diff --git a/spec/classes/watcher_placement_client_spec.rb b/spec/classes/watcher_placement_client_spec.rb new file mode 100644 index 0000000..ebed559 --- /dev/null +++ b/spec/classes/watcher_placement_client_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe 'watcher::placement_client' do + + shared_examples 'watcher::placement_client' do + context 'with defaults' do + let :params do + {} + end + + it 'should set the defaults' do + should contain_watcher_config('placement_client/api_version').with_value('') + should contain_watcher_config('placement_client/interface').with_value('') + should contain_watcher_config('placement_client/region_name').with_value('') + end + end + + context 'with parameters overridden' do + let :params do + { + :api_version => 1, + :interface => 'publicURL', + :region_name => 'regionOne' + } + end + + it 'should set the defaults' do + should contain_watcher_config('placement_client/api_version').with_value(1) + should contain_watcher_config('placement_client/interface').with_value('publicURL') + should contain_watcher_config('placement_client/region_name').with_value('regionOne') + 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 'watcher::placement_client' + end + end + +end