From 84343cebe85f8c177ed9970e99422c25068ac67c Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Robles Date: Mon, 13 Feb 2017 08:16:05 +0200 Subject: [PATCH] Make placement's os_interface configurable this exposes the os_interface option for the placement API configuration, which enables us to set the interface (public, internal or admin) to use for the placement API endpoint. Before, it was hardcoded to public, due to the keystoneauth1 library's defaults. The change was introduced by Ic996e596f8473c0b8626e8d0e92e1bf58044b4f8 Change-Id: I1c7fd3a32d04e2fafb3820d1c1f221f45c613c83 Related-Bug: #1663187 --- manifests/placement.pp | 7 ++ ...erface-config-option-cc6d444666f00111.yaml | 5 ++ spec/classes/nova_placement_spec.rb | 82 +++++++++++-------- 3 files changed, 62 insertions(+), 32 deletions(-) create mode 100644 releasenotes/notes/Add-nova-placement-interface-config-option-cc6d444666f00111.yaml diff --git a/manifests/placement.pp b/manifests/placement.pp index 15003e516..1ed8ec0c9 100644 --- a/manifests/placement.pp +++ b/manifests/placement.pp @@ -32,6 +32,11 @@ # through the OpenStack Identity service. # Defaults to 'RegionOne' # +# [*os_interface*] +# (optional) interface name name used for getting the keystone endpoint for +# the placement API. +# Defaults to $::os_service_default +# # [*username*] # (optional) Username for connecting to Nova Placement API service in admin context # through the OpenStack Identity service. @@ -48,6 +53,7 @@ class nova::placement( $auth_type = 'password', $auth_url = 'http://127.0.0.1:35357/v3', $os_region_name = 'RegionOne', + $os_interface = $::os_service_default, $project_domain_name = 'Default', $project_name = 'services', $user_domain_name = 'Default', @@ -64,6 +70,7 @@ class nova::placement( 'placement/user_domain_name': value => $user_domain_name; 'placement/username': value => $username; 'placement/os_region_name': value => $os_region_name; + 'placement/os_interface': value => $os_interface; } } diff --git a/releasenotes/notes/Add-nova-placement-interface-config-option-cc6d444666f00111.yaml b/releasenotes/notes/Add-nova-placement-interface-config-option-cc6d444666f00111.yaml new file mode 100644 index 000000000..14b2b9769 --- /dev/null +++ b/releasenotes/notes/Add-nova-placement-interface-config-option-cc6d444666f00111.yaml @@ -0,0 +1,5 @@ +--- +features: + - The os_interface option for the nova placement API is not configurable. + This allows nodes communicating with the placement API (such as the compute + nodes) to be able to choose which keystone endpoint's interface to use. diff --git a/spec/classes/nova_placement_spec.rb b/spec/classes/nova_placement_spec.rb index 14eb678f5..b63c88ae1 100644 --- a/spec/classes/nova_placement_spec.rb +++ b/spec/classes/nova_placement_spec.rb @@ -17,42 +17,60 @@ describe 'nova::placement' do { :password => 's3cr3t' } end - context 'with required parameters' do - it 'configures [placement] parameters in nova.conf' do - is_expected.to contain_nova_config('placement/password').with_value(params[:password]).with_secret(true) - is_expected.to contain_nova_config('placement/auth_type').with_value(default_params[:auth_type]) - is_expected.to contain_nova_config('placement/project_name').with_value(default_params[:project_name]) - is_expected.to contain_nova_config('placement/project_domain_name').with_value(default_params[:project_domain_name]) - is_expected.to contain_nova_config('placement/os_region_name').with_value(default_params[:os_region_name]) - is_expected.to contain_nova_config('placement/username').with_value(default_params[:username]) - is_expected.to contain_nova_config('placement/user_domain_name').with_value(default_params[:user_domain_name]) - is_expected.to contain_nova_config('placement/auth_url').with_value(default_params[:auth_url]) + shared_examples 'nova::placement' do + + context 'with required parameters' do + it 'configures [placement] parameters in nova.conf' do + is_expected.to contain_nova_config('placement/password').with_value(params[:password]).with_secret(true) + is_expected.to contain_nova_config('placement/auth_type').with_value(default_params[:auth_type]) + is_expected.to contain_nova_config('placement/project_name').with_value(default_params[:project_name]) + is_expected.to contain_nova_config('placement/project_domain_name').with_value(default_params[:project_domain_name]) + is_expected.to contain_nova_config('placement/os_region_name').with_value(default_params[:os_region_name]) + is_expected.to contain_nova_config('placement/os_interface').with_value('') + is_expected.to contain_nova_config('placement/username').with_value(default_params[:username]) + is_expected.to contain_nova_config('placement/user_domain_name').with_value(default_params[:user_domain_name]) + is_expected.to contain_nova_config('placement/auth_url').with_value(default_params[:auth_url]) + end end + + context 'when overriding class parameters' do + before do + params.merge!( + :auth_type => 'password', + :project_name => 'service', + :project_domain_name => 'default', + :os_region_name => 'RegionTwo', + :os_interface => 'internal', + :username => 'placement2', + :user_domain_name => 'default', + :auth_url => 'https://127.0.0.1:35357/v3', + ) + end + + it 'configures [placement] parameters in nova.conf' do + is_expected.to contain_nova_config('placement/password').with_value(params[:password]).with_secret(true) + is_expected.to contain_nova_config('placement/auth_type').with_value(params[:auth_type]) + is_expected.to contain_nova_config('placement/project_name').with_value(params[:project_name]) + is_expected.to contain_nova_config('placement/project_domain_name').with_value(params[:project_domain_name]) + is_expected.to contain_nova_config('placement/os_region_name').with_value(params[:os_region_name]) + is_expected.to contain_nova_config('placement/os_interface').with_value(params[:os_interface]) + is_expected.to contain_nova_config('placement/username').with_value(params[:username]) + is_expected.to contain_nova_config('placement/user_domain_name').with_value(params[:user_domain_name]) + is_expected.to contain_nova_config('placement/auth_url').with_value(params[:auth_url]) + end + end + end - context 'when overriding class parameters' do - before do - params.merge!( - :auth_type => 'password', - :project_name => 'service', - :project_domain_name => 'default', - :os_region_name => 'RegionTwo', - :username => 'placement2', - :user_domain_name => 'default', - :auth_url => 'https://127.0.0.1:35357/v3', - ) - 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 [placement] parameters in nova.conf' do - is_expected.to contain_nova_config('placement/password').with_value(params[:password]).with_secret(true) - is_expected.to contain_nova_config('placement/auth_type').with_value(params[:auth_type]) - is_expected.to contain_nova_config('placement/project_name').with_value(params[:project_name]) - is_expected.to contain_nova_config('placement/project_domain_name').with_value(params[:project_domain_name]) - is_expected.to contain_nova_config('placement/os_region_name').with_value(params[:os_region_name]) - is_expected.to contain_nova_config('placement/username').with_value(params[:username]) - is_expected.to contain_nova_config('placement/user_domain_name').with_value(params[:user_domain_name]) - is_expected.to contain_nova_config('placement/auth_url').with_value(params[:auth_url]) + it_behaves_like 'nova::placement' end end - end