]> review.fuel-infra Code Review - puppet-modules/puppet-ceilometer.git/commitdiff
Add auth_admin_prefix support for ceilometer::api
authorFrançois Charlier <francois.charlier@enovance.com>
Thu, 6 Jun 2013 13:41:45 +0000 (15:41 +0200)
committerFrançois Charlier <francois.charlier@enovance.com>
Thu, 6 Jun 2013 13:41:45 +0000 (15:41 +0200)
To support keystone urls like http://host:80/keystone/admin

Implements blueprint serve-keystone-from-wsgi

Change-Id: I68c17a5b76ed61b18337ee580fba63200d874792

manifests/api.pp
spec/classes/ceilometer_api_spec.rb

index 96de77729b07226e8cdbf101da8c0761430f9260..786fa1d760bbb4dee1de9f08d43bddb596280d6c 100644 (file)
 #  [*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
 #
 #    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;
+    }
+  }
+
 }
index fc86640f7779a7c906a98b46c8d1f598be0f9fd8..072d4bfe58ba5d6492092d9e60efe7e38d3f8c07 100644 (file)
@@ -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