X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/b7ad0079c7b68733b52d84b5e9f32a68e0f0902b..a4c4a8a5a8cde7f9bf91ae49a9dc1ce23e77293b:/cookbooks/hardware/templates/default/ohai.rb.erb?ds=inline diff --git a/cookbooks/hardware/templates/default/ohai.rb.erb b/cookbooks/hardware/templates/default/ohai.rb.erb index 661a6833d..a2eb0ef96 100644 --- a/cookbooks/hardware/templates/default/ohai.rb.erb +++ b/cookbooks/hardware/templates/default/ohai.rb.erb @@ -331,6 +331,7 @@ Ohai.plugin(:Hardware) do when "Hardware Revision" then controller[:hardware_version] = Regexp.last_match(2) when "Firmware Version" then controller[:firmware_version] = Regexp.last_match(2) when "PCI Address (Domain:Bus:Device.Function)" then controller[:pci_slot] = Regexp.last_match(2) + when "Battery/Capacitor Status" then controller[:battery_status] = Regexp.last_match(2).split.first.downcase end elsif controller && line =~ /^ Logical Drive: (\d+)$/ array = { @@ -403,6 +404,10 @@ Ohai.plugin(:Hardware) do end devices[:disks].each do |disk| + controller = disk[:controller] + + next unless devices[:controllers][controller][:type] == "hp" + disk[:smart_device] = "cciss,#{disks.find_index(disk[:location])}" if disk[:status] == "Failed" @@ -519,7 +524,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 +602,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