Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes logical drive mapping #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions lib/einarc/adaptec_arcconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def _logical_list
ld = @logical[num] = {
:num => num,
:physical => [],
:serial_list => [],
}
when /Size\s*:\s*(\d+) MB/
ld[:capacity] = $1.to_i
Expand All @@ -171,8 +172,8 @@ def _logical_list
when 'Simple_volume', 'Spanned_volume' then 'linear'
else ld[:raid_level]
end
when /Segment (\d+)\s*:\s*(.*?) \((\d+),(\d+)\)/
ld[:physical] << "#{$3}:#{$4}"
when /Segment (\d+)\s*:\s*(.*?) \((.+)\)\s*(.+)/
ld[:serial_list] << $4
when /Dedicated Hot-Spare\s*:\s*(\d+),(\d+)/
ld[:physical] << "#{$1}:#{$2}"
when /Status of logical device\s+:\s(.+)$/
Expand All @@ -189,9 +190,41 @@ def _logical_list
ld[:dev] = find_dev_by_name($1.strip)
end
}
# Get serial_to_physical mapping and update ld[:physical] list accordingly
@serial_to_physical = _serial_to_physical
@logical.each { |ld|
ld[:serial_list].each { |sn|
ld[:physical] << @serial_to_physical[sn]
}
}
return @logical
end

def _serial_to_physical
@serial_to_physical = {}
hdd = nil
serial = nil
physical = nil
run("getconfig #{@adapter_num} pd").each { |l|
case l
when /Device #(\d+)/
hdd = false
serial = false
physical = false
when /Device is a Hard drive/
hdd = true
when /Reported Channel,Device\(T:L\)\s*:\s*(\d+),(\d+).*/
physical = "#{$1}:#{$2}" if hdd
@serial_to_physical[serial] = physical if serial
when /Serial number\s*:\s*(.*)$/
serial = $1
@serial_to_physical[serial] = physical if physical
end
}
return @serial_to_physical
end


def logical_add(raid_level, discs = nil, sizes = nil, options = nil)
# Normalize arguments: make "discs" and "sizes" an array, "raid_level" a string
if discs
Expand Down Expand Up @@ -341,6 +374,7 @@ def _physical_list
_logical_list.each_with_index { |l, i|
next unless l
l[:physical].each { |pd|
next unless @physical.has_key?(pd)
next if %w{ failed }.include?(@physical[pd][:state])
next if @physical[pd][:state] == "hotspare"
if @physical[pd][:state].is_a?(Array)
Expand Down