Enable image import conversion & image output format
Glance image conversion configuration is not enabled by puppet-glance in glance-image-import.conf. Adding image_import_plugins & output format parameters to enable glance image conversion. Change-Id: I098aa0cabf2518b8861d5b58b885d9bdef54a7f6 Closes-Bug: #1807366 (cherry picked from commit091c01b7b8
) (cherry picked from commita245923a28
)
This commit is contained in:
parent
6c9ca30504
commit
e8abc91c6d
|
@ -0,0 +1,10 @@
|
||||||
|
Puppet::Type.type(:glance_image_import_config).provide(
|
||||||
|
:ini_setting,
|
||||||
|
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
|
||||||
|
) do
|
||||||
|
|
||||||
|
def self.file_path
|
||||||
|
'/etc/glance/glance-image-import.conf'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,57 @@
|
||||||
|
Puppet::Type.newtype(:glance_image_import_config) do
|
||||||
|
|
||||||
|
ensurable
|
||||||
|
|
||||||
|
newparam(:name, :namevar => true) do
|
||||||
|
desc 'Section/setting name to manage from glance-image-import.conf'
|
||||||
|
newvalues(/\S+\/\S+/)
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:value) do
|
||||||
|
desc 'The value of the setting to be defined.'
|
||||||
|
munge do |value|
|
||||||
|
value = value.to_s.strip
|
||||||
|
value.capitalize! if value =~ /^(true|false)$/i
|
||||||
|
value
|
||||||
|
end
|
||||||
|
newvalues(/^[\S ]*$/)
|
||||||
|
|
||||||
|
def is_to_s( currentvalue )
|
||||||
|
if resource.secret?
|
||||||
|
return '[old secret redacted]'
|
||||||
|
else
|
||||||
|
return currentvalue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def should_to_s( newvalue )
|
||||||
|
if resource.secret?
|
||||||
|
return '[new secret redacted]'
|
||||||
|
else
|
||||||
|
return newvalue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
newparam(:secret, :boolean => true) do
|
||||||
|
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
|
||||||
|
|
||||||
|
newvalues(:true, :false)
|
||||||
|
|
||||||
|
defaultto false
|
||||||
|
end
|
||||||
|
|
||||||
|
newparam(:ensure_absent_val) do
|
||||||
|
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
|
||||||
|
defaultto('<SERVICE DEFAULT>')
|
||||||
|
end
|
||||||
|
|
||||||
|
autorequire(:package) do
|
||||||
|
if Facter.value(:osfamily) == 'Debian'
|
||||||
|
'glance-api'
|
||||||
|
elsif Facter.value(:osfamily) == 'RedHat'
|
||||||
|
'openstack-glance'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -114,6 +114,14 @@
|
||||||
# (optional) The amount of time to let an image remain in the cache without being accessed.
|
# (optional) The amount of time to let an image remain in the cache without being accessed.
|
||||||
# Defaults to $::os_service_default.
|
# Defaults to $::os_service_default.
|
||||||
#
|
#
|
||||||
|
# [*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.
|
||||||
|
# Defaults to $::os_service_default.
|
||||||
|
#
|
||||||
# [*use_syslog*]
|
# [*use_syslog*]
|
||||||
# (optional) Use syslog for logging.
|
# (optional) Use syslog for logging.
|
||||||
# Defaults to undef
|
# Defaults to undef
|
||||||
|
@ -352,6 +360,8 @@ class glance::api(
|
||||||
$image_cache_max_size = $::os_service_default,
|
$image_cache_max_size = $::os_service_default,
|
||||||
$image_cache_stall_time = $::os_service_default,
|
$image_cache_stall_time = $::os_service_default,
|
||||||
$image_cache_dir = '/var/lib/glance/image-cache',
|
$image_cache_dir = '/var/lib/glance/image-cache',
|
||||||
|
$image_import_plugins = $::os_service_default,
|
||||||
|
$image_conversion_output_format = $::os_service_default,
|
||||||
$enabled_import_methods = $::os_service_default,
|
$enabled_import_methods = $::os_service_default,
|
||||||
$node_staging_uri = $::os_service_default,
|
$node_staging_uri = $::os_service_default,
|
||||||
$image_member_quota = $::os_service_default,
|
$image_member_quota = $::os_service_default,
|
||||||
|
@ -497,6 +507,18 @@ class glance::api(
|
||||||
'glance_store/os_region_name': value => $os_region_name;
|
'glance_store/os_region_name': value => $os_region_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if $image_import_plugins != $::os_service_default {
|
||||||
|
$image_import_plugins_real = sprintf('[%s]', join(any2array($image_import_plugins), ','))
|
||||||
|
} else {
|
||||||
|
$image_import_plugins_real = $image_import_plugins
|
||||||
|
}
|
||||||
|
|
||||||
|
glance_image_import_config {
|
||||||
|
'image_import_opts/image_import_plugins': value => $image_import_plugins_real;
|
||||||
|
'image_conversion/output_format': value => $image_conversion_output_format;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# configure api service to connect registry service
|
# configure api service to connect registry service
|
||||||
glance_api_config {
|
glance_api_config {
|
||||||
'DEFAULT/registry_host': value => $registry_host;
|
'DEFAULT/registry_host': value => $registry_host;
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
# [*cache_config*]
|
# [*cache_config*]
|
||||||
# (optional) Allow configuration of glance-cache.conf configurations.
|
# (optional) Allow configuration of glance-cache.conf configurations.
|
||||||
#
|
#
|
||||||
|
# [*image_import_config*]
|
||||||
|
# (optional) Allow configuration of glance-image-import.conf configurations.
|
||||||
|
#
|
||||||
# NOTE: The configuration MUST NOT be already handled by this module
|
# NOTE: The configuration MUST NOT be already handled by this module
|
||||||
# or Puppet catalog compilation will fail with duplicate resources.
|
# or Puppet catalog compilation will fail with duplicate resources.
|
||||||
#
|
#
|
||||||
|
@ -51,6 +54,7 @@ class glance::config (
|
||||||
$registry_config = {},
|
$registry_config = {},
|
||||||
$registry_paste_ini_config = {},
|
$registry_paste_ini_config = {},
|
||||||
$cache_config = {},
|
$cache_config = {},
|
||||||
|
$image_import_config = {},
|
||||||
# deprecated
|
# deprecated
|
||||||
$glare_config = undef,
|
$glare_config = undef,
|
||||||
$glare_paste_ini_config = undef,
|
$glare_paste_ini_config = undef,
|
||||||
|
@ -68,10 +72,12 @@ you should use puppet-glare module for configuring Glare service.")
|
||||||
validate_hash($registry_config)
|
validate_hash($registry_config)
|
||||||
validate_hash($registry_paste_ini_config)
|
validate_hash($registry_paste_ini_config)
|
||||||
validate_hash($cache_config)
|
validate_hash($cache_config)
|
||||||
|
validate_hash($image_import_config)
|
||||||
|
|
||||||
create_resources('glance_api_config', $api_config)
|
create_resources('glance_api_config', $api_config)
|
||||||
create_resources('glance_api_paste_ini', $api_paste_ini_config)
|
create_resources('glance_api_paste_ini', $api_paste_ini_config)
|
||||||
create_resources('glance_registry_config', $registry_config)
|
create_resources('glance_registry_config', $registry_config)
|
||||||
create_resources('glance_registry_paste_ini', $registry_paste_ini_config)
|
create_resources('glance_registry_paste_ini', $registry_paste_ini_config)
|
||||||
create_resources('glance_cache_config', $cache_config)
|
create_resources('glance_cache_config', $cache_config)
|
||||||
|
create_resources('glance_image_import_config', $image_import_config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ class glance::deps {
|
||||||
Anchor['glance::config::begin'] -> Glance_api_config<||> ~> Anchor['glance::config::end']
|
Anchor['glance::config::begin'] -> Glance_api_config<||> ~> Anchor['glance::config::end']
|
||||||
Anchor['glance::config::begin'] -> Glance_api_paste_ini<||> ~> Anchor['glance::config::end']
|
Anchor['glance::config::begin'] -> Glance_api_paste_ini<||> ~> Anchor['glance::config::end']
|
||||||
Anchor['glance::config::begin'] -> Glance_cache_config<||> ~> Anchor['glance::config::end']
|
Anchor['glance::config::begin'] -> Glance_cache_config<||> ~> Anchor['glance::config::end']
|
||||||
|
Anchor['glance::config::begin'] -> Glance_image_import_config<||> ~> Anchor['glance::config::end']
|
||||||
Anchor['glance::config::begin'] -> Glance_registry_config<||> ~> Anchor['glance::config::end']
|
Anchor['glance::config::begin'] -> Glance_registry_config<||> ~> Anchor['glance::config::end']
|
||||||
Anchor['glance::config::begin'] -> Glance_registry_paste_ini<||> ~> Anchor['glance::config::end']
|
Anchor['glance::config::begin'] -> Glance_registry_paste_ini<||> ~> Anchor['glance::config::end']
|
||||||
Anchor['glance::config::begin'] -> Glance_swift_config<||> ~> Anchor['glance::config::end']
|
Anchor['glance::config::begin'] -> Glance_swift_config<||> ~> Anchor['glance::config::end']
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add new parameter 'image_import_plugins', to enable plugins
|
||||||
|
used by image import process.
|
||||||
|
Add parameter 'output_format', to provide desired output
|
||||||
|
format for image conversion plugin.
|
|
@ -11,6 +11,7 @@ describe 'basic glance config resource' do
|
||||||
File <||> -> Glance_api_config <||>
|
File <||> -> Glance_api_config <||>
|
||||||
File <||> -> Glance_registry_config <||>
|
File <||> -> Glance_registry_config <||>
|
||||||
File <||> -> Glance_cache_config <||>
|
File <||> -> Glance_cache_config <||>
|
||||||
|
File <||> -> Glance_image_import_config <||>
|
||||||
|
|
||||||
file { '/etc/glance' :
|
file { '/etc/glance' :
|
||||||
ensure => directory,
|
ensure => directory,
|
||||||
|
@ -24,6 +25,9 @@ describe 'basic glance config resource' do
|
||||||
file { '/etc/glance/glance-cache.conf' :
|
file { '/etc/glance/glance-cache.conf' :
|
||||||
ensure => file,
|
ensure => file,
|
||||||
}
|
}
|
||||||
|
file { '/etc/glance/glance-image-import.conf' :
|
||||||
|
ensure => file,
|
||||||
|
}
|
||||||
|
|
||||||
glance_api_config { 'DEFAULT/thisshouldexist' :
|
glance_api_config { 'DEFAULT/thisshouldexist' :
|
||||||
value => 'foo',
|
value => 'foo',
|
||||||
|
@ -79,6 +83,24 @@ describe 'basic glance config resource' do
|
||||||
ensure_absent_val => 'toto',
|
ensure_absent_val => 'toto',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glance_image_import_config { 'DEFAULT/thisshouldexist' :
|
||||||
|
value => 'foo',
|
||||||
|
}
|
||||||
|
|
||||||
|
glance_image_import_config { 'DEFAULT/thisshouldnotexist' :
|
||||||
|
value => '<SERVICE DEFAULT>',
|
||||||
|
}
|
||||||
|
|
||||||
|
glance_image_import_config { 'DEFAULT/thisshouldexist2' :
|
||||||
|
value => '<SERVICE DEFAULT>',
|
||||||
|
ensure_absent_val => 'toto',
|
||||||
|
}
|
||||||
|
|
||||||
|
glance_image_import_config { 'DEFAULT/thisshouldnotexist2' :
|
||||||
|
value => 'toto',
|
||||||
|
ensure_absent_val => 'toto',
|
||||||
|
}
|
||||||
|
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,5 +142,16 @@ describe 'basic glance config resource' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe file('/etc/glance/glance-image-import.conf') do
|
||||||
|
it { is_expected.to exist }
|
||||||
|
it { is_expected.to contain('thisshouldexist=foo') }
|
||||||
|
it { is_expected.to contain('thisshouldexist2=<SERVICE DEFAULT>') }
|
||||||
|
|
||||||
|
describe '#content' do
|
||||||
|
subject { super().content }
|
||||||
|
it { is_expected.not_to match /thisshouldnotexist/ }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,6 +32,8 @@ describe 'glance::api' do
|
||||||
:scrub_time => '<SERVICE DEFAULT>',
|
:scrub_time => '<SERVICE DEFAULT>',
|
||||||
:default_store => false,
|
:default_store => false,
|
||||||
:image_cache_dir => '/var/lib/glance/image-cache',
|
:image_cache_dir => '/var/lib/glance/image-cache',
|
||||||
|
:image_import_plugins => '<SERVICE DEFAULT>',
|
||||||
|
:image_conversion_output_format => '<SERVICE DEFAULT>',
|
||||||
:enabled_import_methods => '<SERVICE DEFAULT>',
|
:enabled_import_methods => '<SERVICE DEFAULT>',
|
||||||
:node_staging_uri => '<SERVICE DEFAULT>',
|
:node_staging_uri => '<SERVICE DEFAULT>',
|
||||||
:image_member_quota => '<SERVICE DEFAULT>',
|
:image_member_quota => '<SERVICE DEFAULT>',
|
||||||
|
@ -72,6 +74,8 @@ describe 'glance::api' do
|
||||||
:delayed_delete => 'true',
|
:delayed_delete => 'true',
|
||||||
:scrub_time => '10',
|
:scrub_time => '10',
|
||||||
:image_cache_dir => '/tmp/glance',
|
:image_cache_dir => '/tmp/glance',
|
||||||
|
:image_import_plugins => 'image_conversion',
|
||||||
|
:image_conversion_output_format => 'raw',
|
||||||
:enabled_import_methods => 'glance-direct,web-download',
|
:enabled_import_methods => 'glance-direct,web-download',
|
||||||
:node_staging_uri => '/tmp/staging',
|
:node_staging_uri => '/tmp/staging',
|
||||||
:image_member_quota => '128',
|
:image_member_quota => '128',
|
||||||
|
@ -149,6 +153,20 @@ describe 'glance::api' do
|
||||||
"[%s]" % param_hash[:enabled_import_methods])
|
"[%s]" % param_hash[:enabled_import_methods])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'is_expected.to lay down default image_import_plugins config' do
|
||||||
|
# Verify brackets "[]" are added to satisfy the ListOpt syntax.
|
||||||
|
is_expected.to contain_glance_image_import_config("image_import_opts/image_import_plugins").with_value(
|
||||||
|
"[%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
|
||||||
|
end
|
||||||
|
|
||||||
it 'is_expected.to lay down default cache config' do
|
it 'is_expected.to lay down default cache config' do
|
||||||
[
|
[
|
||||||
'registry_host',
|
'registry_host',
|
||||||
|
|
|
@ -59,6 +59,18 @@ describe 'glance::config' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'glance_image_import_config' do
|
||||||
|
let :params do
|
||||||
|
{ :image_import_config => config_hash }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures arbitrary glance-image-import configurations' do
|
||||||
|
is_expected.to contain_glance_image_import_config('DEFAULT/foo').with_value('fooValue')
|
||||||
|
is_expected.to contain_glance_image_import_config('DEFAULT/bar').with_value('barValue')
|
||||||
|
is_expected.to contain_glance_image_import_config('DEFAULT/baz').with_ensure('absent')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
on_supported_os({
|
on_supported_os({
|
||||||
:supported_os => OSDefaults.get_supported_os
|
:supported_os => OSDefaults.get_supported_os
|
||||||
}).each do |os,facts|
|
}).each do |os,facts|
|
||||||
|
@ -70,6 +82,7 @@ describe 'glance::config' do
|
||||||
it_configures 'glance_api_config'
|
it_configures 'glance_api_config'
|
||||||
it_configures 'glance_registry_config'
|
it_configures 'glance_registry_config'
|
||||||
it_configures 'glance_cache_config'
|
it_configures 'glance_cache_config'
|
||||||
|
it_configures 'glance_image_import_config'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
$LOAD_PATH.push(
|
||||||
|
File.join(
|
||||||
|
File.dirname(__FILE__),
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'fixtures',
|
||||||
|
'modules',
|
||||||
|
'inifile',
|
||||||
|
'lib')
|
||||||
|
)
|
||||||
|
$LOAD_PATH.push(
|
||||||
|
File.join(
|
||||||
|
File.dirname(__FILE__),
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'..',
|
||||||
|
'fixtures',
|
||||||
|
'modules',
|
||||||
|
'openstacklib',
|
||||||
|
'lib')
|
||||||
|
)
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
provider_class = Puppet::Type.type(:glance_image_import_config).provider(:ini_setting)
|
||||||
|
|
||||||
|
describe provider_class do
|
||||||
|
|
||||||
|
it 'should default to the default setting when no other one is specified' do
|
||||||
|
resource = Puppet::Type::Glance_image_import_config.new(
|
||||||
|
{
|
||||||
|
:name => 'DEFAULT/foo',
|
||||||
|
:value => 'bar'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
provider = provider_class.new(resource)
|
||||||
|
expect(provider.section).to eq('DEFAULT')
|
||||||
|
expect(provider.setting).to eq('foo')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should allow setting to be set explicitly' do
|
||||||
|
resource = Puppet::Type::Glance_image_import_config.new(
|
||||||
|
{
|
||||||
|
:name => 'dude/foo',
|
||||||
|
:value => 'bar'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
provider = provider_class.new(resource)
|
||||||
|
expect(provider.section).to eq('dude')
|
||||||
|
expect(provider.setting).to eq('foo')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||||
|
resource = Puppet::Type::Glance_image_import_config.new(
|
||||||
|
{:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
|
||||||
|
)
|
||||||
|
provider = provider_class.new(resource)
|
||||||
|
provider.exists?
|
||||||
|
expect(resource[:ensure]).to eq :absent
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should ensure absent when value matches ensure_absent_val' do
|
||||||
|
resource = Puppet::Type::Glance_image_import_config.new(
|
||||||
|
{:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' }
|
||||||
|
)
|
||||||
|
provider = provider_class.new(resource)
|
||||||
|
provider.exists?
|
||||||
|
expect(resource[:ensure]).to eq :absent
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,41 @@
|
||||||
|
require 'puppet'
|
||||||
|
require 'puppet/type/glance_image_import_config'
|
||||||
|
|
||||||
|
describe 'Puppet::Type.type(:glance_image_import_config)' do
|
||||||
|
before :each do
|
||||||
|
Puppet::Type.rmtype(:glance_image_import_config)
|
||||||
|
Facter.fact(:osfamily).stubs(:value).returns(platform_params[:osfamily])
|
||||||
|
@glance_image_import_config = Puppet::Type.type(:glance_image_import_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'glance_image_import_config' do
|
||||||
|
it 'should autorequire the package that install the file' do
|
||||||
|
catalog = Puppet::Resource::Catalog.new
|
||||||
|
package = Puppet::Type.type(:package).new(:name => platform_params[:package_name])
|
||||||
|
catalog.add_resource package, @glance_image_import_config
|
||||||
|
dependency = @glance_image_import_config.autorequire
|
||||||
|
expect(dependency.size).to eq(1)
|
||||||
|
expect(dependency[0].target).to eq(@glance_image_import_config)
|
||||||
|
expect(dependency[0].source).to eq(package)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on Debian platforms' do
|
||||||
|
let :platform_params do
|
||||||
|
{ :package_name => 'glance-api',
|
||||||
|
:osfamily => 'Debian' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'glance_image_import_config'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on RedHat platforms' do
|
||||||
|
let :platform_params do
|
||||||
|
{ :package_name => 'openstack-glance',
|
||||||
|
:osfamily => 'RedHat'}
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'glance_image_import_config'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue