Iscsi: Allow one to specify volumes_dir path
It is currently impossible to specify a volumes_dir for iscsi backend. This commit allows one to specify it. Also it fixes the default currently used[1] to map cinder defaults[2][3]. [1] https://github.com/stackforge/puppet-cinder/blob/master/manifests/backend/iscsi.pp#L40 [2] https://github.com/openstack/cinder/blob/master/cinder/volume/driver.py#L106 [3] https://github.com/openstack/cinder/blob/master/cinder/common/config.py#L43 Change-Id: Ib49c4055198e895f7cc5b727db9bde93a5c92b8c
This commit is contained in:
parent
42a30e40a4
commit
ad1567ca5d
@ -9,13 +9,16 @@
|
||||
# [*volume_driver*]
|
||||
# (Optional) Driver to use for volume creation
|
||||
# Defaults to 'cinder.volume.drivers.lvm.LVMVolumeDriver'.
|
||||
#
|
||||
# [*volumes_dir*]
|
||||
# (Optional) Volume configuration file storage directory
|
||||
# Defaults to '/var/lib/cinder/volumes'.
|
||||
#
|
||||
define cinder::backend::iscsi (
|
||||
$iscsi_ip_address,
|
||||
$volume_backend_name = $name,
|
||||
$volume_driver = 'cinder.volume.drivers.lvm.LVMVolumeDriver',
|
||||
$volume_group = 'cinder-volumes',
|
||||
$volumes_dir = '/var/lib/cinder/volumes',
|
||||
$iscsi_helper = $::cinder::params::iscsi_helper,
|
||||
$iscsi_protocol = 'iscsi',
|
||||
) {
|
||||
@ -28,6 +31,7 @@ define cinder::backend::iscsi (
|
||||
"${name}/iscsi_ip_address": value => $iscsi_ip_address;
|
||||
"${name}/iscsi_helper": value => $iscsi_helper;
|
||||
"${name}/volume_group": value => $volume_group;
|
||||
"${name}/volumes_dir": value => $volumes_dir;
|
||||
"${name}/iscsi_protocol": value => $iscsi_protocol;
|
||||
}
|
||||
|
||||
@ -41,7 +45,7 @@ define cinder::backend::iscsi (
|
||||
if($::osfamily == 'RedHat') {
|
||||
file_line { 'cinder include':
|
||||
path => '/etc/tgt/targets.conf',
|
||||
line => 'include /etc/cinder/volumes/*',
|
||||
line => "include ${volumes_dir}/*",
|
||||
match => '#?include /',
|
||||
require => Package['tgt'],
|
||||
notify => Service['tgtd'],
|
||||
|
@ -15,6 +15,10 @@
|
||||
# (Optional) Name for the VG that will contain exported volumes
|
||||
# Defaults to 'cinder-volumes'.
|
||||
#
|
||||
# [*volumes_dir*]
|
||||
# (Optional) Volume configuration file storage directory
|
||||
# Defaults to '/var/lib/cinder/volumes'.
|
||||
#
|
||||
# [*iscsi_helper*]
|
||||
# (Optional) iSCSI target user-land tool to use.
|
||||
# Defaults to '$::cinder::params::iscsi_helper'.
|
||||
@ -27,6 +31,7 @@ class cinder::volume::iscsi (
|
||||
$iscsi_ip_address,
|
||||
$volume_driver = 'cinder.volume.drivers.lvm.LVMVolumeDriver',
|
||||
$volume_group = 'cinder-volumes',
|
||||
$volumes_dir = '/var/lib/cinder/volumes',
|
||||
$iscsi_helper = $::cinder::params::iscsi_helper,
|
||||
$iscsi_protocol = 'iscsi'
|
||||
) {
|
||||
@ -37,6 +42,7 @@ class cinder::volume::iscsi (
|
||||
iscsi_ip_address => $iscsi_ip_address,
|
||||
volume_driver => $volume_driver,
|
||||
volume_group => $volume_group,
|
||||
volumes_dir => $volumes_dir,
|
||||
iscsi_helper => $iscsi_helper,
|
||||
iscsi_protocol => $iscsi_protocol
|
||||
}
|
||||
|
@ -21,10 +21,22 @@ describe 'cinder::volume::iscsi' do
|
||||
it { should contain_cinder_config('DEFAULT/iscsi_ip_address').with(:value => '127.0.0.2')}
|
||||
it { should contain_cinder_config('DEFAULT/iscsi_helper').with(:value => 'tgtadm')}
|
||||
it { should contain_cinder_config('DEFAULT/volume_group').with(:value => 'cinder-volumes')}
|
||||
it { should contain_cinder_config('DEFAULT/volumes_dir').with(:value => '/var/lib/cinder/volumes')}
|
||||
it { should contain_cinder_config('DEFAULT/iscsi_protocol').with(:value => 'iscsi')}
|
||||
|
||||
end
|
||||
|
||||
describe 'with a non-default $volumes_dir' do
|
||||
let(:params) { req_params.merge(:volumes_dir => '/etc/cinder/volumes')}
|
||||
|
||||
it 'should contain a cinder::backend::iscsi resource with /etc/cinder/volumes as $volumes dir' do
|
||||
should contain_cinder__backend__iscsi('DEFAULT').with({
|
||||
:volumes_dir => '/etc/cinder/volumes'
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'with a unsupported iscsi helper' do
|
||||
let(:params) { req_params.merge(:iscsi_helper => 'fooboozoo')}
|
||||
|
||||
@ -48,7 +60,7 @@ describe 'cinder::volume::iscsi' do
|
||||
end
|
||||
|
||||
it { should contain_file_line('cinder include').with(
|
||||
:line => 'include /etc/cinder/volumes/*',
|
||||
:line => 'include /var/lib/cinder/volumes/*',
|
||||
:path => '/etc/tgt/targets.conf'
|
||||
) }
|
||||
|
||||
|
@ -22,6 +22,10 @@ describe 'cinder::backend::iscsi' do
|
||||
{:iscsi_protocol => 'iser'}
|
||||
end
|
||||
|
||||
let :volumes_dir_params do
|
||||
{:volumes_dir => '/etc/cinder/volumes'}
|
||||
end
|
||||
|
||||
describe 'with default params' do
|
||||
|
||||
it 'should configure iscsi driver' do
|
||||
@ -35,6 +39,8 @@ describe 'cinder::backend::iscsi' do
|
||||
:value => 'tgtadm')
|
||||
should contain_cinder_config('hippo/volume_group').with(
|
||||
:value => 'cinder-volumes')
|
||||
should contain_cinder_config('hippo/volumes_dir').with(
|
||||
:value => '/var/lib/cinder/volumes')
|
||||
should contain_cinder_config('hippo/iscsi_protocol').with(
|
||||
:value => 'iscsi')
|
||||
end
|
||||
@ -51,6 +57,18 @@ describe 'cinder::backend::iscsi' do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with non-default $volumes_dir' do
|
||||
before :each do
|
||||
params.merge!(volumes_dir_params)
|
||||
end
|
||||
|
||||
it 'should configure iscsi driver with /etc/cinder/volumes as volumes_dir' do
|
||||
should contain_cinder_config('hippo/volumes_dir').with(
|
||||
:value => '/etc/cinder/volumes'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with RedHat' do
|
||||
|
||||
let :facts do
|
||||
@ -58,7 +76,7 @@ describe 'cinder::backend::iscsi' do
|
||||
end
|
||||
|
||||
it { should contain_file_line('cinder include').with(
|
||||
:line => 'include /etc/cinder/volumes/*',
|
||||
:line => 'include /var/lib/cinder/volumes/*',
|
||||
:path => '/etc/tgt/targets.conf'
|
||||
) }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user