Change default service_name to 'swift'

While we were already able to pick an independent auth_name and
service_name; the service_name was defaulting to auth_name. Now it
has a value of its own to be consistent with other modules.

Change-Id: I24e091d509775a11b42298185db71ca00b94b4fe
Related-Bug: #1590040
This commit is contained in:
Marcellin Fom Tchassem 2016-06-07 20:54:47 -05:00
parent fbc530a9d3
commit ce3bd6fd8f
3 changed files with 29 additions and 27 deletions

View File

@ -49,13 +49,11 @@
#
# [*service_name*]
# (optional) Name of the service.
# Defaults to the value of auth_name, but must differ from the value
# of service_name_s3.
# Defaults to 'swift'
#
# [*service_name_s3*]
# (optional) Name of the s3 service.
# Defaults to the value of auth_name_s3, but must differ from the value
# of service_name.
# Defaults to 'swift_s3'
#
# [*service_description*]
# (optional) Description for keystone service.
@ -157,8 +155,8 @@ class swift::keystone::auth(
$email = 'swift@localhost',
$region = 'RegionOne',
$operator_roles = ['admin', 'SwiftOperator'],
$service_name = undef,
$service_name_s3 = undef,
$service_name = 'swift',
$service_name_s3 = 'swift_s3',
$service_description = 'Openstack Object-Store Service',
$service_description_s3 = 'Openstack S3 Service',
$configure_endpoint = true,
@ -277,27 +275,24 @@ class swift::keystone::auth(
$internal_url_s3_real = $internal_url_s3
}
$real_service_name = pick($service_name, $auth_name)
$real_service_name_s3 = pick($service_name_s3, "${auth_name}_s3")
if $real_service_name == $real_service_name_s3 {
fail('cinder::keystone::auth parameters service_name and service_name_s3 must be different.')
if $service_name == $service_name_s3 {
fail('swift::keystone::auth parameters service_name and service_name_s3 must be different.')
}
# Establish that keystone auth and endpoints are properly setup before
# managing any type of swift related service.
if $configure_endpoint {
Keystone_endpoint["${region}/${real_service_name}::object-store"] -> Swift::Service<||>
Keystone_endpoint["${region}/${service_name}::object-store"] -> Swift::Service<||>
}
if $configure_s3_endpoint {
Keystone_endpoint["${region}/${real_service_name_s3}::s3"] -> Swift::Service<||>
Keystone_endpoint["${region}/${service_name_s3}::s3"] -> Swift::Service<||>
}
keystone::resource::service_identity { 'swift':
configure_endpoint => $configure_endpoint,
configure_user => $configure_user,
configure_user_role => $configure_user_role,
service_name => $real_service_name,
service_name => $service_name,
service_type => 'object-store',
service_description => $service_description,
region => $region,
@ -315,7 +310,7 @@ class swift::keystone::auth(
configure_user_role => false,
configure_endpoint => $configure_s3_endpoint,
configure_service => $configure_s3_endpoint,
service_name => $real_service_name_s3,
service_name => $service_name_s3,
service_type => 's3',
service_description => $service_description_s3,
region => $region,

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

@ -21,6 +21,8 @@ describe 'swift::keystone::auth' do
:public_url_s3 => 'http://127.0.0.1:8080',
:admin_url_s3 => 'http://127.0.0.1:8080',
:internal_url_s3 => 'http://127.0.0.1:8080',
:service_name => 'swift',
:service_name_s3 => 'swift_s3',
}
end
@ -57,14 +59,14 @@ describe 'swift::keystone::auth' do
it { is_expected.to contain_keystone_role(role_name).with_ensure('present') }
end
it { is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}::object-store").with(
it { is_expected.to contain_keystone_endpoint("#{params[:region]}/#{default_params[:service_name]}::object-store").with(
:ensure => 'present',
:public_url => params[:public_url],
:admin_url => params[:admin_url],
:internal_url => params[:internal_url],
)}
it { is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}_s3::s3").with(
it { is_expected.to contain_keystone_endpoint("#{params[:region]}/#{default_params[:service_name_s3]}::s3").with(
:ensure => 'present',
:public_url => params[:public_url_s3],
:admin_url => params[:admin_url_s3],
@ -107,6 +109,8 @@ describe 'swift::keystone::auth' do
:internal_protocol => 'https',
:internal_address => 'internal.example.org',
:endpoint_prefix => 'KEY_AUTH',
:service_name => 'swift',
:service_name_s3 => 'swift_s3'
})
end
@ -114,14 +118,14 @@ describe 'swift::keystone::auth' do
default_params.merge( params )
end
it { is_expected.to contain_keystone_endpoint("#{p[:region]}/#{p[:auth_name]}::object-store").with(
it { is_expected.to contain_keystone_endpoint("#{p[:region]}/#{p[:service_name]}::object-store").with(
:ensure => 'present',
:public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:public_port]}/v1/#{p[:endpoint_prefix]}_%(tenant_id)s",
:admin_url => "#{p[:admin_protocol]}://#{p[:admin_address]}:#{p[:port]}",
:internal_url => "#{p[:internal_protocol]}://#{p[:internal_address]}:#{p[:port]}/v1/#{p[:endpoint_prefix]}_%(tenant_id)s"
)}
it { is_expected.to contain_keystone_endpoint("#{p[:region]}/#{p[:auth_name]}_s3::s3").with(
it { is_expected.to contain_keystone_endpoint("#{p[:region]}/#{p[:service_name_s3]}::s3").with(
:ensure => 'present',
:public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:port]}",
:admin_url => "#{p[:admin_protocol]}://#{p[:admin_address]}:#{p[:port]}",
@ -136,10 +140,11 @@ describe 'swift::keystone::auth' do
end
context 'when user configuration is set to default' do
it { is_expected.to contain_keystone_user(p[:auth_name]).with(
:ensure => 'present',
:password => p[:password],
:email => p[:email]
:email => p[:email],
)}
it { is_expected.to contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}").with(
@ -147,13 +152,13 @@ describe 'swift::keystone::auth' do
:roles => ['admin'],
)}
it { is_expected.to contain_keystone_service("#{p[:auth_name]}::object-store").with(
it { is_expected.to contain_keystone_service("swift::object-store").with(
:ensure => 'present',
:type => 'object-store',
:description => 'Openstack Object-Store Service'
)}
it { is_expected.to contain_keystone_service("#{p[:auth_name]}_s3::s3").with(
it { is_expected.to contain_keystone_service('swift_s3::s3').with(
:ensure => 'present',
:type => 's3',
:description => 'Openstack S3 Service'
@ -168,7 +173,7 @@ describe 'swift::keystone::auth' do
it { is_expected.to_not contain_keystone_user(p[:auth_name]) }
it { is_expected.to contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}") }
it { is_expected.to contain_keystone_service("#{p[:auth_name]}::object-store").with(
it { is_expected.to contain_keystone_service('swift::object-store').with(
:ensure => 'present',
:type => 'object-store',
:description => 'Openstack Object-Store Service'
@ -186,7 +191,7 @@ describe 'swift::keystone::auth' do
it { is_expected.to_not contain_keystone_user(p[:auth_name]) }
it { is_expected.to_not contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}") }
it { is_expected.to contain_keystone_service("#{p[:auth_name]}::object-store").with(
it { is_expected.to contain_keystone_service('swift::object-store').with(
:ensure => 'present',
:type => 'object-store',
:description => 'Openstack Object-Store Service'
@ -210,9 +215,6 @@ describe 'swift::keystone::auth' do
it_configures 'swift keystone auth'
end
context 'when overriding service name' do
before do
params.merge!({