Skip to content

Commit fc12c66

Browse files
authored
Merge pull request #183 from tphoney/fact
Fact
2 parents 81bdec1 + 3d2e143 commit fc12c66

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

lib/facter/lvm_support.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
vg_list = []
1515
Facter.add('lvm_vgs') do
1616
confine :lvm_support => true
17-
vgs = Facter::Util::Resolution.exec('vgs -o name --noheadings 2>/dev/null')
17+
18+
vgs = Facter::Core::Execution.execute('vgs -o name --noheadings 2>/dev/null', timeout: 30)
1819
if vgs.nil?
1920
setcode { 0 }
2021
else
@@ -29,7 +30,7 @@
2930
Facter.add("lvm_vg_#{i}") { setcode { vg } }
3031
Facter.add("lvm_vg_#{vg}_pvs") do
3132
setcode do
32-
pvs = Facter::Util::Resolution.exec("vgs -o pv_name #{vg} 2>/dev/null")
33+
pvs = Facter::Core::Execution.execute("vgs -o pv_name #{vg} 2>/dev/null", timeout: 30)
3334
res = nil
3435
unless pvs.nil?
3536
res = pvs.split("\n").select{|l| l =~ /^\s+\// }.collect(&:strip).sort.join(',')
@@ -44,7 +45,8 @@
4445
pv_list = []
4546
Facter.add('lvm_pvs') do
4647
confine :lvm_support => true
47-
pvs = Facter::Util::Resolution.exec('pvs -o name --noheadings 2>/dev/null')
48+
49+
pvs = Facter::Core::Execution.execute('pvs -o name --noheadings 2>/dev/null', timeout: 30)
4850
if pvs.nil?
4951
setcode { 0 }
5052
else

spec/unit/facter/lvm_support_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@
5252
context 'when there is lvm support' do
5353
context 'when there are no vgs' do
5454
it 'should be set to 0' do
55-
Facter::Util::Resolution.stubs('exec') # All other calls
56-
Facter::Util::Resolution.expects('exec').at_least(1).with('vgs -o name --noheadings 2>/dev/null').returns(nil)
55+
Facter::Core::Execution.stubs(:execute) # All other calls
56+
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o name --noheadings 2>/dev/null', timeout: 30).returns(nil)
5757
Facter.fact(:lvm_support).expects(:value).at_least(1).returns(true)
5858
Facter.value(:lvm_vgs).should == 0
5959
end
6060
end
6161

6262
context 'when there are vgs' do
6363
it 'should list vgs' do
64-
Facter::Util::Resolution.stubs('exec') # All other calls
65-
Facter::Util::Resolution.expects('exec').at_least(1).with('vgs -o name --noheadings 2>/dev/null').returns("vg0\nvg1")
66-
Facter::Util::Resolution.expects('exec').at_least(1).with('vgs -o pv_name vg0 2>/dev/null').returns(" PV\n /dev/pv3\n /dev/pv2")
67-
Facter::Util::Resolution.expects('exec').at_least(1).with('vgs -o pv_name vg1 2>/dev/null').returns(" PV\n /dev/pv0")
64+
Facter::Core::Execution.stubs(:execute) # All other calls
65+
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o name --noheadings 2>/dev/null', timeout: 30).returns("vg0\nvg1")
66+
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o pv_name vg0 2>/dev/null', timeout: 30).returns(" PV\n /dev/pv3\n /dev/pv2")
67+
Facter::Core::Execution.expects(:execute).at_least(1).with('vgs -o pv_name vg1 2>/dev/null', timeout: 30).returns(" PV\n /dev/pv0")
6868
Facter.fact(:lvm_support).expects(:value).at_least(1).returns(true)
6969
Facter.value(:lvm_vgs).should == 2
7070
Facter.value(:lvm_vg_0).should == 'vg0'
@@ -92,17 +92,17 @@
9292
context 'when there is lvm support' do
9393
context 'when there are no pvs' do
9494
it 'should be set to 0' do
95-
Facter::Util::Resolution.stubs('exec') # All other calls
96-
Facter::Util::Resolution.expects('exec').at_least(1).with('pvs -o name --noheadings 2>/dev/null').returns(nil)
95+
Facter::Core::Execution.stubs('execute') # All other calls
96+
Facter::Core::Execution.expects('execute').at_least(1).with('pvs -o name --noheadings 2>/dev/null', timeout: 30).returns(nil)
9797
Facter.fact(:lvm_support).expects(:value).at_least(1).returns(true)
9898
Facter.value(:lvm_pvs).should == 0
9999
end
100100
end
101101

102102
context 'when there are pvs' do
103103
it 'should list pvs' do
104-
Facter::Util::Resolution.stubs('exec') # All other calls
105-
Facter::Util::Resolution.expects('exec').at_least(1).with('pvs -o name --noheadings 2>/dev/null').returns("pv0\npv1")
104+
Facter::Core::Execution.stubs('execute') # All other calls
105+
Facter::Core::Execution.expects('execute').at_least(1).with('pvs -o name --noheadings 2>/dev/null', timeout: 30).returns("pv0\npv1")
106106
Facter.fact(:lvm_support).expects(:value).at_least(1).returns(true)
107107
Facter.value(:lvm_pvs).should == 2
108108
Facter.value(:lvm_pv_0).should == 'pv0'

0 commit comments

Comments
 (0)