Add get_dmi_facts in setup for FreeBSD systems using dmidecode
This commit is contained in:
parent
5413ee9431
commit
34ff7e00a9
1 changed files with 36 additions and 0 deletions
36
system/setup
36
system/setup
|
@ -943,6 +943,7 @@ class FreeBSDHardware(Hardware):
|
|||
def populate(self):
|
||||
self.get_cpu_facts()
|
||||
self.get_memory_facts()
|
||||
self.get_dmi_facts()
|
||||
self.get_device_facts()
|
||||
self.get_mount_facts()
|
||||
return self.facts
|
||||
|
@ -1012,6 +1013,41 @@ class FreeBSDHardware(Hardware):
|
|||
if s:
|
||||
self.facts['devices'][d.group(1)].append(s.group(1))
|
||||
|
||||
def get_dmi_facts(self):
|
||||
''' learn dmi facts from system
|
||||
|
||||
Use dmidecode executable if available'''
|
||||
|
||||
# Fall back to using dmidecode, if available
|
||||
dmi_bin = module.get_bin_path('dmidecode')
|
||||
DMI_DICT = {
|
||||
'bios_date': 'bios-release-date',
|
||||
'bios_version': 'bios-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():
|
||||
if dmi_bin is not None:
|
||||
(rc, out, err) = module.run_command('%s -s %s' % (dmi_bin, v))
|
||||
if rc == 0:
|
||||
# Strip out commented lines (specific dmidecode output)
|
||||
thisvalue = ''.join([ line for line in out.split('\n') if not line.startswith('#') ])
|
||||
try:
|
||||
json.dumps(thisvalue)
|
||||
except UnicodeDecodeError:
|
||||
thisvalue = "NA"
|
||||
|
||||
self.facts[k] = thisvalue
|
||||
else:
|
||||
self.facts[k] = 'NA'
|
||||
else:
|
||||
self.facts[k] = 'NA'
|
||||
|
||||
|
||||
class NetBSDHardware(Hardware):
|
||||
"""
|
||||
NetBSD-specific subclass of Hardware. Defines memory and CPU facts:
|
||||
|
|
Loading…
Reference in a new issue