From 79b27373ec4a3b4093197a44daa6c5a2bfa1078d Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 3 Apr 2017 22:24:44 -0700 Subject: Provide a more robust mechanism for adding additional IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to allow the user to add not only additional IDs, but the value for that ID. If we don’t have a description name it shows up as “unknown” Signed-off-by: Tim Smith --- lib/ohai/common/dmi.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ohai/common/dmi.rb b/lib/ohai/common/dmi.rb index f1450619..febb74d4 100644 --- a/lib/ohai/common/dmi.rb +++ b/lib/ohai/common/dmi.rb @@ -74,7 +74,19 @@ module Ohai # list of IDs to collect from config or default to a sane list that prunes # away some of the less useful IDs - ID_TO_CAPTURE = Ohai.config[:plugin][:dmi][:ids] || [ 0, 1, 2, 3, 4, 6, 11 ] + ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ] + + # add additional config defined IDs from the config hash + if Ohai.config[:additional_dmi_ids] + if Ohai.config[:additional_dmi_ids].is_a?(Hash) + Ohai.config[:additional_dmi_ids].each_pair do |id,desc| + ID_TO_CAPTURE << id + ID_TO_DESCRIPTION[id] = desc + end + else + Ohai::Log.debug("The DMI additional_ids config must be a hash of IDs and their description.") + end + end # look up DMI ID def id_lookup(id) -- cgit v1.2.1