Merge "Add support for image_format/container_formats"

This commit is contained in:
Zuul 2020-10-13 17:24:43 +00:00 committed by Gerrit Code Review
commit 02ad7e079a
3 changed files with 33 additions and 11 deletions

View File

@ -75,8 +75,12 @@
# (optional) If set, use this value for max_overflow with sqlalchemy.
# Defaults to undef.
#
# [*container_formats*]
# (optional) List of allowed values for an image container_format attributes
# Defaults to $::os_service_default.
#
# [*disk_formats*]
# (optional) (Array) List of allowed values for an image disk_format attribute.
# (optional) List of allowed values for an image disk_format attribute.
# Defaults to $::os_service_default.
#
# [*cache_prefetcher_interval*]
@ -340,6 +344,7 @@ class glance::api(
$database_max_retries = undef,
$database_retry_interval = undef,
$database_max_overflow = undef,
$container_formats = $::os_service_default,
$disk_formats = $::os_service_default,
$cache_prefetcher_interval = $::os_service_default,
$image_cache_max_size = $::os_service_default,
@ -555,14 +560,9 @@ enabled_backends instead.')
'glance_store/filesystem_store_file_perm': value => $filesystem_store_file_perm;
}
# disk_formats handling
if $disk_formats != $::os_service_default {
$disk_formats_real = join(any2array($disk_formats), ',')
} else {
$disk_formats_real = $disk_formats
}
glance_api_config {
'image_format/disk_formats': value => $disk_formats_real;
'image_format/container_formats': value => join(any2array($container_formats), ',');
'image_format/disk_formats': value => join(any2array($disk_formats), ',');
}
resources { 'glance_api_config':

View File

@ -0,0 +1,5 @@
---
features:
- |
The new ``glance::api::container_formats`` parameter has been added to
configure supported values for the container_format image attribute.

View File

@ -189,7 +189,8 @@ describe 'glance::api' do
is_expected.to contain_glance_api_config('DEFAULT/key_file').with_value('<SERVICE DEFAULT>')
end
it 'is_expected.to have no disk_formats set' do
it 'is_expected.to have no formats set' do
is_expected.to contain_glance_api_config('image_format/container_formats').with_value('<SERVICE DEFAULT>')
is_expected.to contain_glance_api_config('image_format/disk_formats').with_value('<SERVICE DEFAULT>')
end
@ -294,14 +295,30 @@ describe 'glance::api' do
end
end
describe 'with disk_formats option' do
describe 'with formats options with strings' do
let :params do
default_params.merge({
:disk_formats => 'raw,iso',
:container_formats => 'ami,ari',
:disk_formats => 'raw,iso',
})
end
context 'with disk_formats option' do
it { is_expected.to contain_glance_api_config('image_format/container_formats').with_value('ami,ari') }
it { is_expected.to contain_glance_api_config('image_format/disk_formats').with_value('raw,iso') }
end
end
describe 'with formats options with arrays' do
let :params do
default_params.merge({
:container_formats => ['ami', 'ari'],
:disk_formats => ['raw', 'iso'],
})
end
context 'with disk_formats option' do
it { is_expected.to contain_glance_api_config('image_format/container_formats').with_value('ami,ari') }
it { is_expected.to contain_glance_api_config('image_format/disk_formats').with_value('raw,iso') }
end
end