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: Ic1699df4bf562390bd8c3196df03c2483cdf6ff1
Closes-bug: #1359755
This commit is contained in:
Rico Lin 2015-03-23 08:49:36 +08:00
parent feee104f7f
commit 57755f18d0
2 changed files with 25 additions and 2 deletions

View File

@ -66,6 +66,10 @@
# [*region*]
# Region for endpoint. Defaults to 'RegionOne'.
#
# [*service_name*]
# (optional) Name of the service.
# Defaults to the value of auth_name.
#
#
class trove::keystone::auth (
$password,
@ -73,6 +77,7 @@ class trove::keystone::auth (
$email = 'trove@localhost',
$tenant = 'services',
$configure_endpoint = true,
$service_name = undef,
$service_type = 'database',
$public_protocol = 'http',
$public_address = '127.0.0.1',
@ -85,8 +90,10 @@ class trove::keystone::auth (
$region = 'RegionOne'
) {
$real_service_name = pick($service_name, $auth_name)
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'trove-server' |>
Keystone_endpoint["${region}/${auth_name}"] ~> Service <| name == 'trove-server' |>
Keystone_endpoint["${region}/${real_service_name}"] ~> Service <| name == 'trove-server' |>
if ! $public_port {
$real_public_port = $port
@ -94,13 +101,15 @@ class trove::keystone::auth (
$real_public_port = $public_port
}
keystone::resource::service_identity { $auth_name:
keystone::resource::service_identity { 'trove':
configure_user => true,
configure_user_role => true,
configure_endpoint => $configure_endpoint,
service_name => $real_service_name,
service_type => $service_type,
service_description => 'Trove Database Service',
region => $region,
auth_name => $auth_name,
password => $password,
email => $email,
tenant => $tenant,

View File

@ -98,4 +98,18 @@ describe 'trove::keystone::auth' do
it { is_expected.to contain_keystone_service('trovey') }
it { is_expected.to contain_keystone_endpoint('RegionOne/trovey') }
end
describe 'when overriding service name' do
let :params do
{ :service_name => 'trove_service',
:auth_name => 'trove',
:password => 'trove_password' }
end
it { is_expected.to contain_keystone_user('trove') }
it { is_expected.to contain_keystone_user_role('trove@services') }
it { is_expected.to contain_keystone_service('trove_service') }
it { is_expected.to contain_keystone_endpoint('RegionOne/trove_service') }
end
end