From 71356461ce4f1259025024c4b387fed540d1e6fd Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 16 Mar 2021 10:38:36 +0900 Subject: [PATCH] Add support for the oslo_policy/enforce_scope parameter Depends-on: https://review.opendev.org/#/c/759008/ Change-Id: I1d0b8e4851db59f4a26b66965e7f0f4c67ce12cb --- manifests/policy.pp | 14 +++++++++++--- ...oslo_policy-enforce_scope-6a23a798b4bfbdb0.yaml | 5 +++++ spec/classes/cinder_policy_spec.rb | 14 ++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/oslo_policy-enforce_scope-6a23a798b4bfbdb0.yaml diff --git a/manifests/policy.pp b/manifests/policy.pp index 4b37dbc5..f55d0a99 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -4,6 +4,10 @@ # # === Parameters # +# [*enforce_scope*] +# (Optional) Whether or not to enforce scope when evaluating policies. +# Defaults to $::os_service_default. +# # [*policies*] # (Optional) Set of policies to configure for cinder # Example : @@ -24,8 +28,9 @@ # Defaults to /etc/cinder/policy.yaml # class cinder::policy ( - $policies = {}, - $policy_path = '/etc/cinder/policy.yaml', + $enforce_scope = $::os_service_default, + $policies = {}, + $policy_path = '/etc/cinder/policy.yaml', ) { include cinder::deps @@ -42,6 +47,9 @@ class cinder::policy ( create_resources('openstacklib::policy::base', $policies) - oslo::policy { 'cinder_config': policy_file => $policy_path } + oslo::policy { 'cinder_config': + enforce_scope => $enforce_scope, + policy_file => $policy_path + } } diff --git a/releasenotes/notes/oslo_policy-enforce_scope-6a23a798b4bfbdb0.yaml b/releasenotes/notes/oslo_policy-enforce_scope-6a23a798b4bfbdb0.yaml new file mode 100644 index 00000000..ca418f39 --- /dev/null +++ b/releasenotes/notes/oslo_policy-enforce_scope-6a23a798b4bfbdb0.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``cinder::policy::enforce_scope`` parameter has been added to + support the corresponding parameter in oslo.policy library. diff --git a/spec/classes/cinder_policy_spec.rb b/spec/classes/cinder_policy_spec.rb index dd6a26b2..7acf987f 100644 --- a/spec/classes/cinder_policy_spec.rb +++ b/spec/classes/cinder_policy_spec.rb @@ -1,11 +1,12 @@ require 'spec_helper' describe 'cinder::policy' do - shared_examples 'cinder policies' do + shared_examples 'cinder::policy' do let :params do { - :policy_path => '/etc/cinder/policy.yaml', - :policies => { + :enforce_scope => false, + :policy_path => '/etc/cinder/policy.yaml', + :policies => { 'context_is_admin' => { 'key' => 'context_is_admin', 'value' => 'foo:bar' @@ -23,20 +24,21 @@ describe 'cinder::policy' do :file_format => 'yaml', }) is_expected.to contain_oslo__policy('cinder_config').with( - :policy_file => '/etc/cinder/policy.yaml', + :enforce_scope => false, + :policy_file => '/etc/cinder/policy.yaml', ) end end on_supported_os({ - :supported_os => OSDefaults.get_supported_os + :supported_os => OSDefaults.get_supported_os }).each do |os,facts| context "on #{os}" do let (:facts) do facts.merge!(OSDefaults.get_facts()) end - it_behaves_like 'cinder policies' + it_behaves_like 'cinder::policy' end end end