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
This commit is contained in:
Juan Antonio Osorio Robles 2017-02-13 08:16:05 +02:00
parent 3e33a66628
commit 84343cebe8
3 changed files with 62 additions and 32 deletions

View File

@ -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;
}
}

View File

@ -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.

View File

@ -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('<SERVICE DEFAULT>')
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