Closed MikeLingenfelter closed 4 years ago
The 'manufacturer' and 'serialnumber' values under 'system_enclosure' from Ohai are collected directly from WMI. Whatever data Ohai returns is what the operating system and hardware are returning.
On my Windows 10 VM under Virtual Box on Linux, no serial number is returned from the system either. You can test this with these commands on Windows:
wmic systemenclosure get serialnumber
wmic systemenclosure get manufacturer
I don't believe VMWare populates that data.You could also try wmic bios get serialnumber
and let us know if that reutrns the data you're looking for. I don't believe ohai collects the BIOS data.
Sorry for the delay, your message got lost in my email.
You are correct, those "wmic systemenclosure" commands do return "blank" informaiton, on Windows VMware systems. On our systems I used the following WMI objects to the the informaiton.
gwmi Win32_ComputerSystem | Select Manufacturer | Ft; gwmi Win32_Bios | Select SerialNumber
According to this: https://kb.vmware.com/s/article/1023616
The serial number of a machine is stored in WMI. The location in WMI can vary depending on the hardware manufacturer, but it is generally in one of these classes: Win32_BaseBoard, Win32_BIOS, or Win32_SystemEnclosure.
Windows does not present a consistent location in WMI for the enclosure serial number. The ohai code will need to search all of these classes.
We should collect these and stuff them into the matching dmi
tree for linux.
Here are the 5 sections of node['dmi'] that are returned on my Ubuntu workstation, and what I believe are the Win32 equivalents.
chassis: https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-systemenclosure processor: https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-processor bios: https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-bios system: https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystemproduct base_board: https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-baseboard
I think these are the equivalents.
Note the first one is what is in the system_enclosure plugin today. We can copy that pattern into the dmi plugin and use it to pull all of the sections. The system_enclosure plugin should then be set for future deprecation.
For the values we already gather via the system_enclosure we can depend on that plugin in the DMI plugin and utlize the data we've already collected so we don't have to gather data twice. That'll be useful on windows where those wmi calls are pretty slow.
I started out trying to figure out what information was present in the Ubuntu output and mapping the equivalent Windows data to it, but I wasn't sure that was the right approach, or if we just wanted everything. This was complicated by the fact that I'm using an Ubuntu vm through vagrant and it doesn't seem to return everything that you listed above. So I took a different approach and I'm grabbing all of the information returned. Is this what we want to do? If not, what specific information should I be getting from each of these things?
The WIP PR I opened is here: https://github.com/chef/ohai/pull/1445
Obviously the code is in a rough state, but I thought it would be better to show what I mean with an example.
@phiggins that looks like an acceptable amount of data to consume.
1) it's pretty important we figure out how to match the snake case from linux. right now I can't poke myself, but I hope we can find a source that allows conversion without mapping.
The real goal here is to have node['dmi']['system']['serial_number']
return the same data on Windows and Linux.
2) the "all_records" I don't know what to do with. I think we originally only took the top level keys and skipped a couple records. We might be able to use Ohai::Common::DMI.convenience_keys
to duplicate the behavior outside of "all_records".
https://github.com/chef/ohai/blob/master/lib/ohai/common/dmi.rb#L117
it's pretty important we figure out how to match the snake case from linux.
There's code in ohai that explicitly downcases all the keys, so if it's coming from the windows APIs as camelcase it can probably be converted in a straightforward way.
There is still no node['dmi']['system']['serial_number']
so I'll need to figure something out.
@phiggins I looked again and couldn't find a closer match of a WMI class for 'system' than Win32computerSystemProduct.
Here is "system" on my windows 10 system using your branch.
"system": {
"all_records": [
{
"Caption": "Computer System Product",
"Description": "Computer System Product",
"IdentifyingNumber": "87GBNY1",
"Name": "Inspiron 660",
"SKUNumber": null,
"UUID": "4C4C4544-0037-4710-8042-B8C04F4E5931",
"Vendor": "Dell Inc.",
"Version": " "
}
],
"caption": "Computer System Product",
"description": "Computer System Product",
"identifying_number": "87GBNY1",
"name": "Inspiron 660",
"uuid": "4C4C4544-0037-4710-8042-B8C04F4E5931",
"vendor": "Dell Inc.",
"version": ""
},
If that is the closest match, perhaps we leave the data as is under "all_records" but rename:
vendor -> manufacturer identifying_number -> serial_number name -> family
leave version and uuid as they are.
I would filter caption, creation_class_name, and description out of the records outside of "all_records". That information seems duplicative.
I'm comparing my linux laptop to my windows desktop, but comparing the same data on a dual-boot system would be ideal if someone had it handy.
I'm comparing my linux laptop to my windows desktop, but comparing the same data on a dual-boot system would be ideal if someone had it handy.
I don't have any machines with linux and windows on them currently, but I could get that going sometime in the next few days if no one beats me to it.
WOOT! Fixed in #1445.
btm_000@btm-desktop MINGW64 ~/src/ohai (master)
$ bin/ohai dmi/system/serial_number
[
"87GBNY1"
]
@MikeLingenfelter in Chef 16 now you should be able to find what you are looking for in one of these places, depending where VMware is putting them. -- dmi/system/serial_number -- dmi/chassis/serial_number -- dmi/bios/serial_number
-- dmi/system/manufacturer -- dmi/chassis/manufacturer -- dmi/bios/manufacturer
Description
For Windows VMware VMs, the manufacture and serialnumber are not being discovered. We are only seeing this on Widnows VMware VMs. For Linux systems, HyperV VMs and HP physical servers, are seeing the discovered manufacture and serialnumber values. For VMware VMs we are seeing.
system_enclosure manufacturer: No Enclosure serialnumber: None
Ohai Version
15.0.4
Platform Version
Windows 2008 R2, 2012R2 and 2016
Ohai Output