From 92f80ee955b27fb21ed76bf210eaa517220d942d Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 16 Mar 2021 10:22:20 +0900 Subject: [PATCH] Add support for the oslo_policy/enforce_scope parameter Depends-on: https://review.opendev.org/#/c/759008/ Change-Id: I30d4f1e2069cd9fffc1e37c15c1a5e7a98c322a8 --- manifests/policy.pp | 16 ++++++++++++---- ...lo_policy-enforce_scope-12247a467cadafcf.yaml | 5 +++++ spec/classes/aodh_policy_spec.rb | 15 ++++++++------- 3 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 releasenotes/notes/oslo_policy-enforce_scope-12247a467cadafcf.yaml diff --git a/manifests/policy.pp b/manifests/policy.pp index 0e41c196..66d31af0 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 aodh # Example : @@ -20,12 +24,13 @@ # Defaults to empty hash. # # [*policy_path*] -# (Optional) Path to the nova policy.yaml file +# (Optional) Path to the aodh policy.yaml file # Defaults to /etc/aodh/policy.yaml # class aodh::policy ( - $policies = {}, - $policy_path = '/etc/aodh/policy.yaml', + $enforce_scope = $::os_service_default, + $policies = {}, + $policy_path = '/etc/aodh/policy.yaml', ) { include aodh::deps @@ -42,6 +47,9 @@ class aodh::policy ( create_resources('openstacklib::policy::base', $policies) - oslo::policy { 'aodh_config': policy_file => $policy_path } + oslo::policy { 'aodh_config': + enforce_scope => $enforce_scope, + policy_file => $policy_path + } } diff --git a/releasenotes/notes/oslo_policy-enforce_scope-12247a467cadafcf.yaml b/releasenotes/notes/oslo_policy-enforce_scope-12247a467cadafcf.yaml new file mode 100644 index 00000000..4ee89e40 --- /dev/null +++ b/releasenotes/notes/oslo_policy-enforce_scope-12247a467cadafcf.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``aodh::policy::enforce_scope`` parameter has been added to + support the corresponding parameter in oslo.policy library. diff --git a/spec/classes/aodh_policy_spec.rb b/spec/classes/aodh_policy_spec.rb index 877e7af8..87b24141 100644 --- a/spec/classes/aodh_policy_spec.rb +++ b/spec/classes/aodh_policy_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' describe 'aodh::policy' do - - shared_examples_for 'aodh policies' do + shared_examples 'aodh::policy' do let :params do { - :policy_path => '/etc/aodh/policy.yaml', - :policies => { + :enforce_scope => false, + :policy_path => '/etc/aodh/policy.yaml', + :policies => { 'context_is_admin' => { 'key' => 'context_is_admin', 'value' => 'foo:bar' @@ -24,20 +24,21 @@ describe 'aodh::policy' do :file_format => 'yaml', }) is_expected.to contain_oslo__policy('aodh_config').with( - :policy_file => '/etc/aodh/policy.yaml', + :enforce_scope => false, + :policy_file => '/etc/aodh/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_configures 'aodh policies' + it_behaves_like 'aodh::policy' end end end