Exporting RAID controller information¶
This adds two new facts – raidtype, which specifies whether software or hardware raid is in use, and a raidcontroller fact, which current lists a partial string of all ‘RAID bus controller: ’ entries in lspci output. Neither of these feel like particularly elegant ways of doing this this yet, but I’m open to suggestions. — daniellawson
Facter.add("raidtype") do
confine :kernel => :linux
ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin"
setcode do
raidtype = []
if FileTest.exists?("/proc/mdstat")
txt = File.read("/proc/mdstat")
raidtype.push("software") if txt =~ /^md/i
end
lspciexists = system "/bin/bash -c 'which lspci >&/dev//null'"
if $?.exitstatus == 0
output = %x{lspci}
output.each { |s|
raidtype.push("hardware") if s =~ /RAID/i
}
end
raidtype.join(",")
end
end
Facter.add("raidcontroller") do
confine :kernel => :linux
ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin"
setcode do
controllers = []
lspciexists = system "/bin/bash -c 'which lspci >&/dev//null'"
if $?.exitstatus == 0
output = %x{lspci}
output.each {|s|
controllers.push($1) if s =~ /RAID bus controller: (.*)/
}
end
controllers.join(",")
end
end