Provide default service_name for keystone endpoint

This change updates the ceilometer::keystone::auth class to include a
default service_name of 'ceilometer' so that if a user changes the
auth_name, the service is still created as being related to
'ceilometer'.  This improves the user experiance when they want to
customize the usernames for services.

Change-Id: I472dd78c1b4fd8d3d4667aede56358cf6254617d
Closes-Bug: #1590040
This commit is contained in:
Alex Schultz 2016-06-07 10:52:42 -06:00
parent 736b796f65
commit 8363e51b3c
3 changed files with 17 additions and 11 deletions

View File

@ -29,7 +29,7 @@
# #
# [*service_name*] # [*service_name*]
# (Optional) Name of the service. # (Optional) Name of the service.
# Defaults to value of auth_name. # Defaults to 'ceilometer'.
# #
# [*service_type*] # [*service_type*]
# (Optional) Type of service. Optional. # (Optional) Type of service. Optional.
@ -76,7 +76,7 @@ class ceilometer::keystone::auth (
$auth_name = 'ceilometer', $auth_name = 'ceilometer',
$configure_user = true, $configure_user = true,
$configure_user_role = true, $configure_user_role = true,
$service_name = undef, $service_name = 'ceilometer',
$service_type = 'metering', $service_type = 'metering',
$service_description = 'Openstack Metering Service', $service_description = 'Openstack Metering Service',
$region = 'RegionOne', $region = 'RegionOne',
@ -89,16 +89,15 @@ class ceilometer::keystone::auth (
validate_string($password) validate_string($password)
$service_name_real = pick($service_name, $auth_name) ::keystone::resource::service_identity { 'ceilometer':
::keystone::resource::service_identity { $auth_name:
configure_user => $configure_user, configure_user => $configure_user,
configure_user_role => $configure_user_role, configure_user_role => $configure_user_role,
configure_endpoint => $configure_endpoint, configure_endpoint => $configure_endpoint,
service_type => $service_type, service_type => $service_type,
service_description => $service_description, service_description => $service_description,
service_name => $service_name_real, service_name => $service_name,
region => $region, region => $region,
auth_name => $auth_name,
password => $password, password => $password,
email => $email, email => $email,
tenant => $tenant, tenant => $tenant,

View File

@ -0,0 +1,5 @@
---
fixes:
- The keystone auth class has been updated to provide a default service_name
to allow a user to specify a custom auth_name that may not contain the
name of the service.

View File

@ -6,6 +6,7 @@ describe 'ceilometer::keystone::auth' do
{ {
:email => 'ceilometer@localhost', :email => 'ceilometer@localhost',
:auth_name => 'ceilometer', :auth_name => 'ceilometer',
:service_name => 'ceilometer',
:configure_endpoint => true, :configure_endpoint => true,
:service_type => 'metering', :service_type => 'metering',
:region => 'RegionOne', :region => 'RegionOne',
@ -43,14 +44,14 @@ describe 'ceilometer::keystone::auth' do
end end
it 'configures ceilometer service' do it 'configures ceilometer service' do
is_expected.to contain_keystone_service("#{default_params[:auth_name]}::#{default_params[:service_type]}").with( is_expected.to contain_keystone_service("#{default_params[:service_name]}::#{default_params[:service_type]}").with(
:ensure => 'present', :ensure => 'present',
:description => 'Openstack Metering Service' :description => 'Openstack Metering Service'
) )
end end
it 'configure ceilometer endpoints' do it 'configure ceilometer endpoints' do
is_expected.to contain_keystone_endpoint("#{default_params[:region]}/#{default_params[:auth_name]}::#{default_params[:service_type]}").with( is_expected.to contain_keystone_endpoint("#{default_params[:region]}/#{default_params[:service_name]}::#{default_params[:service_type]}").with(
:ensure => 'present', :ensure => 'present',
:public_url => default_params[:public_url], :public_url => default_params[:public_url],
:admin_url => default_params[:admin_url], :admin_url => default_params[:admin_url],
@ -70,6 +71,7 @@ describe 'ceilometer::keystone::auth' do
:public_url => 'https://public.host:443/ceilometer_pub', :public_url => 'https://public.host:443/ceilometer_pub',
:admin_url => 'https://admin.host/ceilometer_adm', :admin_url => 'https://admin.host/ceilometer_adm',
:internal_url => 'http://internal.host:80/ceilometer_int', :internal_url => 'http://internal.host:80/ceilometer_int',
:service_name => 'bubbles',
}) })
end end
@ -89,14 +91,14 @@ describe 'ceilometer::keystone::auth' do
end end
it 'configures ceilometer service' do it 'configures ceilometer service' do
is_expected.to contain_keystone_service("#{params[:auth_name]}::#{params[:service_type]}").with( is_expected.to contain_keystone_service("#{params[:service_name]}::#{params[:service_type]}").with(
:ensure => 'present', :ensure => 'present',
:description => 'Openstack Metering Service' :description => 'Openstack Metering Service'
) )
end end
it 'configure ceilometer endpoints' do it 'configure ceilometer endpoints' do
is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}::#{params[:service_type]}").with( is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:service_name]}::#{params[:service_type]}").with(
:ensure => 'present', :ensure => 'present',
:public_url => params[:public_url], :public_url => params[:public_url],
:admin_url => params[:admin_url], :admin_url => params[:admin_url],
@ -108,7 +110,7 @@ describe 'ceilometer::keystone::auth' do
before do before do
params.delete!(:configure_endpoint) params.delete!(:configure_endpoint)
it 'does not configure ceilometer endpoints' do it 'does not configure ceilometer endpoints' do
is_expected.to_not contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}::#{params[:service_type]}") is_expected.to_not contain_keystone_endpoint("#{params[:region]}/#{params[:service_name]}::#{params[:service_type]}")
end end
end end
end end