Skip to content

Commit

Permalink
update megaraid_serial fact to deal with SM motherboards
Browse files Browse the repository at this point in the history
Per jhoblitt#29, the LSI controller on at least some models of SuperMicro
motherboards does not report a serial number.  The megaraid_serial fact
has not gracefully handling this case and facter was generating errors.
  • Loading branch information
Joshua Hoblitt committed May 22, 2014
1 parent 34ccdd4 commit ebf88cd
Show file tree
Hide file tree
Showing 2 changed files with 11 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/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 ebf88cd

Please sign in to comment.