X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/5b06782fb9ac3ba77b39f8c5f2a98590479885c2..7f5c025954a0868b7ac2aea8722089e75c39668e:/cookbooks/hardware/templates/default/ohai.rb.erb?ds=sidebyside diff --git a/cookbooks/hardware/templates/default/ohai.rb.erb b/cookbooks/hardware/templates/default/ohai.rb.erb index 074f5cbf6..c3308eb8c 100644 --- a/cookbooks/hardware/templates/default/ohai.rb.erb +++ b/cookbooks/hardware/templates/default/ohai.rb.erb @@ -287,7 +287,7 @@ Ohai.plugin(:Hardware) do disk = nil IO.popen(%w(ssacli controller all show config detail)).each do |line| - if line =~ /^Smart Array (\S+) / + if line =~ /^Smart (?:Array|HBA) (\S+) / controller = { :id => devices[:controllers].count, :model => Regexp.last_match(1), @@ -303,6 +303,7 @@ Ohai.plugin(:Hardware) do disk = nil elsif controller && line =~ /^ (\S.*):\s+(.*)$/ case Regexp.last_match(1) + when "Slot" then controller[:slot] = Regexp.last_match(2) when "Serial Number" then controller[:serial_number] = Regexp.last_match(2) when "Hardware Revision" then controller[:hardware_version] = Regexp.last_match(2) when "Firmware Version" then controller[:firmware_version] = Regexp.last_match(2) @@ -320,15 +321,12 @@ Ohai.plugin(:Hardware) do controller[:arrays] << array[:id] disk = nil - elsif controller && line =~ /^ physicaldrive (\S+) / - disks << Regexp.last_match(1) elsif array && line =~ /^ physicaldrive (\S+)$/ disk = { :id => devices[:disks].count, :controller => controller[:id], :arrays => [array[:id]], - :location => Regexp.last_match(1), - :smart_device => "cciss,#{disks.find_index(Regexp.last_match(1))}" + :location => Regexp.last_match(1) } devices[:disks] << disk @@ -355,6 +353,14 @@ Ohai.plugin(:Hardware) do end controllers.each do |controller| + slot = controller[:slot] + + IO.popen(%W(ssacli controller slot=#{slot} pd all show status)).each do |line| + if line =~ /^ physicaldrive (\S+) / + disks << Regexp.last_match(1) + end + end + if device = Dir.glob("/sys/bus/pci/devices/#{controller[:pci_slot]}/cciss*").first controller[:device] = File.basename(device).sub(/^cciss(\d+)$/, "/dev/cciss/c\\1d0") elsif device = Dir.glob("/sys/bus/pci/devices/#{controller[:pci_slot]}/host*/target*:3:0/*:3:0:0/scsi_generic/sg*").first @@ -363,6 +369,10 @@ Ohai.plugin(:Hardware) do controller[:device] = "/dev/#{File.basename(device)}" end end + + devices[:disks].each do |disk| + disk[:smart_device] = "cciss,#{disks.find_index(disk[:location])}" + end end def find_megaraid_disks(devices) @@ -444,8 +454,8 @@ Ohai.plugin(:Hardware) do when "Online" then disk[:status] = "online" when "Hotspare" then disk[:status] = "hotspare" when "Failed" then disk[:status] = "failed" - when "Spun Up" then disk[:spun_down] = false - when "Spun down" then disk[:spun_down] = true + 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.*)$/ @@ -766,10 +776,11 @@ Ohai.plugin(:Hardware) do array[:disks].map! do |location| disk = disks.find { |disk| disk[:location] == location } + controller_number = controller[:number] - 1 device_number = disk[:device_number] - device = Dir.glob("#{host}/device/target*:1:#{device_number}/*:1:#{device_number}:0/scsi_generic/*").first disk[:device] = "/dev/#{File.basename(device)}" + disk[:smart_device] = "aacraid,#{controller_number},0,#{device_number}" disk[:arrays] << array[:id] disk[:id]