Skip to content
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

Merged
merged 18 commits into from
Apr 17, 2020
Merged

Conversation

phiggins
Copy link
Contributor

@phiggins phiggins commented Apr 4, 2020

Signed-off-by: Pete Higgins pete@peterhiggins.org

Description

Related Issue

#1359

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@phiggins phiggins force-pushed the expand-windows-dmi branch 3 times, most recently from 8003525 to 48c6aa1 Compare April 10, 2020 23:27
@phiggins phiggins changed the title WIP: expand windows dmi. Add a plugin for Windows mimicing the Unix dmi plugin Apr 10, 2020
@@ -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)
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@phiggins phiggins force-pushed the expand-windows-dmi branch 2 times, most recently from 065d46c to ae1b449 Compare April 15, 2020 19:35
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)
Copy link
Contributor

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

@@ -0,0 +1,84 @@
#
# Author:: Pete Higgins (pete@peterhiggins.org)
# Copyright:: Copyright (c) 2020 Kurt Yoder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-paste error 😅

@btm
Copy link
Contributor

btm commented Apr 15, 2020

@phiggins can you add these to the convenience_keys filter?

  • Caption
  • CreationClassName
  • SystemCreationClassName

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
identifying_number -> serial_number
name -> family

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>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
@phiggins
Copy link
Contributor Author

I made all the requested changes, the output of the plugin now looks like:

{
  "dmi": {
    "chassis": {
      "all_records": [
        {
          "AudibleAlarm": null,
          "BreachDescription": null,
          "CableManagementStrategy": null,
          "Caption": "System Enclosure",
          "ChassisTypes": [
            1
          ],
          "CreationClassName": "Win32_SystemEnclosure",
          "CurrentRequiredOrProduced": null,
          "Depth": null,
          "Description": "System Enclosure",
          "HeatGeneration": null,
          "Height": null,
          "HotSwappable": null,
          "InstallDate": null,
          "LockPresent": false,
          "Manufacturer": "Oracle Corporation",
          "Model": null,
          "Name": "System Enclosure",
          "NumberOfPowerCords": null,
          "OtherIdentifyingInfo": null,
          "PartNumber": null,
          "PoweredOn": null,
          "Removable": null,
          "Replaceable": null,
          "SecurityBreach": null,
          "SecurityStatus": 3,
          "SerialNumber": "",
          "ServiceDescriptions": null,
          "ServicePhilosophy": null,
          "SKU": null,
          "SMBIOSAssetTag": "",
          "Status": null,
          "Tag": "System Enclosure 0",
          "TypeDescriptions": null,
          "Version": "",
          "VisibleAlarm": null,
          "Weight": null,
          "Width": null
        }
      ],
      "description": "System Enclosure",
      "manufacturer": "Oracle Corporation",
      "serial_number": "",
      "smbios_asset_tag": "",
      "tag": "System Enclosure 0",
      "version": "",
      "family": "System Enclosure"
    },
    "processor": {
      "all_records": [
        {
          "AddressWidth": 64,
          "Architecture": 9,
          "AssetTag": null,
          "Availability": 3,
          "Caption": "Intel64 Family 6 Model 70 Stepping 1",
          "Characteristics": null,
          "ConfigManagerErrorCode": null,
          "ConfigManagerUserConfig": null,
          "CpuStatus": 0,
          "CreationClassName": "Win32_Processor",
          "CurrentClockSpeed": 2794,
          "CurrentVoltage": null,
          "DataWidth": 64,
          "Description": "Intel64 Family 6 Model 70 Stepping 1",
          "DeviceID": "CPU0",
          "ErrorCleared": null,
          "ErrorDescription": null,
          "ExtClock": null,
          "Family": 2,
          "InstallDate": null,
          "L2CacheSize": null,
          "L2CacheSpeed": null,
          "L3CacheSize": 0,
          "L3CacheSpeed": 0,
          "LastErrorCode": null,
          "Level": 6,
          "LoadPercentage": 0,
          "Manufacturer": "GenuineIntel",
          "MaxClockSpeed": 2794,
          "Name": "Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz",
          "NumberOfCores": 2,
          "NumberOfEnabledCore": null,
          "NumberOfLogicalProcessors": 2,
          "OtherFamilyDescription": null,
          "PartNumber": null,
          "PNPDeviceID": null,
          "PowerManagementCapabilities": null,
          "PowerManagementSupported": false,
          "ProcessorId": null,
          "ProcessorType": null,
          "Revision": 17921,
          "Role": "CPU",
          "SecondLevelAddressTranslationExtensions": false,
          "SerialNumber": null,
          "SocketDesignation": null,
          "Status": "OK",
          "StatusInfo": 3,
          "Stepping": null,
          "SystemCreationClassName": "Win32_ComputerSystem",
          "SystemName": "VAGRANT-36IHG0U",
          "ThreadCount": null,
          "UniqueId": null,
          "UpgradeMethod": 2,
          "Version": "",
          "VirtualizationFirmwareEnabled": false,
          "VMMonitorModeExtensions": false,
          "VoltageCaps": null
        }
      ],
      "description": "Intel64 Family 6 Model 70 Stepping 1",
      "device_id": "CPU0",
      "manufacturer": "GenuineIntel",
      "role": "CPU",
      "status": "OK",
      "system_name": "VAGRANT-36IHG0U",
      "version": "",
      "family": "Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz"
    },
    "bios": {
      "all_records": [
        {
          "BiosCharacteristics": [
            4,
            7,
            15,
            16,
            27,
            30,
            32
          ],
          "BIOSVersion": [
            "VBOX   - 1"
          ],
          "BuildNumber": null,
          "Caption": "Default System BIOS",
          "CodeSet": null,
          "CurrentLanguage": null,
          "Description": "Default System BIOS",
          "EmbeddedControllerMajorVersion": 110,
          "EmbeddedControllerMinorVersion": 111,
          "IdentificationCode": null,
          "InstallableLanguages": null,
          "InstallDate": null,
          "LanguageEdition": null,
          "ListOfLanguages": null,
          "Manufacturer": "innotek GmbH",
          "Name": "Default System BIOS",
          "OtherTargetOS": null,
          "PrimaryBIOS": true,
          "ReleaseDate": "20061201000000.000000+000",
          "SerialNumber": "0",
          "SMBIOSBIOSVersion": "VirtualBox",
          "SMBIOSMajorVersion": 2,
          "SMBIOSMinorVersion": 5,
          "SMBIOSPresent": true,
          "SoftwareElementID": "Default System BIOS",
          "SoftwareElementState": 3,
          "Status": "OK",
          "SystemBiosMajorVersion": 105,
          "SystemBiosMinorVersion": 110,
          "TargetOperatingSystem": 0,
          "Version": "VBOX   - 1"
        }
      ],
      "description": "Default System BIOS",
      "manufacturer": "innotek GmbH",
      "release_date": "20061201000000.000000+000",
      "serial_number": "0",
      "smbiosbios_version": "VirtualBox",
      "software_element_id": "Default System BIOS",
      "status": "OK",
      "version": "VBOX   - 1",
      "family": "Default System BIOS"
    },
    "system": {
      "all_records": [
        {
          "Caption": "Computer System Product",
          "Description": "Computer System Product",
          "IdentifyingNumber": "0",
          "Name": "VirtualBox",
          "SKUNumber": null,
          "UUID": "DBF47626-9602-4396-B121-94A6DEB3A06D",
          "Vendor": "innotek GmbH",
          "Version": "1.2"
        }
      ],
      "description": "Computer System Product",
      "uuid": "DBF47626-9602-4396-B121-94A6DEB3A06D",
      "version": "1.2",
      "manufacturer": "innotek GmbH",
      "serial_number": "0",
      "family": "VirtualBox"
    },
    "base_board": {
      "all_records": [
        {
          "Caption": "Base Board",
          "ConfigOptions": null,
          "CreationClassName": "Win32_BaseBoard",
          "Depth": null,
          "Description": "Base Board",
          "Height": null,
          "HostingBoard": true,
          "HotSwappable": false,
          "InstallDate": null,
          "Manufacturer": "Oracle Corporation",
          "Model": null,
          "Name": "Base Board",
          "OtherIdentifyingInfo": null,
          "PartNumber": null,
          "PoweredOn": true,
          "Product": "VirtualBox",
          "Removable": false,
          "Replaceable": false,
          "RequirementsDescription": null,
          "RequiresDaughterBoard": false,
          "SerialNumber": "0",
          "SKU": null,
          "SlotLayout": null,
          "SpecialRequirements": null,
          "Status": "OK",
          "Tag": "Base Board",
          "Version": "1.2",
          "Weight": null,
          "Width": null
        }
      ],
      "description": "Base Board",
      "manufacturer": "Oracle Corporation",
      "product": "VirtualBox",
      "serial_number": "0",
      "status": "OK",
      "tag": "Base Board",
      "version": "1.2",
      "family": "Base Board"
    }
  }
}

@tas50 tas50 merged commit a505760 into master Apr 17, 2020
@chef-expeditor chef-expeditor bot deleted the expand-windows-dmi branch April 17, 2020 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants