]> git.openstreetmap.org Git - chef.git/commitdiff
Don't do SMART checks on spun down disks
authorTom Hughes <tom@compton.nu>
Wed, 23 Dec 2015 00:35:31 +0000 (00:35 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 23 Dec 2015 00:40:39 +0000 (00:40 +0000)
cookbooks/hardware/recipes/default.rb
cookbooks/hardware/templates/default/ohai.rb.erb

index 0b7b3e6f3f88dfa03f1b656cc4304b3d9f223c17..d929bbf5746f3ae6927bcd05529bb7ded68175b4 100644 (file)
@@ -298,6 +298,8 @@ end
 end
 
 disks = node[:hardware][:disk][:disks].map do |disk|
+  next if disk[:state] == "spun_down"
+
   if disk[:smart_device]
     controller = node[:hardware][:disk][:controllers][disk[:controller]]
     device = controller[:device].sub("/dev/", "")
index 6d5e49fb1314606bbdae987c09b99dec0a3601a3..b2d56c7d86698e2dc8cbd16eb398b3aa0efcab1a 100644 (file)
@@ -434,6 +434,15 @@ Ohai.plugin(:Hardware) do
         devices[:disks] << disk
         controller[:disks] << disk[:id]
         array[:disks] << disk[:id]
+      elsif disk && line =~ /^Firmware state:\s+(.*\S)\s*$/
+        Regexp.last_match(1).split(/,\s*/).each do |state|
+          case state
+          when "Online" then disk[:status] = "online"
+          when "Hotspare" then disk[:status] = "hotspare"
+          when "Spun Up" then disk[:spun_down] = false
+          when "Spun down" then disk[:spun_down] = true
+          end
+        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)}"
@@ -464,10 +473,18 @@ Ohai.plugin(:Hardware) do
 
           devices[:disks] << disk
         end
+      elsif disk && line =~ /^Firmware state:\s+(.*\S)\s*$/
+        Regexp.last_match(1).split(/,\s*/).each do |state|
+          case state
+          when "Online" then disk[:status] = "online"
+          when "Hotspare" then disk[:status] = "hotspare"
+          when "Spun Up" then disk[:state] = "spun_up"
+          when "Spun down" then disk[:state] = "spun_down"
+          end
+        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 "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*\[.*\]$/, ""))
         when "Inquiry Data" then disk[:vendor], disk[:model], disk[:serial_number] = Regexp.last_match(2).split