-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a plugin for Windows mimicing the Unix dmi plugin #1445
Conversation
8003525
to
48c6aa1
Compare
@@ -122,7 +122,7 @@ def convenience_keys(dmi) | |||
|
|||
records[:all_records].each do |record| | |||
record.each do |field, value| | |||
next if value.is_a?(Mash) | |||
next unless value.is_a?(String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Windows API returns values other than strings, which seemed to break an expectation of the values coming from the existing dmi plugin. There is a call to value.strip
a few lines down so it seemed like a test for String was more in line with the intent here.
%w{SMBIOSAssetTag smbios_asset_tag eee}, | ||
%w{DeviceID device_id fff}, | ||
%w{L2CacheSize l2_cache_size ggg}, | ||
].freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had this in a tabular format, but chefstyle complained about excessive whitespace. I considered replacing the 3 element array with a Struct or something but thought that was a bit overkill.
@plugin.run | ||
expect(@plugin["system_enclosure"]["serialnumber"]).to eql("1234123412341234") | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After changing the SystemEnclosure plugin to depend on the dmi plugin, I couldn't think of a meaningful way to test this, so I just deleted the test file.
065d46c
to
ae1b449
Compare
wmi_object = wmi.first_of("Win32_SystemEnclosure").wmi_ole_object | ||
system_enclosure[:manufacturer] = wmi_object.invoke("manufacturer") | ||
system_enclosure[:serialnumber] = wmi_object.invoke("serialnumber") | ||
system_enclosure[:manufacturer] = get_attribute(:dmi, :chassis, :manufacturer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should cut an issue in cookstyle to get people using node['system_enclosure']['manufacturer'] onto the DMI equiv in the future. That way we can eventually remove this plugin namespace
lib/ohai/plugins/windows/dmi.rb
Outdated
@@ -0,0 +1,84 @@ | |||
# | |||
# Author:: Pete Higgins (pete@peterhiggins.org) | |||
# Copyright:: Copyright (c) 2020 Kurt Yoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy-paste error 😅
@phiggins can you add these to the convenience_keys filter?
Caption looks like it is always the same as Description. I see one place where Description is useful so we could keep it. https://github.com/chef/ohai/blob/master/lib/ohai/common/dmi.rb#L126 As I mentioned on #1359 (comment), I think we should rename these in system (but not system/all_records): vendor -> manufacturer that way they match linux. |
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
…I plugin. Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
17069a8
to
e40757d
Compare
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
f7e0e73
to
c756955
Compare
I made all the requested changes, the output of the plugin now looks like:
|
Signed-off-by: Pete Higgins pete@peterhiggins.org
Description
Related Issue
#1359
Types of changes
Checklist: