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, separately from auth_name.

Change-Id: I142b9e944eacdeba8a029d7f15f067ef5f1f87a4
This commit is contained in:
Mike Dorman 2014-08-13 09:03:36 -06:00
parent a432119ff6
commit 1f27e17ea0
2 changed files with 28 additions and 3 deletions

View File

@ -6,6 +6,7 @@
# $auth_name :: identifier used for all keystone objects related to glance.
# Optional. Defaults to glance.
# $password :: password for glance user. Optional. Defaults to glance_password.
# $service_name :: name of the service. Optional. Defaults to value of auth_name.
# $service_type :: type of service to create. Optional. Defaults to image.
# $public_address :: Public address for endpoint. Optional. Defaults to 127.0.0.1.
# $admin_address :: Admin address for endpoint. Optional. Defaults to 127.0.0.1.
@ -22,6 +23,7 @@ class glance::keystone::auth(
$email = 'glance@localhost',
$auth_name = 'glance',
$configure_endpoint = true,
$service_name = undef,
$service_type = 'image',
$public_address = '127.0.0.1',
$admin_address = '127.0.0.1',
@ -34,9 +36,15 @@ class glance::keystone::auth(
$internal_protocol = 'http'
) {
if $service_name == undef {
$real_service_name = $auth_name
} else {
$real_service_name = $service_name
}
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'glance-registry' |>
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'glance-api' |>
Keystone_endpoint["${region}/${auth_name}"] ~> Service <| name == 'glance-api' |>
Keystone_endpoint["${region}/${real_service_name}"] ~> Service <| name == 'glance-api' |>
keystone_user { $auth_name:
ensure => present,
@ -50,14 +58,14 @@ class glance::keystone::auth(
roles => 'admin',
}
keystone_service { $auth_name:
keystone_service { $real_service_name:
ensure => present,
type => $service_type,
description => 'Openstack Image Service',
}
if $configure_endpoint {
keystone_endpoint { "${region}/${auth_name}":
keystone_endpoint { "${region}/${real_service_name}":
ensure => present,
public_url => "${public_protocol}://${public_address}:${port}",
admin_url => "${admin_protocol}://${admin_address}:${port}",

View File

@ -116,4 +116,21 @@ describe 'glance::keystone::auth' do
it { should contain_keystone_endpoint('RegionOne/glance').with_notify('Service[glance-api]') }
end
describe 'when overriding service name' do
let :params do
{
:service_name => 'glance_service',
:password => 'pass'
}
end
it { should contain_keystone_user('glance') }
it { should contain_keystone_user_role('glance@services') }
it { should contain_keystone_service('glance_service') }
it { should contain_keystone_endpoint('RegionOne/glance_service') }
end
end