Fix placement URL

In Debian, if using the UWSGI placement thing, then the URL for
the placement API is just:

http://127.0.0.1:8778/

and not:

http://127.0.0.1:8778/placement

This patch fixes the endpoint registration for that case.

Change-Id: I1d8a7dec1bcc5915d99e7e275dc63de0e727f907
This commit is contained in:
Thomas Goirand 2018-05-01 15:59:45 +02:00
parent 1c0a38e398
commit adbcfd709b
3 changed files with 181 additions and 138 deletions

View File

@ -63,13 +63,13 @@ class nova::keystone::auth_placement(
$region = 'RegionOne', $region = 'RegionOne',
$tenant = 'services', $tenant = 'services',
$email = 'placement@localhost', $email = 'placement@localhost',
$public_url = 'http://127.0.0.1/placement', $public_url = $::nova::params::placement_public_url,
$internal_url = 'http://127.0.0.1/placement', $internal_url = $::nova::params::placement_internal_url,
$admin_url = 'http://127.0.0.1/placement', $admin_url = $::nova::params::placement_admin_url,
$configure_endpoint = true, $configure_endpoint = true,
$configure_user = true, $configure_user = true,
$configure_user_role = true, $configure_user_role = true,
) { ) inherits nova::params {
include ::nova::deps include ::nova::deps

View File

@ -55,6 +55,9 @@ class nova::params {
$nova_log_group = 'root' $nova_log_group = 'root'
$nova_wsgi_script_path = '/var/www/cgi-bin/nova' $nova_wsgi_script_path = '/var/www/cgi-bin/nova'
$nova_api_wsgi_script_source = '/usr/bin/nova-api-wsgi' $nova_api_wsgi_script_source = '/usr/bin/nova-api-wsgi'
$placement_public_url = 'http://127.0.0.1/placement'
$placement_internal_url = 'http://127.0.0.1/placement'
$placement_admin_url = 'http://127.0.0.1/placement'
$placement_wsgi_script_source = '/usr/bin/nova-placement-api' $placement_wsgi_script_source = '/usr/bin/nova-placement-api'
$placement_httpd_config_file = '/etc/httpd/conf.d/00-nova-placement-api.conf' $placement_httpd_config_file = '/etc/httpd/conf.d/00-nova-placement-api.conf'
case $::operatingsystem { case $::operatingsystem {
@ -131,6 +134,9 @@ class nova::params {
$virtlock_service_name = undef $virtlock_service_name = undef
$virtlog_service_name = undef $virtlog_service_name = undef
$placement_service_name = 'nova-placement-api' $placement_service_name = 'nova-placement-api'
$placement_public_url = 'http://127.0.0.1'
$placement_internal_url = 'http://127.0.0.1'
$placement_admin_url = 'http://127.0.0.1'
} }
default: { default: {
$spicehtml5proxy_package_name = 'nova-spiceproxy' $spicehtml5proxy_package_name = 'nova-spiceproxy'
@ -141,6 +147,9 @@ class nova::params {
$virtlock_service_name = 'virtlockd' $virtlock_service_name = 'virtlockd'
$virtlog_service_name = 'virtlogd' $virtlog_service_name = 'virtlogd'
$placement_service_name = 'httpd' $placement_service_name = 'httpd'
$placement_public_url = 'http://127.0.0.1/placement'
$placement_internal_url = 'http://127.0.0.1/placement'
$placement_admin_url = 'http://127.0.0.1/placement'
} }
} }
$libvirt_service_name = 'libvirtd' $libvirt_service_name = 'libvirtd'

View File

@ -3,7 +3,7 @@ require 'spec_helper'
describe 'nova::keystone::auth_placement' do describe 'nova::keystone::auth_placement' do
let :params do let :params do
{:password => 'placement_password'} { :password => 'placement_password' }
end end
let :default_params do let :default_params do
@ -11,151 +11,185 @@ describe 'nova::keystone::auth_placement' do
:service_name => 'placement', :service_name => 'placement',
:region => 'RegionOne', :region => 'RegionOne',
:tenant => 'services', :tenant => 'services',
:email => 'placement@localhost', :email => 'placement@localhost' }
:public_url => 'http://127.0.0.1/placement',
:internal_url => 'http://127.0.0.1/placement',
:admin_url => 'http://127.0.0.1/placement' }
end end
context 'with default parameters' do shared_examples 'nova::keystone::auth_placement' do
context 'with default parameters' do
it { is_expected.to contain_keystone_user('placement').with(
:ensure => 'present',
:password => 'placement_password'
)}
it { is_expected.to contain_keystone_user('placement').with( it { is_expected.to contain_keystone_user_role('placement@services').with(
:ensure => 'present', :ensure => 'present',
:password => 'placement_password' :roles => ['admin']
) } )}
it { is_expected.to contain_keystone_user_role('placement@services').with( it { is_expected.to contain_keystone_service('placement::placement').with(
:ensure => 'present', :ensure => 'present',
:roles => ['admin'] :description => 'Openstack Placement Service'
)} )}
it { is_expected.to contain_keystone_service('placement::placement').with( it { is_expected.to contain_keystone_endpoint('RegionOne/placement::placement').with(
:ensure => 'present', :ensure => 'present',
:description => 'Openstack Placement Service' :public_url => platform_params[:public_url],
)} :admin_url => platform_params[:admin_url],
:internal_url => platform_params[:internal_url]
)}
end
context 'when setting auth name' do
before do
params.merge!( :auth_name => 'foo' )
end
it { is_expected.to contain_keystone_user('foo').with(
:ensure => 'present',
:password => 'placement_password'
)}
it { is_expected.to contain_keystone_user_role('foo@services').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('placement::placement').with(
:ensure => 'present',
:description => 'Openstack Placement Service'
)}
end
context 'when overriding endpoint parameters' do
before do
params.merge!(
:region => 'RegionTwo',
:public_url => 'https://10.0.0.1:9778',
:internal_url => 'https://10.0.0.3:9778',
:admin_url => 'https://10.0.0.2:9778',
)
end
it { is_expected.to contain_keystone_endpoint('RegionTwo/placement::placement').with(
:ensure => 'present',
:public_url => params[:public_url],
:internal_url => params[:internal_url],
:admin_url => params[:admin_url]
)}
end
describe 'when disabling endpoint configuration' do
before do
params.merge!( :configure_endpoint => false )
end
it { is_expected.to_not contain_keystone_endpoint('RegionOne/placement::placement') }
end
describe 'when disabling user configuration' do
before do
params.merge!( :configure_user => false )
end
it { is_expected.to_not contain_keystone_user('placement') }
it { is_expected.to contain_keystone_user_role('placement@services') }
it { is_expected.to contain_keystone_service('placement::placement').with(
:ensure => 'present',
:description => 'Openstack Placement Service'
)}
end
describe 'when disabling user and user role configuration' do
let :params do
{
:configure_user => false,
:configure_user_role => false,
:password => 'placement_password'
}
end
it { is_expected.to_not contain_keystone_user('placement') }
it { is_expected.to_not contain_keystone_user_role('placement@services') }
it { is_expected.to contain_keystone_service('placement::placement').with(
:ensure => 'present',
:description => 'Openstack Placement Service'
)}
end
describe 'when configuring nova-placement and the keystone endpoint' do
let :pre_condition do
"class { '::nova::keystone::authtoken':
password => 'secrete',
}
class { 'nova::api':}
include nova"
end
let :facts do
facts.merge({ :osfamily => "Debian"})
end
let :params do
{
:password => 'test'
}
end
end
describe 'when overriding service names' do
let :params do
{
:service_name => 'nova_service',
:password => 'placement_password'
}
end
it { is_expected.to contain_keystone_user('placement') }
it { is_expected.to contain_keystone_user_role('placement@services') }
it { is_expected.to contain_keystone_service('nova_service::placement') }
it { is_expected.to contain_keystone_endpoint('RegionOne/nova_service::placement') }
end
end
shared_examples 'nova::keystone::auth_placement on Debian' do
before do
facts.merge!( :os_package_type => 'debian' )
end
it { is_expected.to contain_keystone_endpoint('RegionOne/placement::placement').with( it { is_expected.to contain_keystone_endpoint('RegionOne/placement::placement').with(
:ensure => 'present', :ensure => 'present',
:public_url => 'http://127.0.0.1/placement', :public_url => platform_params[:public_url],
:admin_url => 'http://127.0.0.1/placement', :admin_url => platform_params[:admin_url],
:internal_url => 'http://127.0.0.1/placement' :internal_url => platform_params[:internal_url]
)}
end
context 'when setting auth name' do
before do
params.merge!( :auth_name => 'foo' )
end
it { is_expected.to contain_keystone_user('foo').with(
:ensure => 'present',
:password => 'placement_password'
) }
it { is_expected.to contain_keystone_user_role('foo@services').with(
:ensure => 'present',
:roles => ['admin']
)}
it { is_expected.to contain_keystone_service('placement::placement').with(
:ensure => 'present',
:description => 'Openstack Placement Service'
)}
end
context 'when overriding endpoint parameters' do
before do
params.merge!(
:region => 'RegionTwo',
:public_url => 'https://10.0.0.1:9778',
:internal_url => 'https://10.0.0.3:9778',
:admin_url => 'https://10.0.0.2:9778',
)
end
it { is_expected.to contain_keystone_endpoint('RegionTwo/placement::placement').with(
:ensure => 'present',
:public_url => params[:public_url],
:internal_url => params[:internal_url],
:admin_url => params[:admin_url]
)}
end
describe 'when disabling endpoint configuration' do
before do
params.merge!( :configure_endpoint => false )
end
it { is_expected.to_not contain_keystone_endpoint('RegionOne/placement::placement') }
end
describe 'when disabling user configuration' do
before do
params.merge!( :configure_user => false )
end
it { is_expected.to_not contain_keystone_user('placement') }
it { is_expected.to contain_keystone_user_role('placement@services') }
it { is_expected.to contain_keystone_service('placement::placement').with(
:ensure => 'present',
:description => 'Openstack Placement Service'
)} )}
end end
describe 'when disabling user and user role configuration' do on_supported_os({
let :params do :supported_os => OSDefaults.get_supported_os
{ }).each do |os,facts|
:configure_user => false, context "on #{os}" do
:configure_user_role => false, let (:facts) do
:password => 'placement_password' facts.merge!(OSDefaults.get_facts())
} end
let(:platform_params) do
if facts[:os_package_type] == 'debian'
{ :public_url => 'http://127.0.0.1',
:internal_url => 'http://127.0.0.1',
:admin_url => 'http://127.0.0.1' }
else
{ :public_url => 'http://127.0.0.1/placement',
:internal_url => 'http://127.0.0.1/placement',
:admin_url => 'http://127.0.0.1/placement' }
end
end
it_behaves_like 'nova::keystone::auth_placement'
if facts[:operatingsystem] == 'Debian'
it_behaves_like 'nova::keystone::auth_placement on Debian'
end
end end
it { is_expected.to_not contain_keystone_user('placement') }
it { is_expected.to_not contain_keystone_user_role('placement@services') }
it { is_expected.to contain_keystone_service('placement::placement').with(
:ensure => 'present',
:description => 'Openstack Placement Service'
)}
end
describe 'when configuring nova-placement and the keystone endpoint' do
let :pre_condition do
"class { '::nova::keystone::authtoken':
password => 'secrete',
}
class { 'nova::api':}
include nova"
end
let :facts do
@default_facts.merge({ :osfamily => "Debian"})
end
let :params do
{
:password => 'test'
}
end
end
describe 'when overriding service names' do
let :params do
{
:service_name => 'nova_service',
:password => 'placement_password'
}
end
it { is_expected.to contain_keystone_user('placement') }
it { is_expected.to contain_keystone_user_role('placement@services') }
it { is_expected.to contain_keystone_service('nova_service::placement') }
it { is_expected.to contain_keystone_endpoint('RegionOne/nova_service::placement') }
end end
end end