Add support for cinder RBD driver parameter

Add the ability to control the rbd_flatten_volume_from_snapshot
setting in cinder's RBD driver. The parameter has been supported in
puppet-cinder for a while, and this patch makes it possible to
control the value using hiera data.

Change-Id: I430a2d1793ffcd0964d268a1930e3fb85e32a995
This commit is contained in:
Alan Bishop 2019-08-30 12:43:55 -07:00
parent 04b14abc04
commit d4affe0a5b
2 changed files with 64 additions and 51 deletions

View File

@ -51,45 +51,53 @@
# (Optional) The user name for the RBD client # (Optional) The user name for the RBD client
# Defaults to 'openstack' # Defaults to 'openstack'
# #
# [*cinder_rbd_flatten_volume_from_snapshot*]
# (Optional) Whether volumes created from a snapshot should be flattened
# in order to remove a dependency on the snapshot.
# Defaults to hiera('cinder::backend::rbd::flatten_volume_from_snapshot, undef)
#
# [*step*] # [*step*]
# (Optional) The current step in deployment. See tripleo-heat-templates # (Optional) The current step in deployment. See tripleo-heat-templates
# for more details. # for more details.
# Defaults to hiera('step') # Defaults to hiera('step')
# #
class tripleo::profile::base::cinder::volume::rbd ( class tripleo::profile::base::cinder::volume::rbd (
$backend_name = hiera('cinder::backend::rbd::volume_backend_name', 'tripleo_ceph'), $backend_name = hiera('cinder::backend::rbd::volume_backend_name', 'tripleo_ceph'),
$backend_availability_zone = hiera('cinder::backend::rbd::backend_availability_zone', undef), $backend_availability_zone = hiera('cinder::backend::rbd::backend_availability_zone', undef),
# lint:ignore:parameter_documentation # lint:ignore:parameter_documentation
$cinder_rbd_backend_host = hiera('cinder::backend_host', hiera('cinder::host', $::hostname)), $cinder_rbd_backend_host = hiera('cinder::backend_host', hiera('cinder::host', $::hostname)),
# lint:endignore # lint:endignore
$cinder_rbd_ceph_conf = hiera('cinder::backend::rbd::rbd_ceph_conf', '/etc/ceph/ceph.conf'), $cinder_rbd_ceph_conf = hiera('cinder::backend::rbd::rbd_ceph_conf', '/etc/ceph/ceph.conf'),
$cinder_rbd_pool_name = 'volumes', $cinder_rbd_pool_name = 'volumes',
$cinder_rbd_extra_pools = undef, $cinder_rbd_extra_pools = undef,
$cinder_rbd_secret_uuid = undef, $cinder_rbd_secret_uuid = undef,
$cinder_rbd_user_name = 'openstack', $cinder_rbd_user_name = 'openstack',
$step = Integer(hiera('step')), $cinder_rbd_flatten_volume_from_snapshot = hiera('cinder::backend::rbd::flatten_volume_from_snapshot', undef),
$step = Integer(hiera('step')),
) { ) {
include ::tripleo::profile::base::cinder::volume include ::tripleo::profile::base::cinder::volume
if $step >= 4 { if $step >= 4 {
cinder::backend::rbd { $backend_name : cinder::backend::rbd { $backend_name :
backend_availability_zone => $backend_availability_zone, backend_availability_zone => $backend_availability_zone,
backend_host => $cinder_rbd_backend_host, backend_host => $cinder_rbd_backend_host,
rbd_ceph_conf => $cinder_rbd_ceph_conf, rbd_ceph_conf => $cinder_rbd_ceph_conf,
rbd_pool => $cinder_rbd_pool_name, rbd_pool => $cinder_rbd_pool_name,
rbd_user => $cinder_rbd_user_name, rbd_user => $cinder_rbd_user_name,
rbd_secret_uuid => $cinder_rbd_secret_uuid, rbd_secret_uuid => $cinder_rbd_secret_uuid,
rbd_flatten_volume_from_snapshot => $cinder_rbd_flatten_volume_from_snapshot,
} }
if $cinder_rbd_extra_pools { if $cinder_rbd_extra_pools {
$cinder_rbd_extra_pools.each |$pool_name| { $cinder_rbd_extra_pools.each |$pool_name| {
cinder::backend::rbd { "${backend_name}_${pool_name}" : cinder::backend::rbd { "${backend_name}_${pool_name}" :
backend_availability_zone => $backend_availability_zone, backend_availability_zone => $backend_availability_zone,
backend_host => $cinder_rbd_backend_host, backend_host => $cinder_rbd_backend_host,
rbd_ceph_conf => $cinder_rbd_ceph_conf, rbd_ceph_conf => $cinder_rbd_ceph_conf,
rbd_pool => $pool_name, rbd_pool => $pool_name,
rbd_user => $cinder_rbd_user_name, rbd_user => $cinder_rbd_user_name,
rbd_secret_uuid => $cinder_rbd_secret_uuid, rbd_secret_uuid => $cinder_rbd_secret_uuid,
rbd_flatten_volume_from_snapshot => $cinder_rbd_flatten_volume_from_snapshot,
} }
} }
} }

View File

@ -41,10 +41,11 @@ describe 'tripleo::profile::base::cinder::volume::rbd' do
context 'with defaults' do context 'with defaults' do
it 'should trigger complete configuration' do it 'should trigger complete configuration' do
is_expected.to contain_cinder__backend__rbd('tripleo_ceph').with( is_expected.to contain_cinder__backend__rbd('tripleo_ceph').with(
:backend_host => 'node.example.com', :backend_host => 'node.example.com',
:rbd_ceph_conf => '/etc/ceph/ceph.conf', :rbd_ceph_conf => '/etc/ceph/ceph.conf',
:rbd_pool => 'volumes', :rbd_pool => 'volumes',
:rbd_user => 'openstack', :rbd_user => 'openstack',
:rbd_flatten_volume_from_snapshot => '<SERVICE DEFAULT>',
) )
end end
end end
@ -52,40 +53,44 @@ describe 'tripleo::profile::base::cinder::volume::rbd' do
context 'with customizations' do context 'with customizations' do
before :each do before :each do
params.merge!({ params.merge!({
:backend_name => 'poodles', :backend_name => 'poodles',
:backend_availability_zone => 'my_zone', :backend_availability_zone => 'my_zone',
:cinder_rbd_backend_host => 'fe80::fc54:ff:fe9e:7846', :cinder_rbd_backend_host => 'fe80::fc54:ff:fe9e:7846',
:cinder_rbd_ceph_conf => '/etc/ceph/mycluster.conf', :cinder_rbd_ceph_conf => '/etc/ceph/mycluster.conf',
:cinder_rbd_pool_name => 'poolname', :cinder_rbd_pool_name => 'poolname',
:cinder_rbd_extra_pools => ['aplenty', 'galore'], :cinder_rbd_extra_pools => ['aplenty', 'galore'],
:cinder_rbd_secret_uuid => 'secretuuid', :cinder_rbd_secret_uuid => 'secretuuid',
:cinder_rbd_user_name => 'kcatsnepo' :cinder_rbd_user_name => 'kcatsnepo',
:cinder_rbd_flatten_volume_from_snapshot => true,
}) })
end end
it 'should trigger complete configuration' do it 'should trigger complete configuration' do
is_expected.to contain_cinder__backend__rbd('poodles').with( is_expected.to contain_cinder__backend__rbd('poodles').with(
:backend_host => 'fe80::fc54:ff:fe9e:7846', :backend_host => 'fe80::fc54:ff:fe9e:7846',
:backend_availability_zone => 'my_zone', :backend_availability_zone => 'my_zone',
:rbd_ceph_conf => '/etc/ceph/mycluster.conf', :rbd_ceph_conf => '/etc/ceph/mycluster.conf',
:rbd_pool => 'poolname', :rbd_pool => 'poolname',
:rbd_user => 'kcatsnepo', :rbd_user => 'kcatsnepo',
:rbd_secret_uuid => 'secretuuid' :rbd_secret_uuid => 'secretuuid',
:rbd_flatten_volume_from_snapshot => true,
) )
is_expected.to contain_cinder__backend__rbd('poodles_aplenty').with( is_expected.to contain_cinder__backend__rbd('poodles_aplenty').with(
:backend_host => 'fe80::fc54:ff:fe9e:7846', :backend_host => 'fe80::fc54:ff:fe9e:7846',
:backend_availability_zone => 'my_zone', :backend_availability_zone => 'my_zone',
:rbd_ceph_conf => '/etc/ceph/mycluster.conf', :rbd_ceph_conf => '/etc/ceph/mycluster.conf',
:rbd_pool => 'aplenty', :rbd_pool => 'aplenty',
:rbd_user => 'kcatsnepo', :rbd_user => 'kcatsnepo',
:rbd_secret_uuid => 'secretuuid' :rbd_secret_uuid => 'secretuuid',
:rbd_flatten_volume_from_snapshot => true,
) )
is_expected.to contain_cinder__backend__rbd('poodles_galore').with( is_expected.to contain_cinder__backend__rbd('poodles_galore').with(
:backend_host => 'fe80::fc54:ff:fe9e:7846', :backend_host => 'fe80::fc54:ff:fe9e:7846',
:backend_availability_zone => 'my_zone', :backend_availability_zone => 'my_zone',
:rbd_ceph_conf => '/etc/ceph/mycluster.conf', :rbd_ceph_conf => '/etc/ceph/mycluster.conf',
:rbd_pool => 'galore', :rbd_pool => 'galore',
:rbd_user => 'kcatsnepo', :rbd_user => 'kcatsnepo',
:rbd_secret_uuid => 'secretuuid' :rbd_secret_uuid => 'secretuuid',
:rbd_flatten_volume_from_snapshot => true,
) )
end end
end end