From 03bd82ca15d1f0629eb89f4d5fab89ce0dee94a7 Mon Sep 17 00:00:00 2001
From: Mehdi Abaakouk <sileht@sileht.net>
Date: Tue, 18 Jul 2017 14:43:34 +0200
Subject: [PATCH] Configure the Ceilometer project name

This change configures the Ceilometer project name.

This allow to use Aodh and Gnocchi alarms as non admin user.

Change-Id: I8b8328a87997a3ba4e15bd711d266b564153a2d3
---
 manifests/api.pp              | 10 ++++++++--
 spec/classes/aodh_api_spec.rb |  8 ++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/manifests/api.pp b/manifests/api.pp
index 03551980..c68151d3 100644
--- a/manifests/api.pp
+++ b/manifests/api.pp
@@ -44,6 +44,10 @@
 #   HTTPProxyToWSGI middleware.
 #   Defaults to $::os_service_default.
 #
+# [*gnocchi_external_project_owner*]
+#   (optional) Gnocchi external project owner (usually Ceilometer project name)
+#   Defaults to 'services'
+#
 class aodh::api (
   $manage_service                 = true,
   $enabled                        = true,
@@ -54,6 +58,7 @@ class aodh::api (
   $sync_db                        = false,
   $auth_strategy                  = 'keystone',
   $enable_proxy_headers_parsing   = $::os_service_default,
+  $gnocchi_external_project_owner = 'services',
 ) inherits aodh::params {
 
 
@@ -109,8 +114,9 @@ as a standalone service, or httpd for being run by a httpd server")
   }
 
   aodh_config {
-    'api/host': value => $host;
-    'api/port': value => $port;
+    'api/gnocchi_external_project_owner': value => $gnocchi_external_project_owner;
+    'api/host':                           value => $host;
+    'api/port':                           value => $port;
   }
 
   oslo::middleware { 'aodh_config':
diff --git a/spec/classes/aodh_api_spec.rb b/spec/classes/aodh_api_spec.rb
index e753c122..446bdbf3 100644
--- a/spec/classes/aodh_api_spec.rb
+++ b/spec/classes/aodh_api_spec.rb
@@ -36,6 +36,7 @@ describe 'aodh::api' do
     it 'configures api' do
       is_expected.to contain_aodh_config('api/host').with_value( params[:host] )
       is_expected.to contain_aodh_config('api/port').with_value( params[:port] )
+      is_expected.to contain_aodh_config('api/gnocchi_external_project_owner').with_value( 'services' )
       is_expected.to contain_aodh_config('oslo_middleware/enable_proxy_headers_parsing').with_value('<SERVICE DEFAULT>')
     end
 
@@ -76,6 +77,13 @@ describe 'aodh::api' do
       it { is_expected.to contain_aodh_config('oslo_middleware/enable_proxy_headers_parsing').with_value(true) }
     end
 
+    context 'with gnocchi_external_project_owner' do
+      before do
+        params.merge!({:gnocchi_external_project_owner => 'gnocchi-project' })
+      end
+
+      it { is_expected.to contain_aodh_config('api/gnocchi_external_project_owner').with_value('gnocchi-project') }
+    end
     context 'with disabled service managing' do
       before do
         params.merge!({