]> git.openstreetmap.org Git - chef.git/commitdiff
Handle failed megaraid disks with no ID
authorTom Hughes <tom@compton.nu>
Wed, 10 Aug 2022 21:32:27 +0000 (22:32 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 10 Aug 2022 21:32:27 +0000 (22:32 +0100)
cookbooks/hardware/templates/default/ohai.rb.erb

index 2fca2b323c63f758630abd78a36b48885aea2802..6e6e5f37e200d1f86c50ba95882fcdf126553970 100644 (file)
@@ -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