From e226c0ed95ce5321dcbf0a3a5188098734b5cab8 Mon Sep 17 00:00:00 2001 From: Clayton O'Neill Date: Mon, 5 Oct 2015 15:44:17 +0000 Subject: [PATCH] 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 --- manifests/backend/rbd.pp | 18 +++++++++++++++++- spec/classes/cinder_volume_rbd_spec.rb | 1 - spec/defines/cinder_backend_rbd_spec.rb | 13 +++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/manifests/backend/rbd.pp b/manifests/backend/rbd.pp index 4ba62b22..66ceb620 100644 --- a/manifests/backend/rbd.pp +++ b/manifests/backend/rbd.pp @@ -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:' +# # [*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 { diff --git a/spec/classes/cinder_volume_rbd_spec.rb b/spec/classes/cinder_volume_rbd_spec.rb index 0d5e6f37..fc06c01f 100644 --- a/spec/classes/cinder_volume_rbd_spec.rb +++ b/spec/classes/cinder_volume_rbd_spec.rb @@ -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\"/, diff --git a/spec/defines/cinder_backend_rbd_spec.rb b/spec/defines/cinder_backend_rbd_spec.rb index b0d54e4b..ff526821 100644 --- a/spec/defines/cinder_backend_rbd_spec.rb +++ b/spec/defines/cinder_backend_rbd_spec.rb @@ -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