Browse Source

Merge "Handle cinder volume type for multiple cinder stores"

changes/40/772340/4
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
3140ca5c4e
2 changed files with 69 additions and 36 deletions
  1. +29
    -20
      manifests/profile/base/glance/backend/cinder.pp
  2. +40
    -16
      spec/classes/tripleo_profile_base_glance_backend_cinder_spec.rb

+ 29
- 20
manifests/profile/base/glance/backend/cinder.pp View File

@ -73,6 +73,10 @@
# (Optional) Directory where the NFS volume is mounted on the glance node.
# Defaults to hiera('glance::backend::cinder::cinder_mount_point_base', undef)
#
# [*cinder_volume_type*]
# (Optional) The volume type to be used to create image volumes in cinder.
# Defaults to hiera('glance::backend::cinder::cinder_volume_type', undef)
#
# [*store_description*]
# (Optional) Provides constructive information about the store backend to
# end users.
@ -98,34 +102,39 @@ class tripleo::profile::base::glance::backend::cinder (
$cinder_enforce_multipath = hiera('glance::backend::cinder::cinder_enforce_multipath', undef),
$cinder_use_multipath = hiera('glance::backend::cinder::cinder_use_multipath', undef),
$cinder_mount_point_base = hiera('glance::backend::cinder::cinder_mount_point_base', undef),
$cinder_volume_type = hiera('glance::backend::cinder::cinder_volume_type', undef),
$store_description = hiera('tripleo::profile::base::glance::api::glance_store_description', 'Cinder store'),
$step = Integer(hiera('step')),
) {
if $backend_names.length() > 1 {
fail('Multiple cinder backends are not supported.')
}
if $step >= 4 {
$backend_name = $backend_names[0]
$backend_names.each |String $backend_name| {
$backend_config = pick($multistore_config[$backend_name], {})
$store_description_real = pick($backend_config['GlanceStoreDescription'], $store_description)
$multistore_description = pick($multistore_config[$backend_name], {})['GlanceStoreDescription']
$store_description_real = pick($multistore_description, $store_description)
if $backend_config['GlanceCinderVolumeType'] {
$cinder_volume_type_real = $backend_config['GlanceCinderVolumeType']
} else {
$cinder_volume_type_real = $cinder_volume_type
}
glance::backend::multistore::cinder { $backend_name:
cinder_api_insecure => $cinder_api_insecure,
cinder_catalog_info => $cinder_catalog_info,
cinder_http_retries => $cinder_http_retries,
cinder_endpoint_template => $cinder_endpoint_template,
cinder_ca_certificates_file => $cinder_ca_certificates_file,
cinder_store_auth_address => $cinder_store_auth_address,
cinder_store_project_name => $cinder_store_project_name,
cinder_store_user_name => $cinder_store_user_name,
cinder_store_password => $cinder_store_password,
cinder_enforce_multipath => $cinder_enforce_multipath,
cinder_use_multipath => $cinder_use_multipath,
cinder_mount_point_base => $cinder_mount_point_base,
store_description => $store_description_real,
glance::backend::multistore::cinder { $backend_name:
cinder_api_insecure => $cinder_api_insecure,
cinder_catalog_info => $cinder_catalog_info,
cinder_http_retries => $cinder_http_retries,
cinder_endpoint_template => $cinder_endpoint_template,
cinder_ca_certificates_file => $cinder_ca_certificates_file,
cinder_store_auth_address => $cinder_store_auth_address,
cinder_store_project_name => $cinder_store_project_name,
cinder_store_user_name => $cinder_store_user_name,
cinder_store_password => $cinder_store_password,
cinder_enforce_multipath => $cinder_enforce_multipath,
cinder_use_multipath => $cinder_use_multipath,
cinder_mount_point_base => $cinder_mount_point_base,
cinder_volume_type => $cinder_volume_type_real,
store_description => $store_description_real,
}
}
}
}

+ 40
- 16
spec/classes/tripleo_profile_base_glance_backend_cinder_spec.rb View File

@ -37,7 +37,6 @@ describe 'tripleo::profile::base::glance::backend::cinder' do
context 'with step 4' do
let(:params) { {
:backend_names => ['my_cinder'],
:cinder_ca_certificates_file => '/path/to/certificates_file',
:cinder_api_insecure => true,
:cinder_catalog_info => 'volume:cinder:internalURL',
@ -50,6 +49,9 @@ describe 'tripleo::profile::base::glance::backend::cinder' do
:cinder_enforce_multipath => true,
:cinder_use_multipath => true,
:cinder_mount_point_base => '/var/lib/glance/mnt/nfs',
:cinder_volume_type => 'glance-my_cinder',
:store_description => 'Cinder store',
:backend_names => ['my_cinder'],
:step => 4,
} }
@ -67,34 +69,56 @@ describe 'tripleo::profile::base::glance::backend::cinder' do
:cinder_enforce_multipath => true,
:cinder_use_multipath => true,
:cinder_mount_point_base => '/var/lib/glance/mnt/nfs',
:cinder_volume_type => 'glance-my_cinder',
:store_description => 'Cinder store',
)
end
context 'with store description in multistore_config' do
context 'with store description and volume type in multistore_config' do
before :each do
params.merge!({
:multistore_config => {
'my_cinder' => {
'GlanceCinderVolumeType' => 'glance-cinder',
'GlanceStoreDescription' => 'My multistore cinder backend',
},
},
})
end
it 'should use the multistore_config description and volume type' do
is_expected.to contain_glance__backend__multistore__cinder('my_cinder').with(
:cinder_volume_type => 'glance-cinder',
:store_description => 'My multistore cinder backend',
)
end
end
context 'with multiple backend_names' do
before :each do
params.merge!({
:backend_names => ['cinder1', 'cinder2'],
:multistore_config => {
'my_cinder' => {
'GlanceStoreDescription' => 'My multistore cinder backend',
'cinder2' => {
'GlanceCinderVolumeType' => 'glance-cinder2',
'GlanceStoreDescription' => 'cinder2 backend',
},
},
:cinder_volume_type => 'glance-cinder1',
:store_description => 'cinder1 backend',
})
end
it 'should use the multistore_config description' do
is_expected.to contain_glance__backend__multistore__cinder('my_cinder').with(
:store_description => 'My multistore cinder backend',
)
end
end
context 'with multiple backend_names' do
before :each do
params.merge!({
:backend_names => ['cinder1', 'cinder2'],
})
it 'should configure multiple backends' do
is_expected.to contain_glance__backend__multistore__cinder('cinder1').with(
:cinder_volume_type => 'glance-cinder1',
:store_description => 'cinder1 backend',
)
is_expected.to contain_glance__backend__multistore__cinder('cinder2').with(
:cinder_volume_type => 'glance-cinder2',
:store_description => 'cinder2 backend',
)
end
it_raises 'a Puppet::Error', /Multiple cinder backends are not supported./
end
end
end


Loading…
Cancel
Save