Use yaml instead of json for policy file

Because usage of json for policy file will be deprecated and replaced
by yaml[1].

[1] https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html

Depends-on: https://review.opendev.org/769647
Change-Id: I296a34f14cb3cd88ac8a969d224ab7e55b79b137
This commit is contained in:
Takashi Kajinami 2020-12-29 16:31:43 +09:00
parent 498a763916
commit 2b6e3859c3
3 changed files with 24 additions and 13 deletions

View File

@ -20,12 +20,12 @@
# Defaults to empty hash. # Defaults to empty hash.
# #
# [*policy_path*] # [*policy_path*]
# (Optional) Path to the nova policy.json file # (Optional) Path to the nova policy.yaml file
# Defaults to /etc/placement/policy.json # Defaults to /etc/placement/policy.yaml
# #
class placement::policy ( class placement::policy (
$policies = {}, $policies = {},
$policy_path = '/etc/placement/policy.json', $policy_path = '/etc/placement/policy.yaml',
) { ) {
include placement::deps include placement::deps
@ -34,9 +34,10 @@ class placement::policy (
validate_legacy(Hash, 'validate_hash', $policies) validate_legacy(Hash, 'validate_hash', $policies)
Openstacklib::Policy::Base { Openstacklib::Policy::Base {
file_path => $policy_path, file_path => $policy_path,
file_user => 'root', file_user => 'root',
file_group => $::placement::params::group, file_group => $::placement::params::group,
file_format => 'yaml',
} }
create_resources('openstacklib::policy::base', $policies) create_resources('openstacklib::policy::base', $policies)

View File

@ -0,0 +1,4 @@
---
upgrade:
- |
Now policy.yaml is used by default instead of policy.json.

View File

@ -4,7 +4,7 @@ describe 'placement::policy' do
shared_examples 'placement::policy' do shared_examples 'placement::policy' do
let :params do let :params do
{ {
:policy_path => '/etc/placement/policy.json', :policy_path => '/etc/placement/policy.yaml',
:policies => { :policies => {
'context_is_admin' => { 'context_is_admin' => {
'key' => 'context_is_admin', 'key' => 'context_is_admin',
@ -14,12 +14,18 @@ describe 'placement::policy' do
} }
end end
it { is_expected.to contain_openstacklib__policy__base('context_is_admin').with( it 'set up the policies' do
:key => 'context_is_admin', is_expected.to contain_openstacklib__policy__base('context_is_admin').with(
:value => 'foo:bar', :key => 'context_is_admin',
:file_user => 'root', :value => 'foo:bar',
:file_group => 'placement', :file_user => 'root',
)} :file_group => 'placement',
:file_format => 'yaml',
)
is_expected.to contain_oslo__policy('placement_config').with(
:policy_file => '/etc/placement/policy.yaml',
)
end
end end
on_supported_os({ on_supported_os({