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.
refactor megaraid facts + add fact tests
* stop checking for megaraid `/dev/*` files and instead let megacli tell us if it can find any raid controllers * use blockdevice facts instead of exec'ing `lsscsi`, inspired by Kyle Anderson's [gist](https://gist.github.com/solarkennedy/7606943) * split each fact into it's own .rb file * add rspec test coverage of all facts * remove non-functioning freebsd facts completely
- Loading branch information
Joshua Hoblitt
committed
Dec 21, 2013
1 parent
dbdbd4a
commit 0d15b7e
Showing
15 changed files
with
3,673 additions
and
97 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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
pkg/ | ||
spec/fixtures/ | ||
spec/fixtures/manifests/ | ||
spec/fixtures/modules/ | ||
Gemfile.lock | ||
*.orig | ||
*.rej | ||
*.patch | ||
.rspec_system/ | ||
*.swp |
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 @@ | ||
Facter.add(:megacli) do | ||
confine :kernel => :linux | ||
|
||
setcode do | ||
Facter::Util::Resolution.which('MegaCli') | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
# Figure out if this machine has AMI/LSI MegaRAID aka Dell PERC | ||
# storage controllers, and if so, how many physical disks are | ||
# attached. Currently implemented only on Linux because none of | ||
# our FreeBSD machines use these controllers, so I don't have an | ||
# example "mfiutil show config" to write a parser for and test | ||
# against. | ||
|
||
Facter.add(:megaraid_adapters) do | ||
confine :kernel => 'Linux' | ||
|
||
setcode do | ||
megacli = Facter.value(:megacli) | ||
|
||
if megacli.nil? | ||
next nil | ||
end | ||
|
||
# -adpCount sends it's entire output to the stderr | ||
count = Facter::Util::Resolution.exec("#{megacli} -adpCount 2>&1") | ||
count =~ /Controller Count:\s+(\d+)\./ ? $1 : '0' | ||
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,27 @@ | ||
Facter.add(:megaraid_physical_drives) do | ||
confine :kernel => 'Linux' | ||
|
||
setcode do | ||
megacli = Facter.value(:megacli) | ||
megaraid_adapters = Facter.value(:megaraid_adapters) | ||
|
||
if megacli.nil? || | ||
megaraid_adapters.nil? || (megaraid_adapters == 0) | ||
next nil | ||
end | ||
|
||
# XXX there is no support for handling more than one adapter | ||
pds = [] | ||
list = Facter::Util::Resolution.exec("#{megacli} -PDList -aALL") | ||
next if list.nil? | ||
list.each_line do |line| | ||
if line =~ /^Device Id:\s+(\d+)/ | ||
pds.push($1) | ||
end | ||
end | ||
|
||
# sort the device IDs numerically on the assumption that they are always | ||
# integers | ||
pds.sort {|a,b| a.to_i <=> b.to_i}.join(",") | ||
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,34 @@ | ||
# Try to figure out what should be used as the "device" parameter | ||
# for smartd. On FreeBSD it's simple, just use /dev/mfi%d, but | ||
# on Linux we have to find a block device that corresponds to a | ||
# *logical* drive on the controller. Any logical drive will do, | ||
# so long as it's on the same controller. We only support one | ||
# controller for now. | ||
Facter.add(:megaraid_virtual_drives) do | ||
confine :kernel => 'Linux' | ||
|
||
setcode do | ||
megacli = Facter.value(:megacli) | ||
megaraid_adapters = Facter.value(:megaraid_adapters) | ||
blockdevices = Facter.value(:blockdevices) | ||
|
||
if megacli.nil? || | ||
megaraid_adapters.nil? || (megaraid_adapters == 0) || | ||
blockdevices.nil? | ||
next nil | ||
end | ||
|
||
vds = [] | ||
|
||
devices = blockdevices.split(',') | ||
devices.each do |dev| | ||
vendor = Facter.value("blockdevice_#{dev}_vendor") | ||
case vendor | ||
when 'LSI', 'SMC' | ||
vds << dev | ||
end | ||
end | ||
|
||
vds.sort.join(',') | ||
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
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,6 @@ | ||
|
||
|
||
Controller Count: 0. | ||
|
||
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,5 @@ | ||
|
||
|
||
Controller Count: 1. | ||
|
||
Exit Code: 0x01 |
Oops, something went wrong.