diff --git a/manifests/api.pp b/manifests/api.pp index 60d28a2d..eabdf58f 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -62,6 +62,11 @@ # (optional) List of allowed values for an image disk_format attribute. # Defaults to $facts['os_service_default']. # +# [*require_image_format_match*] +# (optional) Inspect the content of uploads and require that they match +# the disk format set on the image. +# Defaults to $facts['os_service_default']. +# # [*image_cache_driver*] # (optional) The driver to use for image cache management. # Defaults to $facts['os_service_default']. @@ -287,6 +292,7 @@ class glance::api( $default_backend = undef, $container_formats = $facts['os_service_default'], $disk_formats = $facts['os_service_default'], + $require_image_format_match = $facts['os_service_default'], $image_cache_driver = $facts['os_service_default'], $image_cache_dir = '/var/lib/glance/image-cache', $image_cache_max_size = $facts['os_service_default'], @@ -517,8 +523,9 @@ enabled_backends instead.') } glance_api_config { - 'image_format/container_formats': value => join(any2array($container_formats), ','); - 'image_format/disk_formats': value => join(any2array($disk_formats), ','); + 'image_format/container_formats': value => join(any2array($container_formats), ','); + 'image_format/disk_formats': value => join(any2array($disk_formats), ','); + 'image_format/require_image_format_match': value => $require_image_format_match; } resources { 'glance_api_config': diff --git a/releasenotes/notes/require_image_format_match-b8b8f60b86634832.yaml b/releasenotes/notes/require_image_format_match-b8b8f60b86634832.yaml new file mode 100644 index 00000000..43cd8caa --- /dev/null +++ b/releasenotes/notes/require_image_format_match-b8b8f60b86634832.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``glance::api::require_image_format_match`` parameter has been + added. diff --git a/spec/classes/glance_api_spec.rb b/spec/classes/glance_api_spec.rb index 678484a4..f2353780 100644 --- a/spec/classes/glance_api_spec.rb +++ b/spec/classes/glance_api_spec.rb @@ -41,7 +41,6 @@ describe 'glance::api' do :image_location_quota => '', :image_size_cap => '', :user_storage_quota => '', - :disk_formats => '', :paste_deploy_flavor => 'keystone', :paste_deploy_config_file => '', :task_time_to_live => '', @@ -215,6 +214,7 @@ describe 'glance::api' 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('') + is_expected.to contain_glance_api_config('image_format/require_image_format_match').with_value('') end it 'passes purge to resource' do @@ -360,6 +360,18 @@ describe 'glance::api' do end end + describe 'with require_image_format_match' do + let :params do + { + :require_image_format_match => true, + } + end + + context 'with require_image_format_match option' do + it { is_expected.to contain_glance_api_config('image_format/require_image_format_match').with_value(true) } + end + end + describe 'with enabled_backends and stores by default' do it { is_expected.to_not contain_glance_api_config('DEFAULT/enabled_backends').with_value('') } it { is_expected.to_not contain_glance_api_config('glance_store/stores').with_value('') }