]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/templates/default/ohai.rb.erb
Recognise some extra disk statuses on HP controllers
[chef.git] / cookbooks / hardware / templates / default / ohai.rb.erb
index 5f1cee9d79d7fdd811015407528bfe16c36a5644..f6b854c99356054c76bb952ca8befc0d615b9325 100644 (file)
@@ -317,6 +317,8 @@ Ohai.plugin(:Hardware) do
     disk = nil
 
     IO.popen(%w(ssacli controller all show config detail)).each do |line|
+      next unless line.valid_encoding?
+
       if line =~ /^Smart (?:Array|HBA) (\S+) /
         controller = {
           :id => devices[:controllers].count,
@@ -377,6 +379,7 @@ Ohai.plugin(:Hardware) do
       elsif array && line =~ /^         Status:\s+(.*\S)\s*$/
         case Regexp.last_match(1)
         when "OK" then array[:status] = "optimal"
+        when "Interim Recovery Mode" then array[:status] = "degraded"
         else array[:status] = "unknown"
         end
       elsif array && line =~ /^         (\S[^:]+):\s+(.*\S)\s*$/
@@ -414,10 +417,14 @@ Ohai.plugin(:Hardware) do
 
       if disk[:status] == "Failed"
         disk[:status] = "failed"
+      elsif disk[:status] == "Predictive Failure"
+        disk[:status] = "failed"
       elsif disk[:status] == "OK" && disk[:drive_type] == "Data Drive"
         disk[:status] = "online"
       elsif disk[:status] == "OK" && disk[:drive_type] == "Spare Drive"
         disk[:status] = "hotspare"
+      elsif disk[:status] == "OK" && disk[:drive_type] == "Unassigned Drive"
+        disk[:status] = "unconfigured"
       else
         disk[:status] = "unknown"
       end
@@ -446,11 +453,11 @@ Ohai.plugin(:Hardware) do
         devices[:controllers] << controller
 
         controllers << controller
-      elsif line =~ /^Bus Number\s+:\s+(\d+)$/
+      elsif line =~ /^Bus Number\s+:\s+([0-9a-f]+)$/i
         controller[:pci_slot] = format "0000:%02x", Integer("0x#{Regexp.last_match(1)}")
-      elsif line =~ /^Device Number\s+:\s+(\d+)$/
+      elsif line =~ /^Device Number\s+:\s+([0-9a-f]+)$/i
         controller[:pci_slot] = format "%s:%02x", controller[:pci_slot], Integer("0x#{Regexp.last_match(1)}")
-      elsif line =~ /^Function Number\s+:\s+(\d+)$/
+      elsif line =~ /^Function Number\s+:\s+([0-9a-f]+)$/i
         controller[:pci_slot] = format "%s.%01x", controller[:pci_slot], Integer("0x#{Regexp.last_match(1)}")
       end
     end