From: Tom Hughes Date: Wed, 10 Aug 2022 21:32:27 +0000 (+0100) Subject: Handle failed megaraid disks with no ID X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/cb2c78c1445e99170521c1280d94c2b44f2220b7?ds=sidebyside;hp=393651c3dd76ebd8454b71f14ee49d399f0692f6 Handle failed megaraid disks with no ID --- diff --git a/cookbooks/hardware/templates/default/ohai.rb.erb b/cookbooks/hardware/templates/default/ohai.rb.erb index 2fca2b323..6e6e5f37e 100644 --- a/cookbooks/hardware/templates/default/ohai.rb.erb +++ b/cookbooks/hardware/templates/default/ohai.rb.erb @@ -597,12 +597,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