X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=facts%2Fraidcontroller.rb;h=8a09a71ca76c464d12db88d1cb5d9d982e2d27cd;hb=df361af8358dc4084afc4ec502cab8546d6bf47a;hp=f2834c2dcf3a72abc81f4ee7f94523a9b8a8dfb5;hpb=eb8d9c9ed20621f4081cb4049c4a6227aacb5f59;p=mirror%2Fdsa-puppet.git diff --git a/facts/raidcontroller.rb b/facts/raidcontroller.rb index f2834c2dc..8a09a71ca 100644 --- a/facts/raidcontroller.rb +++ b/facts/raidcontroller.rb @@ -5,11 +5,11 @@ Facter.add("smartarraycontroller") do ishp = "false" lspciexists = system "/bin/bash -c 'which lspci >&/dev//null'" if $?.exitstatus == 0 - %x{lspci}.each { |s| + %x{lspci 2>&1}.each { |s| ishp = "true" if s =~ /RAID bus controller: (.*) Smart Array/ } end - ishp + ishp == "true" end end @@ -29,6 +29,20 @@ Facter.add("3warecontroller") do is3w = "true" if x =~ /Vendor: 3ware/ } end - is3w + is3w == "true" end end + +Facter.add("swraid") do + confine :kernel => :linux + setcode do + swraid = "false" + if FileTest.exist?("/proc/mdstat") && FileTest.exist?("/sbin/mdadm") + IO.foreach("/proc/mdstat") { |x| + swraid = "true" if x =~ /md[0-9]+ : active/ + } + end + swraid == "true" + end +end +