Allow RBD host to be configurable

Most sites using ceph with cinder are going to have already set the host
value.  This change allows those sites to override the default and not
break existing volumes.  It also moves the tests cases from the volume
class to the backend define.  Lastly, it renames the parameter from host
to backend_host, since host is deprecated with Kilo.

Change-Id: I43e4d3b7ae1672ea0c551c6c7267f0c38bb9842f
This commit is contained in:
Clayton O'Neill 2015-10-05 15:44:17 +00:00
parent 0724a23b58
commit e226c0ed95
3 changed files with 30 additions and 2 deletions

View File

@ -11,6 +11,12 @@
# [*rbd_user*]
# (required) A required parameter to configure OS init scripts and cephx.
#
# [*backend_host*]
# (optional) Allows specifying the hostname/key used for the owner of volumes
# created. This must be set to the same value on all nodes in a multi-node
# environment.
# Defaults to 'rbd:<rbd_pool>'
#
# [*volume_backend_name*]
# (optional) Allows for the volume_backend_name to be separate of $name.
# Defaults to: $name
@ -47,6 +53,7 @@
define cinder::backend::rbd (
$rbd_pool,
$rbd_user,
$backend_host = undef,
$volume_backend_name = $name,
$rbd_ceph_conf = '/etc/ceph/ceph.conf',
$rbd_flatten_volume_from_snapshot = false,
@ -66,11 +73,20 @@ define cinder::backend::rbd (
"${name}/rbd_pool": value => $rbd_pool;
"${name}/rbd_max_clone_depth": value => $rbd_max_clone_depth;
"${name}/rbd_flatten_volume_from_snapshot": value => $rbd_flatten_volume_from_snapshot;
"${name}/host": value => "rbd:${rbd_pool}";
"${name}/rbd_secret_uuid": value => $rbd_secret_uuid;
"${name}/volume_tmp_dir": value => $volume_tmp_dir;
}
if $backend_host {
cinder_config {
"${name}/backend_host": value => $backend_host;
}
} else {
cinder_config {
"${name}/backend_host": value => "rbd:${rbd_pool}";
}
}
create_resources('cinder_config', $extra_options)
case $::osfamily {

View File

@ -34,7 +34,6 @@ describe 'cinder::volume::rbd' do
is_expected.to contain_cinder_config('DEFAULT/rbd_pool').with_value(req_params[:rbd_pool])
is_expected.to contain_cinder_config('DEFAULT/rbd_user').with_value(req_params[:rbd_user])
is_expected.to contain_cinder_config('DEFAULT/rbd_secret_uuid').with_value(req_params[:rbd_secret_uuid])
is_expected.to contain_cinder_config('DEFAULT/host').with_value('rbd:'"#{req_params[:rbd_pool]}")
is_expected.to contain_file('/etc/init/cinder-volume.override').with(:ensure => 'present')
is_expected.to contain_file_line('set initscript env').with(
:line => /env CEPH_ARGS=\"--id test\"/,

View File

@ -38,6 +38,7 @@ describe 'cinder::backend::rbd' do
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_pool").with_value(req_params[:rbd_pool])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_user").with_value(req_params[:rbd_user])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_secret_uuid").with_value(req_params[:rbd_secret_uuid])
is_expected.to contain_cinder_config("#{req_params[:volume_backend_name]}/backend_host").with_value('rbd:'"#{req_params[:rbd_pool]}")
is_expected.to contain_file('/etc/init/cinder-volume.override').with(:ensure => 'present')
is_expected.to contain_file_line('set initscript env').with(
:line => /env CEPH_ARGS=\"--id test\"/,
@ -72,6 +73,18 @@ describe 'cinder::backend::rbd' do
end
end
context 'override backend_host parameter' do
before do
params.merge!({:backend_host => 'test_host.fqdn.com' })
end
it 'configure rbd backend with specific hostname' do
is_expected.to contain_cinder_config('rbd-ssd/backend_host').with({
:value => 'test_host.fqdn.com',
})
end
end
end
describe 'with RedHat' do