Browse Source

Add support for the oslo_policy/enforce_scope parameter

Depends-on: https://review.opendev.org/#/c/759008/
Change-Id: I8c12dee1312b756f4c2bfc02d9cdb81db5404247
changes/93/780693/3
Takashi Kajinami 4 months ago
parent
commit
c0a7f7d891
  1. 16
      manifests/policy.pp
  2. 5
      releasenotes/notes/oslo_policy-enforce_scope-422b5bb6f96a7afe.yaml
  3. 15
      spec/classes/glance_policy_spec.rb

16
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 glance
# Example :
@ -24,8 +28,9 @@
# Defaults to /etc/glance/policy.yaml
#
class glance::policy (
$policies = {},
$policy_path = '/etc/glance/policy.yaml',
$enforce_scope = $::os_service_default,
$policies = {},
$policy_path = '/etc/glance/policy.yaml',
) {
include glance::deps
@ -38,12 +43,13 @@ class glance::policy (
file_user => 'root',
file_group => $::glance::params::group,
file_format => 'yaml',
require => Anchor['glance::config::begin'],
notify => Anchor['glance::config::end'],
}
create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'glance_api_config': policy_file => $policy_path }
oslo::policy { 'glance_api_config':
enforce_scope => $enforce_scope,
policy_file => $policy_path
}
}

5
releasenotes/notes/oslo_policy-enforce_scope-422b5bb6f96a7afe.yaml

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

15
spec/classes/glance_policy_spec.rb

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