Add support for the oslo_policy/enforce_scope parameter

Depends-on: https://review.opendev.org/#/c/759008/
Change-Id: Ice8c1420a2386887965dd587e90b35d3314b0c27
This commit is contained in:
Takashi Kajinami 2021-03-16 12:36:29 +09:00
parent 89d2dd4805
commit e08f3cd6fe
3 changed files with 24 additions and 10 deletions

View File

@ -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 heat
# Example :
@ -24,8 +28,9 @@
# Defaults to /etc/heat/policy.yaml
#
class heat::policy (
$policies = {},
$policy_path = '/etc/heat/policy.yaml',
$enforce_scope = $::os_service_default,
$policies = {},
$policy_path = '/etc/heat/policy.yaml',
) {
include heat::deps
@ -42,6 +47,9 @@ class heat::policy (
create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'heat_config': policy_file => $policy_path }
oslo::policy { 'heat_config':
enforce_scope => $enforce_scope,
policy_file => $policy_path
}
}

View File

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

View File

@ -1,12 +1,12 @@
require 'spec_helper'
describe 'heat::policy' do
shared_examples_for 'heat policies' do
shared_examples 'heat::policy' do
let :params do
{
:policy_path => '/etc/heat/policy.yaml',
:policies => {
:enforce_scope => false,
:policy_path => '/etc/heat/policy.yaml',
:policies => {
'context_is_admin' => {
'key' => 'context_is_admin',
'value' => 'foo:bar'
@ -24,20 +24,21 @@ describe 'heat::policy' do
:file_format => 'yaml',
})
is_expected.to contain_oslo__policy('heat_config').with(
:policy_file => '/etc/heat/policy.yaml',
:enforce_scope => false,
:policy_file => '/etc/heat/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 'heat policies'
it_behaves_like 'heat::policy'
end
end
end