]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/templates/default/ohai.rb.erb
Don't set smart_device for cciss disks which aren't in the PD list
[chef.git] / cookbooks / hardware / templates / default / ohai.rb.erb
index 661a6833d7087c0c011247ee6b72c08a10488774..536377de4d136fa1407d84971f17e39b26f6007e 100644 (file)
@@ -403,7 +403,9 @@ Ohai.plugin(:Hardware) do
     end
 
     devices[:disks].each do |disk|
-      disk[:smart_device] = "cciss,#{disks.find_index(disk[:location])}"
+      if location = disks.find_index(disk[:location])
+        disk[:smart_device] = "cciss,#{location}"
+      end
 
       if disk[:status] == "Failed"
         disk[:status] = "failed"
@@ -519,7 +521,7 @@ Ohai.plugin(:Hardware) do
         end
       elsif disk && line =~ /^(\S.*\S)\s*:\s+(\S.*)$/
         case Regexp.last_match(1)
-        when "Device Id" then disk[:smart_device] = "megaraid,#{Regexp.last_match(2)}"
+        when "Device Id" then disk[:device_id] = Regexp.last_match(2)
         when "WWN" then disk[:wwn] = Regexp.last_match(2)
         when "PD Type" then disk[:interface] = Regexp.last_match(2)
         when "Raw Size" then disk[:size] = memory_to_disk_size(Regexp.last_match(2).sub(/\s*\[.*\]$/, ""))
@@ -597,12 +599,13 @@ Ohai.plugin(:Hardware) do
 
     disks.each do |disk|
       controller = devices[:controllers][disk[:controller]]
-      id = disk.delete(:device_id)
 
-      if device = Dir.glob("/sys/bus/pci/devices/#{controller[:pci_slot]}/host*/target0:0:#{id}/0:0:#{id}:0/block/sd*").first
-        disk[:device] = "/dev/#{File.basename(device)}"
-      else
-        disk[:smart_device] = "megaraid,#{id}"
+      if id = disk.delete(:device_id)
+        if device = Dir.glob("/sys/bus/pci/devices/#{controller[:pci_slot]}/host*/target0:0:#{id}/0:0:#{id}:0/block/sd*").first
+          disk[:device] = "/dev/#{File.basename(device)}"
+        else
+          disk[:smart_device] = "megaraid,#{id}"
+        end
       end
     end
   end