Add some missing dmi facts when we use dmidecode (#68756)

On OSes where we fall back to dmidecode (freebsd and linux currently),
add some missing fields that dmidecode provides when it is able.

Closes #59317.

Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
Rick Elrod 2020-04-09 00:33:11 -05:00 committed by GitHub
parent 04edd77c42
commit 9b43a57916
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 12 deletions

View file

@ -170,16 +170,26 @@ class FreeBSDHardware(Hardware):
# Fall back to using dmidecode, if available # Fall back to using dmidecode, if available
dmi_bin = self.module.get_bin_path('dmidecode') dmi_bin = self.module.get_bin_path('dmidecode')
DMI_DICT = dict( DMI_DICT = {
bios_date='bios-release-date', 'bios_date': 'bios-release-date',
bios_version='bios-version', 'bios_vendor': 'bios-vendor',
form_factor='chassis-type', 'bios_version': 'bios-version',
product_name='system-product-name', 'board_asset_tag': 'baseboard-asset-tag',
product_serial='system-serial-number', 'board_name': 'baseboard-product-name',
product_uuid='system-uuid', 'board_serial': 'baseboard-serial-number',
product_version='system-version', 'board_vendor': 'baseboard-manufacturer',
system_vendor='system-manufacturer' 'board_version': 'baseboard-version',
) 'chassis_asset_tag': 'chassis-asset-tag',
'chassis_serial': 'chassis-serial-number',
'chassis_vendor': 'chassis-manufacturer',
'chassis_version': 'chassis-version',
'form_factor': 'chassis-type',
'product_name': 'system-product-name',
'product_serial': 'system-serial-number',
'product_uuid': 'system-uuid',
'product_version': 'system-version',
'system_vendor': 'system-manufacturer',
}
for (k, v) in DMI_DICT.items(): for (k, v) in DMI_DICT.items():
if dmi_bin is not None: if dmi_bin is not None:
(rc, out, err) = self.module.run_command('%s -s %s' % (dmi_bin, v)) (rc, out, err) = self.module.run_command('%s -s %s' % (dmi_bin, v))

View file

@ -302,13 +302,23 @@ class LinuxHardware(Hardware):
DMI_DICT = { DMI_DICT = {
'bios_date': '/sys/devices/virtual/dmi/id/bios_date', 'bios_date': '/sys/devices/virtual/dmi/id/bios_date',
'bios_vendor': '/sys/devices/virtual/dmi/id/bios_vendor',
'bios_version': '/sys/devices/virtual/dmi/id/bios_version', 'bios_version': '/sys/devices/virtual/dmi/id/bios_version',
'board_asset_tag': '/sys/devices/virtual/dmi/id/board_asset_tag',
'board_name': '/sys/devices/virtual/dmi/id/board_name',
'board_serial': '/sys/devices/virtual/dmi/id/board_serial',
'board_vendor': '/sys/devices/virtual/dmi/id/board_vendor',
'board_version': '/sys/devices/virtual/dmi/id/board_version',
'chassis_asset_tag': '/sys/devices/virtual/dmi/id/chassis_asset_tag',
'chassis_serial': '/sys/devices/virtual/dmi/id/chassis_serial',
'chassis_vendor': '/sys/devices/virtual/dmi/id/chassis_vendor',
'chassis_version': '/sys/devices/virtual/dmi/id/chassis_version',
'form_factor': '/sys/devices/virtual/dmi/id/chassis_type', 'form_factor': '/sys/devices/virtual/dmi/id/chassis_type',
'product_name': '/sys/devices/virtual/dmi/id/product_name', 'product_name': '/sys/devices/virtual/dmi/id/product_name',
'product_serial': '/sys/devices/virtual/dmi/id/product_serial', 'product_serial': '/sys/devices/virtual/dmi/id/product_serial',
'product_uuid': '/sys/devices/virtual/dmi/id/product_uuid', 'product_uuid': '/sys/devices/virtual/dmi/id/product_uuid',
'product_version': '/sys/devices/virtual/dmi/id/product_version', 'product_version': '/sys/devices/virtual/dmi/id/product_version',
'system_vendor': '/sys/devices/virtual/dmi/id/sys_vendor' 'system_vendor': '/sys/devices/virtual/dmi/id/sys_vendor',
} }
for (key, path) in DMI_DICT.items(): for (key, path) in DMI_DICT.items():
@ -329,13 +339,23 @@ class LinuxHardware(Hardware):
dmi_bin = self.module.get_bin_path('dmidecode') dmi_bin = self.module.get_bin_path('dmidecode')
DMI_DICT = { DMI_DICT = {
'bios_date': 'bios-release-date', 'bios_date': 'bios-release-date',
'bios_vendor': 'bios-vendor',
'bios_version': 'bios-version', 'bios_version': 'bios-version',
'board_asset_tag': 'baseboard-asset-tag',
'board_name': 'baseboard-product-name',
'board_serial': 'baseboard-serial-number',
'board_vendor': 'baseboard-manufacturer',
'board_version': 'baseboard-version',
'chassis_asset_tag': 'chassis-asset-tag',
'chassis_serial': 'chassis-serial-number',
'chassis_vendor': 'chassis-manufacturer',
'chassis_version': 'chassis-version',
'form_factor': 'chassis-type', 'form_factor': 'chassis-type',
'product_name': 'system-product-name', 'product_name': 'system-product-name',
'product_serial': 'system-serial-number', 'product_serial': 'system-serial-number',
'product_uuid': 'system-uuid', 'product_uuid': 'system-uuid',
'product_version': 'system-version', 'product_version': 'system-version',
'system_vendor': 'system-manufacturer' 'system_vendor': 'system-manufacturer',
} }
for (k, v) in DMI_DICT.items(): for (k, v) in DMI_DICT.items():
if dmi_bin is not None: if dmi_bin is not None: