Adds ability to override service name for service catalog

Instead of forcing the name of the service in the service catalog to
match auth_name, this allows the ability to explicitly set the service
name, spearately from auth_name.
If service_name is not specified, it's value defaults to the value
of auth_name (which maintains the current behavior.)

Change-Id: Ie586b2892c092a9694b067a9e0f28f36396de30d
Closes-bug: #1359755
This commit is contained in:
Rico Lin
2015-02-02 16:29:42 +08:00
parent 499386a89d
commit 9a45dff83c
2 changed files with 50 additions and 2 deletions

View File

@@ -17,6 +17,16 @@
# [*operator_roles*] # [*operator_roles*]
# Array of strings. List of roles Swift considers as admin. # Array of strings. List of roles Swift considers as admin.
# #
# [*service_name*]
# (optional) Name of the service.
# Defaults to the value of auth_name, but must differ from the value
# of service_name_s3.
#
# [*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.
#
class swift::keystone::auth( class swift::keystone::auth(
$auth_name = 'swift', $auth_name = 'swift',
$password = 'swift_password', $password = 'swift_password',
@@ -25,6 +35,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_s3 = undef,
$public_protocol = 'http', $public_protocol = 'http',
$public_address = '127.0.0.1', $public_address = '127.0.0.1',
$public_port = undef, $public_port = undef,
@@ -36,6 +48,12 @@ class swift::keystone::auth(
$configure_s3_endpoint = true, $configure_s3_endpoint = true,
$endpoint_prefix = 'AUTH', $endpoint_prefix = 'AUTH',
) { ) {
$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 ! $public_port { if ! $public_port {
$real_public_port = $port $real_public_port = $port
@@ -53,11 +71,13 @@ class swift::keystone::auth(
$real_internal_address = $internal_address $real_internal_address = $internal_address
} }
keystone::resource::service_identity { $auth_name: keystone::resource::service_identity { 'swift':
configure_endpoint => $configure_endpoint, configure_endpoint => $configure_endpoint,
service_name => $real_service_name,
service_type => 'object-store', service_type => 'object-store',
service_description => 'Openstack Object-Store Service', service_description => 'Openstack Object-Store Service',
region => $region, region => $region,
auth_name => $auth_name,
password => $password, password => $password,
email => $email, email => $email,
tenant => $tenant, tenant => $tenant,
@@ -66,11 +86,12 @@ class swift::keystone::auth(
internal_url => "${internal_protocol}://${real_internal_address}:${port}/v1/${endpoint_prefix}_%(tenant_id)s", internal_url => "${internal_protocol}://${real_internal_address}:${port}/v1/${endpoint_prefix}_%(tenant_id)s",
} }
keystone::resource::service_identity { "${auth_name}_s3": keystone::resource::service_identity { "swift_s3":
configure_user => false, configure_user => false,
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_type => 's3', service_type => 's3',
service_description => 'Openstack S3 Service', service_description => 'Openstack S3 Service',
region => $region, region => $region,

View File

@@ -138,4 +138,31 @@ describe 'swift::keystone::auth' do
it_configures 'swift keystone auth' it_configures 'swift keystone auth'
end end
context 'when overriding service name' do
before do
params.merge!({
:service_name => 'swift_service',
:service_name_s3 => 'swift_service_s3',
})
end
it 'configures correct user name' do
should contain_keystone_user('swift')
end
it 'configures correct user role' do
should contain_keystone_user_role('swift@services')
end
it 'configures correct service name' do
should contain_keystone_service('swift_service')
should contain_keystone_service('swift_service_s3')
end
it 'configures correct endpoint name' do
should contain_keystone_endpoint('RegionOne/swift_service')
should contain_keystone_endpoint('RegionOne/swift_service_s3')
end
end
end end