Merge "Add support for the oslo_policy/enforce_scope parameter"

This commit is contained in:
Zuul 2021-03-22 09:47:41 +00:00 committed by Gerrit Code Review
commit bff96edd8a
3 changed files with 24 additions and 9 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 placement
# Example :
@ -20,12 +24,13 @@
# Defaults to empty hash.
#
# [*policy_path*]
# (Optional) Path to the nova policy.yaml file
# (Optional) Path to the placement policy.yaml file
# Defaults to /etc/placement/policy.yaml
#
class placement::policy (
$policies = {},
$policy_path = '/etc/placement/policy.yaml',
$enforce_scope = $::os_service_default,
$policies = {},
$policy_path = '/etc/placement/policy.yaml',
) {
include placement::deps
@ -42,6 +47,9 @@ class placement::policy (
create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'placement_config': policy_file => $policy_path }
oslo::policy { 'placement_config':
enforce_scope => $enforce_scope,
policy_file => $policy_path
}
}

View File

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

View File

@ -4,8 +4,9 @@ describe 'placement::policy' do
shared_examples 'placement::policy' do
let :params do
{
:policy_path => '/etc/placement/policy.yaml',
:policies => {
:enforce_scope => false,
:policy_path => '/etc/placement/policy.yaml',
:policies => {
'context_is_admin' => {
'key' => 'context_is_admin',
'value' => 'foo:bar'
@ -15,15 +16,16 @@ describe 'placement::policy' do
end
it 'set up the policies' do
is_expected.to contain_openstacklib__policy__base('context_is_admin').with(
is_expected.to contain_openstacklib__policy__base('context_is_admin').with({
:key => 'context_is_admin',
:value => 'foo:bar',
:file_user => 'root',
:file_group => 'placement',
:file_format => 'yaml',
)
})
is_expected.to contain_oslo__policy('placement_config').with(
:policy_file => '/etc/placement/policy.yaml',
:enforce_scope => false,
:policy_file => '/etc/placement/policy.yaml',
)
end
end