Skip to content

Commit

Permalink
Adds ability to override service name for service catalog
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mike Dorman committed Sep 3, 2014
1 parent a432119 commit 1f27e17
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
14 changes: 11 additions & 3 deletions manifests/keystone/auth.pp
Expand Up @@ -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.
Expand All @@ -22,6 +23,7 @@
$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',
Expand All @@ -34,9 +36,15 @@
$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,
Expand All @@ -50,14 +58,14 @@
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}",
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/glance_keystone_auth_spec.rb
Expand Up @@ -116,4 +116,21 @@

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

0 comments on commit 1f27e17

Please sign in to comment.