Enable image inject metadata properties & user roles to be ignored

Adding inject_metadata_properties & ignore_user_roles params to
inject metadata properties to the image with specific user roles
to be ignored for injecting metadata properties in the image..

Ref: https://blueprints.launchpad.net/glance/+spec/inject-automatic-metadata

Change-Id: I02482dff7b1412d6254ce82d80257ce26c23430d
This commit is contained in:
Pranali Deore 2018-12-19 14:23:36 +05:30
parent f09800121b
commit 674d8ba953
3 changed files with 45 additions and 10 deletions

View File

@ -101,11 +101,19 @@
# Defaults to $::os_service_default.
#
# [*image_import_plugins*]
# (optional) (Array) List of enabled Image Import Plugins.
# (optional) (Array) List of enabled Image Import Plugins.
# Defaults to $::os_service_default.
#
# [*image_conversion_output_format*]
# (optional) Desired output format for image conversion plugin.
# (optional) Desired output format for image conversion plugin.
# Defaults to $::os_service_default.
#
# [*inject_metadata_properties*]
# (optional) Dictionary contains metadata properties to be injected in image.
# Defaults to $::os_service_default.
#
# [*ignore_user_roles*]
# (optional) List containing user roles. For example: [admin,member]
# Defaults to $::os_service_default.
#
# [*show_image_direct_url*]
@ -332,6 +340,8 @@ class glance::api(
$image_cache_stall_time = $::os_service_default,
$image_cache_dir = '/var/lib/glance/image-cache',
$image_import_plugins = $::os_service_default,
$inject_metadata_properties = $::os_service_default,
$ignore_user_roles = $::os_service_default,
$image_conversion_output_format = $::os_service_default,
$enabled_import_methods = $::os_service_default,
$node_staging_uri = $::os_service_default,
@ -476,9 +486,24 @@ class glance::api(
$image_import_plugins_real = $image_import_plugins
}
if $inject_metadata_properties != $::os_service_default {
$inject_metadata_properties_real = join(any2array($inject_metadata_properties), ',')
} else {
$inject_metadata_properties_real = $inject_metadata_properties
}
if $ignore_user_roles != $::os_service_default {
$ignore_user_roles_real = join(any2array($ignore_user_roles), ',')
} else {
$ignore_user_roles_real = $ignore_user_roles
}
glance_image_import_config {
'image_import_opts/image_import_plugins': value => $image_import_plugins_real;
'image_conversion/output_format': value => $image_conversion_output_format;
'image_import_opts/image_import_plugins': value => $image_import_plugins_real;
'image_conversion/output_format': value => $image_conversion_output_format;
'inject_metadata_properties/inject': value => $inject_metadata_properties_real;
'inject_metadata_properties/ignore_user_roles': value => $ignore_user_roles_real;
}

View File

@ -0,0 +1,7 @@
---
features:
- |
Add new parameter 'inject_metadata_properties', to add metadata
properties to be injected in image.
Add new parameter 'ignore_user_roles', to specify name of user
roles to be ignored for injecting metadata properties in the image.

View File

@ -31,6 +31,8 @@ describe 'glance::api' do
:image_cache_dir => '/var/lib/glance/image-cache',
:image_import_plugins => '<SERVICE DEFAULT>',
:image_conversion_output_format => '<SERVICE DEFAULT>',
:inject_metadata_properties => '<SERVICE DEFAULT>',
:ignore_user_roles => '<SERVICE DEFAULT>',
:enabled_import_methods => '<SERVICE DEFAULT>',
:node_staging_uri => '<SERVICE DEFAULT>',
:image_member_quota => '<SERVICE DEFAULT>',
@ -74,6 +76,8 @@ describe 'glance::api' do
:image_cache_dir => '/tmp/glance',
:image_import_plugins => 'image_conversion',
:image_conversion_output_format => 'raw',
:inject_metadata_properties => 'key:val',
:ignore_user_roles => 'admin',
:enabled_import_methods => 'glance-direct,web-download',
:node_staging_uri => '/tmp/staging',
:image_member_quota => '128',
@ -155,12 +159,11 @@ describe 'glance::api' do
"[%s]" % param_hash[:image_import_plugins])
end
it 'is_expected.to lay down default image_conversion image_import config' do
[
'image_conversion_output_format'
].each do |config|
is_expected.to contain_glance_image_import_config("image_conversion/output_format").with_value(param_hash[config.intern])
end
it 'is_expected.to lay down default image_conversion & inject_metadata image_import config' do
is_expected.to contain_glance_image_import_config("image_conversion/output_format").with_value(param_hash[:image_conversion_output_format])
is_expected.to contain_glance_image_import_config("inject_metadata_properties/inject").with_value(param_hash[:inject_metadata_properties])
is_expected.to contain_glance_image_import_config("inject_metadata_properties/ignore_user_roles").with_value(param_hash[:ignore_user_roles])
end
it 'is_expected.to lay down default cache config' do