Add support for the oslo_policy/enforce_scope parameter

Depends-on: https://review.opendev.org/#/c/759008/
Change-Id: Id4ad97d08fd1bb71b75e268a8614629510e62efb
This commit is contained in:
Takashi Kajinami 2021-03-16 17:22:18 +09:00
parent 3feeb84f63
commit a763ef29ff
3 changed files with 24 additions and 10 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 manila # (Optional) Set of policies to configure for manila
# Example : # Example :
@ -24,6 +28,7 @@
# Defaults to /etc/manila/policy.yaml # Defaults to /etc/manila/policy.yaml
# #
class manila::policy ( class manila::policy (
$enforce_scope = $::os_service_default,
$policies = {}, $policies = {},
$policy_path = '/etc/manila/policy.yaml', $policy_path = '/etc/manila/policy.yaml',
) { ) {
@ -42,6 +47,9 @@ class manila::policy (
create_resources('openstacklib::policy::base', $policies) create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'manila_config': policy_file => $policy_path } oslo::policy { 'manila_config':
enforce_scope => $enforce_scope,
policy_file => $policy_path
}
} }

View File

@ -0,0 +1,5 @@
---
features:
- |
The new ``manila::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 'manila::policy' do describe 'manila::policy' do
shared_examples 'manila::policy' do
shared_examples_for 'manila policies' do
let :params do let :params do
{ {
:enforce_scope => false,
:policy_path => '/etc/manila/policy.yaml', :policy_path => '/etc/manila/policy.yaml',
:policies => { :policies => {
'context_is_admin' => { 'context_is_admin' => {
@ -24,6 +24,7 @@ describe 'manila::policy' do
:file_format => 'yaml', :file_format => 'yaml',
}) })
is_expected.to contain_oslo__policy('manila_config').with( is_expected.to contain_oslo__policy('manila_config').with(
:enforce_scope => false,
:policy_file => '/etc/manila/policy.yaml', :policy_file => '/etc/manila/policy.yaml',
) )
end end
@ -37,7 +38,7 @@ describe 'manila::policy' do
facts.merge!(OSDefaults.get_facts()) facts.merge!(OSDefaults.get_facts())
end end
it_configures 'manila policies' it_behaves_like 'manila::policy'
end end
end end
end end