Add support for the oslo_policy/enforce_scope parameter

Depends-on: https://review.opendev.org/#/c/759008/
Change-Id: I8c823504fe0d42840bfa63311bcd0c03bac72b2a
This commit is contained in:
Takashi Kajinami 2021-03-21 11:05:03 +09:00
parent 844d230ddf
commit 2a1b037cc7
3 changed files with 26 additions and 11 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 vitrage # (Optional) Set of policies to configure for vitrage
# Example : # Example :
@ -20,10 +24,11 @@
# Defaults to empty hash. # Defaults to empty hash.
# #
# [*policy_path*] # [*policy_path*]
# (Optional) Path to the nova policy.yaml file # (Optional) Path to the vitrage policy.yaml file
# Defaults to /etc/vitrage/policy.yaml # Defaults to /etc/vitrage/policy.yaml
# #
class vitrage::policy ( class vitrage::policy (
$enforce_scope = $::os_service_default,
$policies = {}, $policies = {},
$policy_path = '/etc/vitrage/policy.yaml', $policy_path = '/etc/vitrage/policy.yaml',
) { ) {
@ -42,5 +47,9 @@ class vitrage::policy (
create_resources('openstacklib::policy::base', $policies) create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'vitrage_config': policy_file => $policy_path } oslo::policy { 'vitrage_config':
enforce_scope => $enforce_scope,
policy_file => $policy_path
}
} }

View File

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