diff --git a/manifests/api.pp b/manifests/api.pp index 4fe3a002..12be1abf 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -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': diff --git a/releasenotes/notes/api-container_formats-0bc5a2c0e7b6357e.yaml b/releasenotes/notes/api-container_formats-0bc5a2c0e7b6357e.yaml new file mode 100644 index 00000000..ea21d976 --- /dev/null +++ b/releasenotes/notes/api-container_formats-0bc5a2c0e7b6357e.yaml @@ -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. diff --git a/spec/classes/glance_api_spec.rb b/spec/classes/glance_api_spec.rb index 0bbe0c46..1f4ed783 100644 --- a/spec/classes/glance_api_spec.rb +++ b/spec/classes/glance_api_spec.rb @@ -189,7 +189,8 @@ describe 'glance::api' do is_expected.to contain_glance_api_config('DEFAULT/key_file').with_value('') 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('') is_expected.to contain_glance_api_config('image_format/disk_formats').with_value('') 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