]> git.openstreetmap.org Git - chef.git/commitdiff
Locate block devices for megaraid arrays
authorTom Hughes <tom@compton.nu>
Mon, 30 Nov 2015 11:57:36 +0000 (11:57 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 30 Nov 2015 11:57:36 +0000 (11:57 +0000)
cookbooks/hardware/templates/default/ohai.rb.erb

index e78e0c6bc5ad1bc83c2a5c7c31ced24c7c03d196..b371d381670ef1848d97e66bf6da8a344ad91be6 100644 (file)
@@ -305,10 +305,15 @@ Ohai.plugin(:Hardware) do
       if line =~ /^Adapter #(\d+)$/
         controller = controllers[Regexp.last_match(1).to_i]
       elsif controller && line =~ /^Virtual Drive: (\d+) \(Target Id: (\d+)\)$/
       if line =~ /^Adapter #(\d+)$/
         controller = controllers[Regexp.last_match(1).to_i]
       elsif controller && line =~ /^Virtual Drive: (\d+) \(Target Id: (\d+)\)$/
+        pci_slot = controller[:pci_slot]
+        target = Regexp.last_match(2)
+        device = Dir.glob("/sys/bus/pci/devices/#{pci_slot}/host*/target*:2:#{target}/*:2:#{target}:0/block/*").first
+
         array = {
           :id => devices[:arrays].count,
           :controller => controller[:id],
           :number => Regexp.last_match(1),
         array = {
           :id => devices[:arrays].count,
           :controller => controller[:id],
           :number => Regexp.last_match(1),
+          :device => "/dev/#{File.basename(device)}",
           :disks => []
         }
 
           :disks => []
         }