Skip to content

Commit b125c38

Browse files
author
Gerard Hickey
committed
Added counting facts to vol module
1 parent 90c990b commit b125c38

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

hanlon_microkernel/facter/hnl_mk_vol.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
lshw_c_volume_str = %x[sudo #{lshw_cmd} -c volume 2> /dev/null]
1818

1919
# process the results from lshw -c volume
20+
vols = 0
2021
lshw_c_volume_str.split(/\s\s\*-/).each do |definition|
2122
unless definition.empty?
2223
lines = definition.split(/\n/)
2324
# section title is on the first line
24-
volume = lines.shift.tr(':', '')
25+
volume = lines.shift.tr(':', '') and vols += 1
26+
2527
# Create a hash of attributes for each section (i.e. cpu)
2628
attribs = Hash[ lines.collect { |l| l =~ /^\s*([^:]+):\s+(.*)\s*$/; v=$2; [$1.gsub(/\s/, '_'), v] } ]
2729
attribs.each_pair do |attrib, val|
@@ -31,3 +33,8 @@
3133
end
3234
end
3335
end
36+
37+
# Report on the number volumes found
38+
Facter.add("mk_hw_volume_count") do
39+
setcode { vols }
40+
end

0 commit comments

Comments
 (0)