Skip to content

Commit

Permalink
Merge pull request #30 from jhoblitt/feature/megaraid_facts
Browse files Browse the repository at this point in the history
update megaraid_serial fact to deal with SM motherboards
  • Loading branch information
Joshua Hoblitt committed May 22, 2014
2 parents 34ccdd4 + 9d2d44b commit 97af513
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/facter/megaraid_serial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
output = Facter::Util::Resolution.exec("#{megacli} -Version -Ctrl -aALL -NoLog")
next if output.nil?
m = output.match(/Serial No : (\S+)\s*$/)
next if m.nil?
next unless m.size == 2
m[1]
end
Expand Down
10 changes: 10 additions & 0 deletions spec/fixtures/megacli/version-ctrl-aall-sm_no_serial
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

CTRL VERSION:
================

Product Name : Supermicro SMC2208
Serial No :
Fw Package Build : 23.9.0-0015
FW Version : 3.220.05-1881

Exit Code: 0x00
10 changes: 10 additions & 0 deletions spec/unit/facts/megaraid_serial_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
returns(File.read(fixtures('megacli', 'version-ctrl-aall-8.07.07')))
Facter.fact(:megaraid_serial).value.should == 'SV22925366'
end

context 'megacli output is missing serial number' do
it 'should get the version string' do
Facter.fact(:megacli).stubs(:value).returns('/usr/bin/MegaCli')
Facter::Util::Resolution.stubs(:exec).
with('/usr/bin/MegaCli -Version -Ctrl -aALL -NoLog').
returns(File.read(fixtures('megacli', 'version-ctrl-aall-sm_no_serial')))
Facter.fact(:megaraid_serial).value.should be_nil
end
end
end

end
Expand Down

0 comments on commit 97af513

Please sign in to comment.