Skip to content

Commit a6ddc6c

Browse files
committed
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 (cherry picked from commit efc90a8)
1 parent 037cace commit a6ddc6c

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

manifests/setup_test_volume.pp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,45 @@
1313
# [*loopback_device*]
1414
# Loop device name. Defaults to '/dev/loop2'.
1515
#
16+
# [*volume_path*]
17+
# Volume image location. Defaults to '/var/lib/cinder'.
1618
class cinder::setup_test_volume(
1719
$volume_name = 'cinder-volumes',
20+
$volume_path = '/var/lib/cinder',
1821
$size = '4G',
1922
$loopback_device = '/dev/loop2'
2023
) {
2124

22-
Exec {
23-
cwd => '/tmp/',
24-
}
25-
2625
package { 'lvm2':
2726
ensure => present,
2827
} ~>
2928

30-
exec { "/bin/dd if=/dev/zero of=${volume_name} bs=1 count=0 seek=${size}":
31-
unless => "/sbin/vgdisplay ${volume_name}"
29+
file { $volume_path:
30+
ensure => directory,
31+
owner => 'cinder',
32+
group => 'cinder',
33+
require => Package['cinder'],
34+
} ~>
35+
36+
exec { "create_${volume_path}/${volume_name}":
37+
command => "dd if=/dev/zero of=\"${volume_path}/${volume_name}\" bs=1 count=0 seek=${size}",
38+
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
39+
unless => "stat ${volume_path}/${volume_name}",
3240
} ~>
3341

34-
exec { "/sbin/losetup ${loopback_device} ${volume_name}":
42+
exec { "losetup ${loopback_device} ${volume_path}/${volume_name}":
43+
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
3544
refreshonly => true,
3645
} ~>
3746

38-
exec { "/sbin/pvcreate ${loopback_device}":
47+
exec { "pvcreate ${loopback_device}":
48+
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
49+
unless => "pvdisplay | grep ${volume_name}",
3950
refreshonly => true,
4051
} ~>
4152

42-
exec { "/sbin/vgcreate ${volume_name} ${loopback_device}":
53+
exec { "vgcreate ${volume_name} ${loopback_device}":
54+
path => ['/bin','/usr/bin','/sbin','/usr/sbin'],
4355
refreshonly => true,
4456
}
4557

manifests/type_set.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
}
5757

5858
exec {"cinder type-key ${type} set ${key}=${name}":
59-
path => '/usr/bin',
59+
path => ['/usr/bin', '/bin'],
6060
command => "cinder type-key ${type} set ${key}=${name}",
6161
environment => concat($cinder_env, $region_env),
6262
require => Package['python-cinderclient']

spec/classes/cinder_setup_test_volume_spec.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66
:ensure => 'present'
77
) }
88

9+
it { should contain_file('/var/lib/cinder').with(
10+
:ensure => 'directory',
11+
:require => 'Package[cinder]'
12+
) }
13+
914
it 'should contain volume creation execs' do
10-
should contain_exec('/bin/dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=4G')
11-
should contain_exec('/sbin/losetup /dev/loop2 cinder-volumes')
12-
should contain_exec('/sbin/pvcreate /dev/loop2')
13-
should contain_exec('/sbin/vgcreate cinder-volumes /dev/loop2')
15+
should contain_exec('create_/var/lib/cinder/cinder-volumes').with(
16+
:command => 'dd if=/dev/zero of="/var/lib/cinder/cinder-volumes" bs=1 count=0 seek=4G'
17+
)
18+
should contain_exec('losetup /dev/loop2 /var/lib/cinder/cinder-volumes')
19+
should contain_exec('pvcreate /dev/loop2')
20+
should contain_exec('vgcreate cinder-volumes /dev/loop2')
1421
end
1522
end

0 commit comments

Comments
 (0)