Handle cinder volume type for multiple cinder stores
1. Adding 'cinder_volume_type' configuration parameter to allow cinder stores to specify a volume type for each cinder store. 2. Removed the restrictions are imposed to allow only a single instance of the 'cinder'. Partially Implements: blueprint multiple-cinder-backend-support Change-Id: I58df2815e59fe064fe3f0f1d5e1cd35e63d5bdd1
This commit is contained in:
parent
50b5095d11
commit
0dcb12907d
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
before :each do
|
||||
params.merge!({
|
||||
:multistore_config => {
|
||||
'my_cinder' => {
|
||||
'GlanceStoreDescription' => 'My multistore cinder 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
|
||||
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 => {
|
||||
'cinder2' => {
|
||||
'GlanceCinderVolumeType' => 'glance-cinder2',
|
||||
'GlanceStoreDescription' => 'cinder2 backend',
|
||||
},
|
||||
},
|
||||
:cinder_volume_type => 'glance-cinder1',
|
||||
:store_description => 'cinder1 backend',
|
||||
})
|
||||
end
|
||||
it_raises 'a Puppet::Error', /Multiple cinder backends are not supported./
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user