From 2649213865c987de9551ba620c6031b306e63606 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 30 Nov 2015 17:10:34 +0000 Subject: [PATCH] Determine device names for Areca logical volumes --- .../hardware/templates/default/ohai.rb.erb | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cookbooks/hardware/templates/default/ohai.rb.erb b/cookbooks/hardware/templates/default/ohai.rb.erb index 74c23f731..1b08dbfc6 100644 --- a/cookbooks/hardware/templates/default/ohai.rb.erb +++ b/cookbooks/hardware/templates/default/ohai.rb.erb @@ -534,13 +534,22 @@ Ohai.plugin(:Hardware) do arrays.each do |array| IO.popen(["/opt/areca/x86_64/cli64", "vsf", "info", "vol=#{array[:number]}"]).each do |line| - next unless line =~ /^(\S.*\S)\s+:\s+(.*\S)\s*$/ + if line =~ /^SCSI Ch\/Id\/Lun\s+:\s+(\d+)\/(\d+)\/(\d+)\s*$/ + pci_slot = controller[:pci_slot] + channel = Regexp.last_match(1).to_i + id = Regexp.last_match(2).to_i + lun = Regexp.last_match(3).to_i - case Regexp.last_match(1) - when "Volume Set Name" then array[:volume_set] = Regexp.last_match(2) - when "Raid Set Name" then array[:raid_set] = Regexp.last_match(2) - when "Volume Capacity" then array[:size] = format_disk_size(Regexp.last_match(2).to_f * 1000 * 1000) - when "Raid Level" then array[:raid_level] = Regexp.last_match(2).sub(/^Raid/, "") + device = Dir.glob("/sys/bus/pci/devices/#{pci_slot}/host*/target*:0:0/0:#{channel}:#{id}:#{lun}/block/*").first + + array[:device] = "/dev/#{File.basename(device)}" + elsif line =~ /^(\S.*\S)\s+:\s+(.*\S)\s*$/ + case Regexp.last_match(1) + when "Volume Set Name" then array[:volume_set] = Regexp.last_match(2) + when "Raid Set Name" then array[:raid_set] = Regexp.last_match(2) + when "Volume Capacity" then array[:size] = format_disk_size(Regexp.last_match(2).to_f * 1000 * 1000) + when "Raid Level" then array[:raid_level] = Regexp.last_match(2).sub(/^Raid/, "") + end end end end -- 2.43.2