Merge "Change default service_name to 'swift'"

This commit is contained in:
Jenkins
2016-06-21 15:34:02 +00:00
committed by Gerrit Code Review
3 changed files with 29 additions and 27 deletions

View File

@@ -49,13 +49,11 @@
# #
# [*service_name*] # [*service_name*]
# (optional) Name of the service. # (optional) Name of the service.
# Defaults to the value of auth_name, but must differ from the value # Defaults to 'swift'
# of service_name_s3.
# #
# [*service_name_s3*] # [*service_name_s3*]
# (optional) Name of the s3 service. # (optional) Name of the s3 service.
# Defaults to the value of auth_name_s3, but must differ from the value # Defaults to 'swift_s3'
# of service_name.
# #
# [*service_description*] # [*service_description*]
# (optional) Description for keystone service. # (optional) Description for keystone service.
@@ -157,8 +155,8 @@ class swift::keystone::auth(
$email = 'swift@localhost', $email = 'swift@localhost',
$region = 'RegionOne', $region = 'RegionOne',
$operator_roles = ['admin', 'SwiftOperator'], $operator_roles = ['admin', 'SwiftOperator'],
$service_name = undef, $service_name = 'swift',
$service_name_s3 = undef, $service_name_s3 = 'swift_s3',
$service_description = 'Openstack Object-Store Service', $service_description = 'Openstack Object-Store Service',
$service_description_s3 = 'Openstack S3 Service', $service_description_s3 = 'Openstack S3 Service',
$configure_endpoint = true, $configure_endpoint = true,
@@ -277,27 +275,24 @@ class swift::keystone::auth(
$internal_url_s3_real = $internal_url_s3 $internal_url_s3_real = $internal_url_s3
} }
$real_service_name = pick($service_name, $auth_name) if $service_name == $service_name_s3 {
$real_service_name_s3 = pick($service_name_s3, "${auth_name}_s3") fail('swift::keystone::auth parameters service_name and service_name_s3 must be different.')
if $real_service_name == $real_service_name_s3 {
fail('cinder::keystone::auth parameters service_name and service_name_s3 must be different.')
} }
# Establish that keystone auth and endpoints are properly setup before # Establish that keystone auth and endpoints are properly setup before
# managing any type of swift related service. # managing any type of swift related service.
if $configure_endpoint { 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 { 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': keystone::resource::service_identity { 'swift':
configure_endpoint => $configure_endpoint, configure_endpoint => $configure_endpoint,
configure_user => $configure_user, configure_user => $configure_user,
configure_user_role => $configure_user_role, configure_user_role => $configure_user_role,
service_name => $real_service_name, service_name => $service_name,
service_type => 'object-store', service_type => 'object-store',
service_description => $service_description, service_description => $service_description,
region => $region, region => $region,
@@ -315,7 +310,7 @@ class swift::keystone::auth(
configure_user_role => false, configure_user_role => false,
configure_endpoint => $configure_s3_endpoint, configure_endpoint => $configure_s3_endpoint,
configure_service => $configure_s3_endpoint, configure_service => $configure_s3_endpoint,
service_name => $real_service_name_s3, service_name => $service_name_s3,
service_type => 's3', service_type => 's3',
service_description => $service_description_s3, service_description => $service_description_s3,
region => $region, 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', :public_url_s3 => 'http://127.0.0.1:8080',
:admin_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', :internal_url_s3 => 'http://127.0.0.1:8080',
:service_name => 'swift',
:service_name_s3 => 'swift_s3',
} }
end end
@@ -57,14 +59,14 @@ describe 'swift::keystone::auth' do
it { is_expected.to contain_keystone_role(role_name).with_ensure('present') } it { is_expected.to contain_keystone_role(role_name).with_ensure('present') }
end 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', :ensure => 'present',
:public_url => params[:public_url], :public_url => params[:public_url],
:admin_url => params[:admin_url], :admin_url => params[:admin_url],
:internal_url => params[:internal_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', :ensure => 'present',
:public_url => params[:public_url_s3], :public_url => params[:public_url_s3],
:admin_url => params[:admin_url_s3], :admin_url => params[:admin_url_s3],
@@ -107,6 +109,8 @@ describe 'swift::keystone::auth' do
:internal_protocol => 'https', :internal_protocol => 'https',
:internal_address => 'internal.example.org', :internal_address => 'internal.example.org',
:endpoint_prefix => 'KEY_AUTH', :endpoint_prefix => 'KEY_AUTH',
:service_name => 'swift',
:service_name_s3 => 'swift_s3'
}) })
end end
@@ -114,14 +118,14 @@ describe 'swift::keystone::auth' do
default_params.merge( params ) default_params.merge( params )
end 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', :ensure => 'present',
:public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:public_port]}/v1/#{p[:endpoint_prefix]}_%(tenant_id)s", :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]}", :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" :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', :ensure => 'present',
:public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:port]}", :public_url => "#{p[:public_protocol]}://#{p[:public_address]}:#{p[:port]}",
:admin_url => "#{p[:admin_protocol]}://#{p[:admin_address]}:#{p[:port]}", :admin_url => "#{p[:admin_protocol]}://#{p[:admin_address]}:#{p[:port]}",
@@ -136,10 +140,11 @@ describe 'swift::keystone::auth' do
end end
context 'when user configuration is set to default' do context 'when user configuration is set to default' do
it { is_expected.to contain_keystone_user(p[:auth_name]).with( it { is_expected.to contain_keystone_user(p[:auth_name]).with(
:ensure => 'present', :ensure => 'present',
:password => p[:password], :password => p[:password],
:email => p[:email] :email => p[:email],
)} )}
it { is_expected.to contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}").with( 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'], :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', :ensure => 'present',
:type => 'object-store', :type => 'object-store',
:description => 'Openstack Object-Store Service' :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', :ensure => 'present',
:type => 's3', :type => 's3',
:description => 'Openstack S3 Service' :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_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_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', :ensure => 'present',
:type => 'object-store', :type => 'object-store',
:description => 'Openstack Object-Store Service' :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(p[:auth_name]) }
it { is_expected.to_not contain_keystone_user_role("#{p[:auth_name]}@#{p[:tenant]}") } 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', :ensure => 'present',
:type => 'object-store', :type => 'object-store',
:description => 'Openstack Object-Store Service' :description => 'Openstack Object-Store Service'
@@ -210,9 +215,6 @@ describe 'swift::keystone::auth' do
it_configures 'swift keystone auth' it_configures 'swift keystone auth'
end end
context 'when overriding service name' do context 'when overriding service name' do
before do before do
params.merge!({ params.merge!({