@@ -112,26 +112,29 @@ def def_to_hash(definition, delimiter=':')
112
112
# process the results from lshw -c memory
113
113
memory = def_to_hash ( lshw_c_memory_str )
114
114
115
- # Create the facts for the firmware info
116
- %w{ description vendor physical_id version date size capabilities capacity } . each do |fact |
117
- Facter . add ( "mk_hw_fw_#{ fact } " ) do
118
- setcode { memory [ 'firmware' ] [ fact ] }
115
+ begin
116
+ # Create the facts for the firmware info
117
+ %w{ description vendor physical_id version date size capabilities capacity } . each do |fact |
118
+ Facter . add ( "mk_hw_fw_#{ fact } " ) do
119
+ setcode { memory [ 'firmware' ] [ fact ] }
120
+ end
119
121
end
120
- end
121
122
122
- # Create the facts for the memory info
123
- %w{ description physical_id slot size } . each do |fact |
124
- Facter . add ( "mk_hw_mem_#{ fact } " ) do
125
- setcode { memory [ 'memory' ] [ fact ] }
123
+ # Create the facts for the memory info
124
+ %w{ description physical_id slot size } . each do |fact |
125
+ Facter . add ( "mk_hw_mem_#{ fact } " ) do
126
+ setcode { memory [ 'memory' ] [ fact ] }
127
+ end
126
128
end
127
- end
128
129
129
- slot_info = memory [ 'memory' ] [ 'bank_array' ] . select { |entry | entry [ 'size' ] }
130
- Facter . add ( "mk_hw_mem_slot_info" ) do
131
- setcode { slot_info }
130
+ slot_info = memory [ 'memory' ] [ 'bank_array' ] . select { |entry | entry [ 'size' ] }
131
+ Facter . add ( "mk_hw_mem_slot_info" ) do
132
+ setcode { slot_info }
133
+ end
134
+ rescue Exception => e
135
+ puts "Exception: #{ e } "
132
136
end
133
137
134
-
135
138
# # next, the memory information (including firmware, system memory, and caches)
136
139
# lshw_c_memory_str = %x[sudo #{lshw_cmd} -c memory 2> /dev/null]
137
140
# hash_map = lshw_output_to_hash(lshw_c_memory_str, ":")
0 commit comments