diff --git a/lib/puppet/provider/volume_group/lvm.rb b/lib/puppet/provider/volume_group/lvm.rb index 44ac190f..bd26851c 100644 --- a/lib/puppet/provider/volume_group/lvm.rb +++ b/lib/puppet/provider/volume_group/lvm.rb @@ -44,7 +44,12 @@ def self.get_logical_volume_properties(volume_groups_line) end def create - vgcreate(@resource[:name], *@resource.should(:physical_volumes)) + vgcreate_args = [@resource[:name], *@resource.should(:physical_volumes)] + extent_args = @resource[:extent_size].nil? ? [] : ['-s', @resource[:extent_size]] + + vgcreate_args.append(*extent_args) + + vgcreate(*vgcreate_args) end def destroy diff --git a/lib/puppet/type/volume_group.rb b/lib/puppet/type/volume_group.rb index b98de0f1..8572d93a 100644 --- a/lib/puppet/type/volume_group.rb +++ b/lib/puppet/type/volume_group.rb @@ -10,6 +10,10 @@ isnamevar end + newparam(:extent_size) do + desc 'The physical extent size. Uses OS default if not provided. Only applicable on Linux.' + end + newproperty(:physical_volumes, array_matching: :all) do desc "The list of physical volumes to be included in the volume group; this will automatically set these as dependencies, but they must be defined elsewhere diff --git a/spec/unit/puppet/provider/volume_group/lvm_spec.rb b/spec/unit/puppet/provider/volume_group/lvm_spec.rb index d17fcdc9..78c91007 100644 --- a/spec/unit/puppet/provider/volume_group/lvm_spec.rb +++ b/spec/unit/puppet/provider/volume_group/lvm_spec.rb @@ -28,11 +28,24 @@ end describe 'when creating' do - it "executes 'vgcreate'" do - @resource.expects(:[]).with(:name).returns('myvg') - @resource.expects(:should).with(:physical_volumes).returns(['/dev/hda']) - @provider.expects(:vgcreate).with('myvg', '/dev/hda') - @provider.create + context 'when an extent size is not provided' do + it "executes 'vgcreate'" do + @resource.expects(:[]).with(:name).returns('myvg') + @resource.expects(:[]).with(:extent_size).returns(nil) + @resource.expects(:should).with(:physical_volumes).returns(['/dev/hda']) + @provider.expects(:vgcreate).with('myvg', '/dev/hda') + @provider.create + end + end + + context 'when an extent size is provided' do + it "executes 'vgcreate' with the desired extent size" do + @resource.expects(:[]).with(:name).returns('myvg') + @resource.expects(:[]).twice.with(:extent_size).returns('16M') + @resource.expects(:should).with(:physical_volumes).returns(['/dev/hda']) + @provider.expects(:vgcreate).with('myvg', '/dev/hda', '-s', '16M') + @provider.create + end end end diff --git a/spec/unit/puppet/type/volume_group_spec.rb b/spec/unit/puppet/type/volume_group_spec.rb index 2800d797..4f3b990f 100644 --- a/spec/unit/puppet/type/volume_group_spec.rb +++ b/spec/unit/puppet/type/volume_group_spec.rb @@ -18,6 +18,12 @@ end end + describe 'the extent_size parameter' do + it 'exists' do + @type.attrclass(:extent_size).should_not be_nil + end + end + describe "the 'ensure' parameter" do it 'exists' do @type.attrclass(:ensure).should_not be_nil