Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow modifying the physical extent size for volume groups #333

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/puppet/provider/volume_group/lvm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet/type/volume_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 18 additions & 5 deletions spec/unit/puppet/provider/volume_group/lvm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions spec/unit/puppet/type/volume_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down