diff --git a/manifests/api.pp b/manifests/api.pp index 7803abb3..4fe3a002 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -75,6 +75,10 @@ # (optional) If set, use this value for max_overflow with sqlalchemy. # Defaults to undef. # +# [*disk_formats*] +# (optional) (Array) List of allowed values for an image disk_format attribute. +# Defaults to $::os_service_default. +# # [*cache_prefetcher_interval*] # (optional) The interval in seconds to run periodic job 'cache_images' # Defaults to $::os_service_default. @@ -336,6 +340,7 @@ class glance::api( $database_max_retries = undef, $database_retry_interval = undef, $database_max_overflow = undef, + $disk_formats = $::os_service_default, $cache_prefetcher_interval = $::os_service_default, $image_cache_max_size = $::os_service_default, $image_cache_stall_time = $::os_service_default, @@ -550,6 +555,16 @@ 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; + } + resources { 'glance_api_config': purge => $purge_config, } diff --git a/releasenotes/notes/add_disk_formats_parameter-9e83e3142f8d10f9.yaml b/releasenotes/notes/add_disk_formats_parameter-9e83e3142f8d10f9.yaml new file mode 100644 index 00000000..f82f86e3 --- /dev/null +++ b/releasenotes/notes/add_disk_formats_parameter-9e83e3142f8d10f9.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + Added disk_formats option which allows configuration of + the image_format/disk_formats config setting; some backends + perform poorly with specific disk formats, for example + Ceph with QCOW2 images and in these scenarios it might + be useful to filter out of the allowed disk formats those + which are unwanted. \ No newline at end of file diff --git a/spec/classes/glance_api_spec.rb b/spec/classes/glance_api_spec.rb index 41220d28..0bbe0c46 100644 --- a/spec/classes/glance_api_spec.rb +++ b/spec/classes/glance_api_spec.rb @@ -34,6 +34,7 @@ describe 'glance::api' do :image_cache_stall_time => '', :image_cache_max_size => '', :cache_prefetcher_interval => '', + :disk_formats => '', :pipeline => 'keystone', :task_time_to_live => '', :task_executor => '', @@ -188,6 +189,10 @@ 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 + is_expected.to contain_glance_api_config('image_format/disk_formats').with_value('') + end + it 'passes purge to resource' do is_expected.to contain_resources('glance_api_config').with({ :purge => false @@ -289,6 +294,18 @@ describe 'glance::api' do end end + describe 'with disk_formats option' do + let :params do + default_params.merge({ + :disk_formats => 'raw,iso', + }) + end + + context 'with disk_formats option' do + it { is_expected.to contain_glance_api_config('image_format/disk_formats').with_value('raw,iso') } + end + end + describe 'with enabled_backends and stores by default' do let :params do default_params