Merge "Add support for the oslo_policy/enforce_scope parameter"

This commit is contained in:
Zuul 2021-03-22 17:10:09 +00:00 committed by Gerrit Code Review
commit 09866fbe25
3 changed files with 24 additions and 12 deletions

View File

@ -4,6 +4,10 @@
# #
# === Parameters # === Parameters
# #
# [*enforce_scope*]
# (Optional) Whether or not to enforce scope when evaluating policies.
# Defaults to $::os_service_default.
#
# [*policies*] # [*policies*]
# (Optional) Set of policies to configure for glance # (Optional) Set of policies to configure for glance
# Example : # Example :
@ -24,6 +28,7 @@
# Defaults to /etc/glance/policy.yaml # Defaults to /etc/glance/policy.yaml
# #
class glance::policy ( class glance::policy (
$enforce_scope = $::os_service_default,
$policies = {}, $policies = {},
$policy_path = '/etc/glance/policy.yaml', $policy_path = '/etc/glance/policy.yaml',
) { ) {
@ -38,12 +43,13 @@ class glance::policy (
file_user => 'root', file_user => 'root',
file_group => $::glance::params::group, file_group => $::glance::params::group,
file_format => 'yaml', file_format => 'yaml',
require => Anchor['glance::config::begin'],
notify => Anchor['glance::config::end'],
} }
create_resources('openstacklib::policy::base', $policies) create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'glance_api_config': policy_file => $policy_path } oslo::policy { 'glance_api_config':
enforce_scope => $enforce_scope,
policy_file => $policy_path
}
} }

View File

@ -0,0 +1,5 @@
---
features:
- |
The new ``glance::policy::enforce_scope`` parameter has been added to
support the corresponding parameter in oslo.policy library.

View File

@ -1,10 +1,10 @@
require 'spec_helper' require 'spec_helper'
describe 'glance::policy' do describe 'glance::policy' do
shared_examples 'glance::policy' do
shared_examples_for 'glance policies' do
let :params do let :params do
{ {
:enforce_scope => false,
:policy_path => '/etc/glance/policy.yaml', :policy_path => '/etc/glance/policy.yaml',
:policies => { :policies => {
'context_is_admin' => { 'context_is_admin' => {
@ -24,6 +24,7 @@ describe 'glance::policy' do
:file_format => 'yaml', :file_format => 'yaml',
}) })
is_expected.to contain_oslo__policy('glance_api_config').with( is_expected.to contain_oslo__policy('glance_api_config').with(
:enforce_scope => false,
:policy_file => '/etc/glance/policy.yaml', :policy_file => '/etc/glance/policy.yaml',
) )
end end
@ -37,7 +38,7 @@ describe 'glance::policy' do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
it_configures 'glance policies' it_behaves_like 'glance::policy'
end end
end end
end end