]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/recipes/default.rb
The smartd on 12.04 doesn't support /dev/bus syntax
[chef.git] / cookbooks / hardware / recipes / default.rb
index eac54e7648043b006d0aa39b2009a43529cfd4d0..c9da86168f4fe00eebcc0aabaa02dd967c1d33cc 100644 (file)
@@ -275,7 +275,8 @@ if status_packages["megaclisas-status"]
 
     next unless driver == "megaraid_sas"
 
-    device = host.sub("/sys/class/scsi_host/host", "bus/")
+    bus = host.sub("/sys/class/scsi_host/host", "")
+    device = File.basename(Dir.glob("/sys/bus/scsi/devices/#{bus}:*/scsi_generic/*").first)
 
     IO.popen(["megacli", "-PDList", "-a#{controller}", "-NoLog"]).each do |line|
       disks << { :device => device, :driver => "megaraid",  :id => Regexp.last_match[1] } if line =~ /^Device Id: ([0-9]+)$/
@@ -285,6 +286,20 @@ if status_packages["megaclisas-status"]
   end
 end
 
+if status_packages["sas2ircu-status"]
+  Dir.glob("/sys/class/scsi_host/host*") do |host|
+    driver = File.new("#{host}/proc_name").read.chomp
+
+    next unless driver == "mpt2sas"
+
+    bus = host.sub("/sys/class/scsi_host/host", "")
+
+    Dir.glob("/sys/bus/scsi/devices/#{bus}:0:*/scsi_generic/*").each do |sg|
+      disks << { :device => File.basename(sg) }
+    end
+  end
+end
+
 if disks.count > 0
   package "smartmontools"