forked from jhoblitt/puppet-smartd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Hoblitt
committed
Apr 29, 2014
1 parent
e7d78b5
commit f575189
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Facter.add(:megacli_version) do | ||
megacli = Facter.value(:megacli) | ||
|
||
setcode do | ||
unless megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Cli -aALL") | ||
next if output.nil? | ||
m = output.match(/MegaCLI SAS RAID Management Tool Ver ([\d\.]+)/) | ||
next unless m.size == 2 | ||
m[1] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
|
||
MegaCLI SAS RAID Management Tool Ver 8.07.07 Dec 19, 2012 | ||
|
||
(c)Copyright 2011, LSI Corporation, All Rights Reserved. | ||
|
||
Exit Code: 0x00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
|
||
describe 'megacli_version', :type => :fact do | ||
before(:each) { Facter.clear } | ||
|
||
context 'megacli fact not set' do | ||
it 'should return nil' do | ||
Facter.fact(:megacli).stubs(:value).returns(nil) | ||
Facter.fact(:megacli_version).value.should be_nil | ||
end | ||
end | ||
|
||
context 'megacli fact is broken' do | ||
it 'should return nil' do | ||
Facter.fact(:megacli).stubs(:value).returns('foobar') | ||
Facter.fact(:megacli_version).value.should be_nil | ||
end | ||
end | ||
|
||
context 'megacli fact is working' 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 -Cli -aALL'). | ||
returns(File.read(fixtures('megacli', 'version-cli-aall-8.07.07'))) | ||
Facter.fact(:megacli_version).value.should == '8.07.07' | ||
end | ||
end | ||
|
||
end | ||
|