diff options
author | Tim Smith <tsmith@chef.io> | 2017-04-03 22:24:44 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-04-17 10:37:34 -0700 |
commit | 79b27373ec4a3b4093197a44daa6c5a2bfa1078d (patch) | |
tree | b317388b10042aa9fc48ca6db239b31520a5045f | |
parent | 9eaf02147e5780fdc246ceb67f3c603f6dbd8260 (diff) | |
download | ohai-79b27373ec4a3b4093197a44daa6c5a2bfa1078d.tar.gz |
Provide a more robust mechanism for adding additional IDs
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 <tsmith@chef.io>
-rw-r--r-- | lib/ohai/common/dmi.rb | 14 |
1 files changed, 13 insertions, 1 deletions
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) |