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.
Merge pull request jhoblitt#40 from negz/master
Expose PD sizes, and support older MegaCli binaries.
- Loading branch information
Showing
20 changed files
with
643 additions
and
67 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,15 @@ | ||
Facter.add(:megacli) do | ||
confine :kernel => :linux | ||
|
||
megacli_binaries = ['MegaCli', 'megacli'] | ||
|
||
setcode do | ||
Facter::Util::Resolution.which('MegaCli') | ||
path = nil | ||
megacli_binaries.each do |bin| | ||
path = Facter::Util::Resolution.which(bin) | ||
next if path.nil? | ||
break | ||
end | ||
path | ||
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,21 @@ | ||
require 'semver' | ||
|
||
# Legacy versions of MegaCLI require different arguments to determine certain | ||
# software and firmware versions. | ||
Facter.add(:megacli_legacy) do | ||
megacli = Facter.value(:megacli) | ||
megacli_version = Facter.value(:megacli_version) | ||
|
||
setcode do | ||
next if megacli.nil? | ||
next if megacli_version.nil? | ||
|
||
# Modern version assumed from changelog at | ||
# http://www.lsi.com/downloads/Public/RAID%20Controllers/RAID%20Controllers%20Common%20Files/Linux%20MegaCLI%208.07.10.txt | ||
actual_version = SemVer.new(megacli_version) | ||
modern_version = SemVer.new('8.02.16') | ||
|
||
actual_version < modern_version | ||
|
||
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 |
---|---|---|
@@ -1,13 +1,23 @@ | ||
Facter.add(:megacli_version) do | ||
megacli = Facter.value(:megacli) | ||
version_commands = ["#{megacli} -Version -Cli -aALL -NoLog", | ||
"#{megacli} -v -aALL -NoLog"] | ||
|
||
setcode do | ||
unless megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Cli -aALL -NoLog") | ||
next if megacli.nil? | ||
|
||
version = nil | ||
# This is a bit hacky, but we need to try different commands to ascertain | ||
# the version of the megacli binary. | ||
version_commands.each do |cmd| | ||
output = Facter::Util::Resolution.exec(cmd) | ||
next if output.nil? | ||
m = output.match(/MegaCLI SAS RAID Management Tool Ver ([\d\.]+)/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
version = m[1] | ||
break | ||
end | ||
version | ||
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 |
---|---|---|
@@ -1,13 +1,30 @@ | ||
Facter.add(:megaraid_fw_package_build) do | ||
confine :megacli_legacy => false | ||
|
||
megacli = Facter.value(:megacli) | ||
setcode do | ||
next if megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Ctrl -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/F[wW] Package Build\s*:\s*([\d\.\-]+)\s*$/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
end | ||
end | ||
|
||
|
||
Facter.add(:megaraid_fw_package_build) do | ||
confine :megacli_legacy => true | ||
|
||
megacli = Facter.value(:megacli) | ||
setcode do | ||
unless megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Ctrl -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/Fw Package Build : ([\d\.\-]+)\s*$/) | ||
next unless m.size == 2 | ||
m[1] | ||
end | ||
next if megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -AdpAllInfo -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/F[wW] Package Build\s*:\s*([\d\.\-]+)\s*$/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
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 |
---|---|---|
@@ -1,13 +1,30 @@ | ||
Facter.add(:megaraid_fw_version) do | ||
confine :megacli_legacy => false | ||
|
||
megacli = Facter.value(:megacli) | ||
setcode do | ||
next if megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Ctrl -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/FW Version\s*:\s*([\d\.\-]+)\s*$/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
end | ||
end | ||
|
||
|
||
Facter.add(:megaraid_fw_version) do | ||
confine :megacli_legacy => true | ||
|
||
megacli = Facter.value(:megacli) | ||
setcode do | ||
unless megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Ctrl -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/FW Version : ([\d\.\-]+)\s*$/) | ||
next unless m.size == 2 | ||
m[1] | ||
end | ||
next if megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -AdpAllInfo -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/FW Version\s*:\s*([\d\.\-]+)\s*$/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
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,25 @@ | ||
Facter.add(:megaraid_physical_drives_size) 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 | ||
sizes = [] | ||
list = Facter::Util::Resolution.exec("#{megacli} -PDList -aALL -NoLog") | ||
next if list.nil? | ||
list.each_line do |line| | ||
if line =~ /Raw Size: ([\.\d]+ [A-Z]?B)/ | ||
sizes.push($1) | ||
end | ||
end | ||
|
||
sizes.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 |
---|---|---|
@@ -1,13 +1,30 @@ | ||
Facter.add(:megaraid_product_name) do | ||
confine :megacli_legacy => false | ||
|
||
megacli = Facter.value(:megacli) | ||
setcode do | ||
next if megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Ctrl -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/Product Name\s*:\s*(.+)\s*$/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
end | ||
end | ||
|
||
|
||
Facter.add(:megaraid_product_name) do | ||
confine :megacli_legacy => true | ||
|
||
megacli = Facter.value(:megacli) | ||
setcode do | ||
unless megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Ctrl -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/Product Name : (.+)\s*$/) | ||
next unless m.size == 2 | ||
m[1] | ||
end | ||
next if megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -AdpAllInfo -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/Product Name\s*:\s*(.+)\s*$/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
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 |
---|---|---|
@@ -1,14 +1,30 @@ | ||
Facter.add(:megaraid_serial) do | ||
confine :megacli_legacy => false | ||
|
||
megacli = Facter.value(:megacli) | ||
setcode do | ||
next if megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -Version -Ctrl -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/Serial No\s*:\s*(\S+)\s*$/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
end | ||
end | ||
|
||
|
||
Facter.add(:megaraid_serial) do | ||
confine :megacli_legacy => true | ||
|
||
megacli = Facter.value(:megacli) | ||
setcode do | ||
unless megacli.nil? | ||
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 | ||
next if megacli.nil? | ||
output = Facter::Util::Resolution.exec("#{megacli} -AdpAllInfo -aALL -NoLog") | ||
next if output.nil? | ||
m = output.match(/Serial No\s*:\s*(\S+)\s*$/) | ||
next if m.nil? | ||
next unless m.size == 2 | ||
m[1] | ||
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
Oops, something went wrong.