Extend cinder::setup_test_volume to use cinder provided path
cinder::setup_test_volume should now support RHEL6 and RHEL7 and also Fedora systems. It should use cinder provided path and not file in /tmp and it should set correct permissions to it. Change-Id: Iee783a3445c97b6559d63d0d501b12028b7b2b26
This commit is contained in:
parent
18d1d2964c
commit
efc90a8fd4
@ -13,33 +13,45 @@
|
||||
# [*loopback_device*]
|
||||
# Loop device name. Defaults to '/dev/loop2'.
|
||||
#
|
||||
# [*volume_path*]
|
||||
# Volume image location. Defaults to '/var/lib/cinder'.
|
||||
class cinder::setup_test_volume(
|
||||
$volume_name = 'cinder-volumes',
|
||||
$volume_path = '/var/lib/cinder',
|
||||
$size = '4G',
|
||||
$loopback_device = '/dev/loop2'
|
||||
) {
|
||||
|
||||
Exec {
|
||||
cwd => '/tmp/',
|
||||
}
|
||||
|
||||
package { 'lvm2':
|
||||
ensure => present,
|
||||
} ~>
|
||||
|
||||
exec { "/bin/dd if=/dev/zero of=${volume_name} bs=1 count=0 seek=${size}":
|
||||
unless => "/sbin/vgdisplay ${volume_name}"
|
||||
file { $volume_path:
|
||||
ensure => directory,
|
||||
owner => 'cinder',
|
||||
group => 'cinder',
|
||||
require => Package['cinder'],
|
||||
} ~>
|
||||
|
||||
exec { "/sbin/losetup ${loopback_device} ${volume_name}":
|
||||
exec { "create_${volume_path}/${volume_name}":
|
||||
command => "dd if=/dev/zero of=\"${volume_path}/${volume_name}\" bs=1 count=0 seek=${size}",
|
||||
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
|
||||
unless => "stat ${volume_path}/${volume_name}",
|
||||
} ~>
|
||||
|
||||
exec { "losetup ${loopback_device} ${volume_path}/${volume_name}":
|
||||
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
|
||||
refreshonly => true,
|
||||
} ~>
|
||||
|
||||
exec { "/sbin/pvcreate ${loopback_device}":
|
||||
exec { "pvcreate ${loopback_device}":
|
||||
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
|
||||
unless => "pvdisplay | grep ${volume_name}",
|
||||
refreshonly => true,
|
||||
} ~>
|
||||
|
||||
exec { "/sbin/vgcreate ${volume_name} ${loopback_device}":
|
||||
exec { "vgcreate ${volume_name} ${loopback_device}":
|
||||
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ define cinder::type_set (
|
||||
}
|
||||
|
||||
exec {"cinder type-key ${type} set ${key}=${name}":
|
||||
path => '/usr/bin',
|
||||
path => ['/usr/bin', '/bin'],
|
||||
command => "cinder type-key ${type} set ${key}=${name}",
|
||||
environment => concat($cinder_env, $region_env),
|
||||
require => Package['python-cinderclient']
|
||||
|
@ -6,10 +6,17 @@ describe 'cinder::setup_test_volume' do
|
||||
:ensure => 'present'
|
||||
) }
|
||||
|
||||
it { should contain_file('/var/lib/cinder').with(
|
||||
:ensure => 'directory',
|
||||
:require => 'Package[cinder]'
|
||||
) }
|
||||
|
||||
it 'should contain volume creation execs' do
|
||||
should contain_exec('/bin/dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=4G')
|
||||
should contain_exec('/sbin/losetup /dev/loop2 cinder-volumes')
|
||||
should contain_exec('/sbin/pvcreate /dev/loop2')
|
||||
should contain_exec('/sbin/vgcreate cinder-volumes /dev/loop2')
|
||||
should contain_exec('create_/var/lib/cinder/cinder-volumes').with(
|
||||
:command => 'dd if=/dev/zero of="/var/lib/cinder/cinder-volumes" bs=1 count=0 seek=4G'
|
||||
)
|
||||
should contain_exec('losetup /dev/loop2 /var/lib/cinder/cinder-volumes')
|
||||
should contain_exec('pvcreate /dev/loop2')
|
||||
should contain_exec('vgcreate cinder-volumes /dev/loop2')
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user