Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #18 from tjmcs/tb/fix-missing-disks-from-lshw

Fixes issue with missing disks in lshw output (issue #17)
  • Loading branch information...
commit 031e26a61b0844d638ed352617dde4fff4b2aaca 2 parents 0a5d118 + 65d9628
tjmcs authored
Showing with 7 additions and 5 deletions.
  1. +7 −5 razor_microkernel/rz_mk_hardware_facter.rb
View
12 razor_microkernel/rz_mk_hardware_facter.rb
@@ -280,7 +280,7 @@ def lshw_output_to_hash(command_output, delimiter)
prev_array_fieldname = ""
indent_level = -1
array.each { |line|
- name_line = /^(\s+)\*\-([A-Za-z]+)\:?([0-9]*)$/.match(line) ||
+ name_line = /^(\s*)\*\-([A-Za-z]+)(\:?[0-9]*)?$/.match(line) ||
/^(\s+)\*\-([A-Za-z]+)\:?([0-9]*)\s+(DISABLED)$/.match(line) ||
/^(\s+)\*\-([A-Za-z]+)\:?([0-9]*)\s+(UNCLAIMED)$/.match(line)
if name_line && name_line[1].length > prev_indent && name_line[2] != prev_array_fieldname
@@ -294,21 +294,23 @@ def lshw_output_to_hash(command_output, delimiter)
# Hash map or Array, otherwise this line is a value for the previously named element
# of the containing Hash map
if name_line
+ key_name = name_line[2]
+ key_name = key_name[1..-1] if key_name.start_with?(':')
# if the third element is non-nil, then this represents one element of an array of
# maps that should be used for this property; else we're just looking at the name
# of a map of name/value pairs for this property (the exception to this is the
# "network" output, which is always an array but never includes numbers, so we'll
# just force it to be an array)
- if name_line[3].length > 0 || name_line[2] == "network"
- key = name_line[2] + "_array"
+ if name_line[3].length > 0 || key_name == "network" || key_name == "disk"
+ key = key_name + "_array"
parse_array << { :indent_level => indent_level, :type => "map_array",
:name => key, :is_enabled => (name_line[4] != "DISABLED"),
:unclaimed => (name_line[4] != "UNCLAIMED") }
else
- key = name_line[2]
+ key = key_name
parse_array << { :indent_level => indent_level, :type => "map", :name => key }
end
- prev_array_fieldname = name_line[2]
+ prev_array_fieldname = key_name
else
# it's a value, so parse it using the delimiter that was passed in as an argument
# to the function (above) and save the result in the parse_array...first, parse the
Please sign in to comment.
Something went wrong with that request. Please try again.