From c770219b12e31a3fde7e3947c06cb4c68b1ed43a Mon Sep 17 00:00:00 2001 From: Alfredo Moralejo Date: Mon, 31 Oct 2016 08:11:37 -0400 Subject: [PATCH] Add magnum::clients class magnum configuration contains some service clients configuration section. In order to work properly, magnum requires at least to configure cinder_client/region_name. This patch adds a new manifest magnum::clients that take care of client basic configuration including region_name and endpoint_type. In future, more options can be added. Change-Id: Ic33aba69873e0aeb79546fe25f158604229a54a5 --- manifests/clients.pp | 44 +++++++++++++++ ...lients-configuration-758a5b8cb4c16e1a.yaml | 4 ++ spec/acceptance/basic_magnum_spec.rb | 2 + spec/classes/magnum_clients_spec.rb | 56 +++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 manifests/clients.pp create mode 100644 releasenotes/notes/add-clients-configuration-758a5b8cb4c16e1a.yaml create mode 100644 spec/classes/magnum_clients_spec.rb diff --git a/manifests/clients.pp b/manifests/clients.pp new file mode 100644 index 0000000..fe6a18c --- /dev/null +++ b/manifests/clients.pp @@ -0,0 +1,44 @@ +# == Class: magnum::clients +# +# Manages the clients configuration in magnum server +# +# === Parameters: +# +# [*region_name*] +# (optional) Region in Identity service catalog to use for communication +# with the OpenStack service. +# Defaults to RegionOne +# +# [*endpoint_type*] +# (optional) Type of endpoint in Identity service catalog to use for +# communication with the the OpenStack service. +# Defaults to publicURL +# +class magnum::clients ( + $region_name = 'RegionOne', + $endpoint_type = 'publicURL', +) { + + include ::magnum::params + + magnum_config { + 'cinder_client/region_name': value => $region_name; + 'barbican_client/region_name': value => $region_name; + 'glance_client/region_name': value => $region_name; + 'heat_client/region_name': value => $region_name; + 'magnum_client/region_name': value => $region_name; + 'neutron_client/region_name': value => $region_name; + 'nova_client/region_name': value => $region_name; + } + + magnum_config { + 'barbican_client/endpoint_type': value => $endpoint_type; + 'glance_client/endpoint_type': value => $endpoint_type; + 'heat_client/endpoint_type': value => $endpoint_type; + 'magnum_client/endpoint_type': value => $endpoint_type; + 'neutron_client/endpoint_type': value => $endpoint_type; + 'nova_client/endpoint_type': value => $endpoint_type; + } + + +} diff --git a/releasenotes/notes/add-clients-configuration-758a5b8cb4c16e1a.yaml b/releasenotes/notes/add-clients-configuration-758a5b8cb4c16e1a.yaml new file mode 100644 index 0000000..675018d --- /dev/null +++ b/releasenotes/notes/add-clients-configuration-758a5b8cb4c16e1a.yaml @@ -0,0 +1,4 @@ +--- +features: + - A new class magnum::clients have been added to configure the OpenStack + service clients used by magnum service. diff --git a/spec/acceptance/basic_magnum_spec.rb b/spec/acceptance/basic_magnum_spec.rb index 1c99b16..bbe8bb3 100755 --- a/spec/acceptance/basic_magnum_spec.rb +++ b/spec/acceptance/basic_magnum_spec.rb @@ -80,6 +80,8 @@ describe 'basic magnum' do class { '::magnum::certificates': cert_manager_type => 'local' } + + class { '::magnum::clients': } EOS # Run it twice to test for idempotency apply_manifest(pp, :catch_failures => true) diff --git a/spec/classes/magnum_clients_spec.rb b/spec/classes/magnum_clients_spec.rb new file mode 100644 index 0000000..e9d4781 --- /dev/null +++ b/spec/classes/magnum_clients_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe 'magnum::clients' do + + shared_examples 'magnum::clients' do + context 'with default parameters' do + it { is_expected.to contain_magnum_config('cinder_client/region_name').with_value('RegionOne') } + it { is_expected.to contain_magnum_config('barbican_client/region_name').with_value('RegionOne') } + it { is_expected.to contain_magnum_config('glance_client/region_name').with_value('RegionOne') } + it { is_expected.to contain_magnum_config('heat_client/region_name').with_value('RegionOne') } + it { is_expected.to contain_magnum_config('magnum_client/region_name').with_value('RegionOne') } + it { is_expected.to contain_magnum_config('neutron_client/region_name').with_value('RegionOne') } + it { is_expected.to contain_magnum_config('nova_client/region_name').with_value('RegionOne') } + it { is_expected.to contain_magnum_config('barbican_client/endpoint_type').with_value('publicURL') } + it { is_expected.to contain_magnum_config('glance_client/endpoint_type').with_value('publicURL') } + it { is_expected.to contain_magnum_config('heat_client/endpoint_type').with_value('publicURL') } + it { is_expected.to contain_magnum_config('magnum_client/endpoint_type').with_value('publicURL') } + it { is_expected.to contain_magnum_config('neutron_client/endpoint_type').with_value('publicURL') } + it { is_expected.to contain_magnum_config('nova_client/endpoint_type').with_value('publicURL') } + end + + context 'with specific parameters' do + let :params do + { :region_name => 'RegionTwo', + :endpoint_type => 'adminURL', + } + end + + it { is_expected.to contain_magnum_config('cinder_client/region_name').with_value('RegionTwo') } + it { is_expected.to contain_magnum_config('barbican_client/region_name').with_value('RegionTwo') } + it { is_expected.to contain_magnum_config('glance_client/region_name').with_value('RegionTwo') } + it { is_expected.to contain_magnum_config('heat_client/region_name').with_value('RegionTwo') } + it { is_expected.to contain_magnum_config('magnum_client/region_name').with_value('RegionTwo') } + it { is_expected.to contain_magnum_config('neutron_client/region_name').with_value('RegionTwo') } + it { is_expected.to contain_magnum_config('nova_client/region_name').with_value('RegionTwo') } + it { is_expected.to contain_magnum_config('barbican_client/endpoint_type').with_value('adminURL') } + it { is_expected.to contain_magnum_config('glance_client/endpoint_type').with_value('adminURL') } + it { is_expected.to contain_magnum_config('heat_client/endpoint_type').with_value('adminURL') } + it { is_expected.to contain_magnum_config('magnum_client/endpoint_type').with_value('adminURL') } + it { is_expected.to contain_magnum_config('neutron_client/endpoint_type').with_value('adminURL') } + it { is_expected.to contain_magnum_config('nova_client/endpoint_type').with_value('adminURL') } + 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_configures 'magnum::clients' + end + end +end