RBD backend: use ensure_resource

In the case we want to declare more than one backend using RBD driver,
we have a resource dupplication which could be fixed by using stlib
functions.

Closes-bug #1294138
Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>

Change-Id: I1783540cd8218e8bafb4d0b860ca4c5992f35a19
This commit is contained in:
Emilien Macchi
2014-03-18 15:43:18 +01:00
parent 4d4017cb63
commit 6dba575af6
2 changed files with 20 additions and 8 deletions

View File

@@ -98,14 +98,12 @@ define cinder::backend::rbd (
}
# Creates an empty file if it doesn't yet exist
file { $::cinder::params::ceph_init_override:
ensure => present,
}
ensure_resource('file', $::cinder::params::ceph_init_override, {'ensure' => 'present'})
file_line { 'set initscript env':
line => $override_line,
path => $::cinder::params::ceph_init_override,
notify => Service['cinder-volume'],
}
ensure_resource('file_line', 'set initscript env', {
line => $override_line,
path => $::cinder::params::ceph_init_override,
notify => Service['cinder-volume']
})
}

View File

@@ -56,6 +56,20 @@ describe 'cinder::backend::rbd' do
it { should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_tmp_dir").with_ensure('absent') }
end
context 'with another RBD backend' do
let :pre_condition do
"cinder::backend::rbd { 'ceph2':
rbd_pool => 'volumes2',
rbd_user => 'test'
}"
end
it { should contain_cinder_config("#{req_params[:volume_backend_name]}/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver') }
it { should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_pool").with_value(req_params[:rbd_pool]) }
it { should contain_cinder_config("#{req_params[:volume_backend_name]}/rbd_user").with_value(req_params[:rbd_user]) }
it { should contain_cinder_config("ceph2/volume_driver").with_value('cinder.volume.drivers.rbd.RBDDriver') }
it { should contain_cinder_config("ceph2/rbd_pool").with_value('volumes2') }
it { should contain_cinder_config("ceph2/rbd_user").with_value('test') }
end
end
describe 'with RedHat' do