Skip to content

Commit 879c4bd

Browse files
committed
Merge pull request #135 from walkamongus/master
Fix issue with using force method as pvcreate argument
2 parents f6ba933 + bacac55 commit 879c4bd

File tree

2 files changed

+13
-8
lines changed
  • lib/puppet/provider/physical_volume
  • spec/unit/puppet/provider/physical_volume

2 files changed

+13
-8
lines changed

lib/puppet/provider/physical_volume/lvm.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ def self.instances
1111
end
1212

1313
def create
14-
pvcreate(force, @resource[:name])
14+
create_physical_volume(@resource[:name])
1515
end
1616

1717
def destroy
18-
pvremove(@resource[:name])
18+
pvremove(@resource[:name])
1919
end
2020

2121
def exists?
@@ -71,9 +71,15 @@ def self.get_physical_volume_properties(physical_volumes_line)
7171
physical_volumes_properties
7272
end
7373

74-
def force
75-
return '--force' if @resource[:force] == :true
76-
nil
74+
private
75+
76+
def create_physical_volume(path)
77+
args = []
78+
if @resource[:force] == :true
79+
args.push('--force')
80+
end
81+
args << path
82+
pvcreate(*args)
7783
end
7884

7985
end

spec/unit/puppet/provider/physical_volume/lvm_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
end
2828

2929
describe 'when creating' do
30-
it "should execute the 'pvcreate'" do
30+
it "should execute the 'create_physical_volume'" do
3131
@resource.expects(:[]).with(:name).returns('/dev/hdx')
32-
@resource.expects(:[]).with(:force)
33-
@provider.expects(:pvcreate).with(nil, '/dev/hdx')
32+
@provider.expects(:create_physical_volume).with('/dev/hdx')
3433
@provider.create
3534
end
3635
end

0 commit comments

Comments
 (0)