From 3a2b7e1acabdbb35292329f941b37f8bb9580c5a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Charlier?= Date: Thu, 6 Jun 2013 15:41:45 +0200 Subject: [PATCH] Add auth_admin_prefix support for ceilometer::api To support keystone urls like http://host:80/keystone/admin Implements blueprint serve-keystone-from-wsgi Change-Id: I68c17a5b76ed61b18337ee580fba63200d874792 --- manifests/api.pp | 32 ++++++++++++++++++++++------- spec/classes/ceilometer_api_spec.rb | 24 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/manifests/api.pp b/manifests/api.pp index 96de777..786fa1d 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -10,6 +10,11 @@ # [*keystone_port*] # keystone's admin endpoint port. Optional. Defaults to 35357 # +# [*keystone_auth_admin_prefix*] +# 'path' to the keystone admin endpoint. Optional. Defaults to false (empty) +# Define to a path starting with a '/' and without trailing '/'. +# Eg.: '/keystone/admin' to match keystone::wsgi::apache default. +# # [*keystone_protocol*] http/https # Optional. Defaults to https # @@ -23,13 +28,14 @@ # Mandatory. # class ceilometer::api ( - $enabled = true, - $keystone_host = '127.0.0.1', - $keystone_port = '35357', - $keystone_protocol = 'http', - $keystone_user = 'ceilometer', - $keystone_tenant = 'services', - $keystone_password = false, + $enabled = true, + $keystone_host = '127.0.0.1', + $keystone_port = '35357', + $keystone_auth_admin_prefix = false, + $keystone_protocol = 'http', + $keystone_user = 'ceilometer', + $keystone_tenant = 'services', + $keystone_password = false, ) { include ceilometer::params @@ -70,4 +76,16 @@ class ceilometer::api ( 'keystone_authtoken/admin_user' : value => $keystone_user; 'keystone_authtoken/admin_password' : value => $keystone_password; } + + if $keystone_auth_admin_prefix { + validate_re($keystone_auth_admin_prefix, '^(/.+[^/])?$') + ceilometer_config { + 'keystone_authtoken/auth_admin_prefix': value => $keystone_auth_admin_prefix; + } + } else { + ceilometer_config { + 'keystone_authtoken/auth_admin_prefix': ensure => absent; + } + } + } diff --git a/spec/classes/ceilometer_api_spec.rb b/spec/classes/ceilometer_api_spec.rb index fc86640..072d4bf 100644 --- a/spec/classes/ceilometer_api_spec.rb +++ b/spec/classes/ceilometer_api_spec.rb @@ -52,6 +52,30 @@ describe 'ceilometer::api' do should contain_ceilometer_config('keystone_authtoken/admin_tenant_name').with_value( params[:keystone_tenant] ) should contain_ceilometer_config('keystone_authtoken/admin_user').with_value( params[:keystone_user] ) should contain_ceilometer_config('keystone_authtoken/admin_password').with_value( params[:keystone_password] ) + should contain_ceilometer_config('keystone_authtoken/auth_admin_prefix').with_ensure('absent') + end + + context 'when specifying keystone_auth_admin_prefix' do + describe 'with a correct value' do + before { params['keystone_auth_admin_prefix'] = '/keystone/admin' } + it { should contain_ceilometer_config('keystone_authtoken/auth_admin_prefix').with_value('/keystone/admin') } + end + + [ + '/keystone/', + 'keystone/', + 'keystone', + '/keystone/admin/', + 'keystone/admin/', + 'keystone/admin' + ].each do |auth_admin_prefix| + describe "with an incorrect value #{auth_admin_prefix}" do + before { params['keystone_auth_admin_prefix'] = auth_admin_prefix } + + it { expect { should contain_ceilomete_config('keystone_authtoken/auth_admin_prefix') }.to \ + raise_error(Puppet::Error, /validate_re\(\): "#{auth_admin_prefix}" does not match/) } + end + end end end -- 2.45.2