Merge "policy.json: Allow one to manage them from the puppet module"

This commit is contained in:
Jenkins 2014-11-09 11:23:58 +00:00 committed by Gerrit Code Review
commit d2615c9e0a
4 changed files with 72 additions and 0 deletions

View File

@ -69,13 +69,16 @@ class ceilometer::api (
) {
include ceilometer::params
include ceilometer::policy
validate_string($keystone_password)
Ceilometer_config<||> ~> Service['ceilometer-api']
Class['ceilometer::policy'] ~> Service['ceilometer-api']
Package['ceilometer-api'] -> Ceilometer_config<||>
Package['ceilometer-api'] -> Service['ceilometer-api']
Package['ceilometer-api'] -> Class['ceilometer::policy']
package { 'ceilometer-api':
ensure => $package_ensure,
name => $::ceilometer::params::api_package_name,

28
manifests/policy.pp Normal file
View File

@ -0,0 +1,28 @@
# == Class: ceilometer::policy
#
# Configure the ceilometer policies
#
# === Parameters
#
# [*policies*]
# (optional) Set of policies to configure for ceilometer
# Example : { 'ceilometer-context_is_admin' => {'context_is_admin' => 'true'}, 'ceilometer-default' => {'default' => 'rule:admin_or_owner'} }
# Defaults to empty hash.
#
# [*policy_path*]
# (optional) Path to the ceilometer policy.json file
# Defaults to /etc/ceilometer/policy.json
#
class ceilometer::policy (
$policies = {},
$policy_path = '/etc/ceilometer/policy.json',
) {
Openstacklib::Policy::Base {
file_path => $policy_path,
}
class { 'openstacklib::policy' :
policies => $policies,
}
}

View File

@ -29,6 +29,7 @@ describe 'ceilometer::api' do
end
it { should contain_class('ceilometer::params') }
it { should contain_class('ceilometer::policy') }
it 'installs ceilometer-api package' do
should contain_package('ceilometer-api').with(

View File

@ -0,0 +1,40 @@
require 'spec_helper'
describe 'ceilometer::policy' do
shared_examples_for 'ceilometer policies' do
let :params do
{
:policy_path => '/etc/ceilometer/policy.json',
:policies => {
'context_is_admin' => {
'key' => 'context_is_admin',
'value' => 'foo:bar'
}
}
}
end
it 'set up the policies' do
should contain_class('openstacklib::policy').with({
:policies => params[:policies]
})
end
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
it_configures 'ceilometer policies'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
it_configures 'ceilometer policies'
end
end