We know where lspci wil be
[mirror/dsa-puppet.git] / facts / raidarray.rb
1 Facter.add("smartarraycontroller") do
2         confine :kernel => :linux
3         ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin"
4         setcode do
5                 ishp = "false"
6                 if ((FileTest.executable?("/usr/bin/lspci")) && (FileTest.exist?("/proc/bus/pci")))
7                         %x{lspci}.each { |s|
8                                 ishp = "true" if s =~ /RAID bus controller: (.*) Smart Array/
9                         }
10                 end
11                 ishp == "true"
12         end
13 end
14
15 Facter.add("mptcontroller") do
16         confine :kernel => :linux
17         setcode do
18                 FileTest.exist?("/proc/mpt/summary")
19         end
20 end
21
22 Facter.add("3warecontroller") do
23         confine :kernel => :linux
24         setcode do
25                 is3w = "false"
26                 if FileTest.exist?("/proc/scsi/scsi")
27                         IO.foreach("/proc/scsi/scsi") { |x|
28                                 is3w = "true" if x =~ /Vendor: 3ware/
29                         }
30                 end
31                 is3w == "true"
32         end
33 end
34
35 Facter.add("swraid") do
36         confine :kernel => :linux
37         setcode do
38                 swraid = "false"
39                 if FileTest.exist?("/proc/mdstat") && FileTest.exist?("/sbin/mdadm")
40                         IO.foreach("/proc/mdstat") { |x|
41                                 swraid = "true" if x =~ /md[0-9]+ : active/
42                         }
43                 end
44                 swraid == "true"
45         end
46 end
47