Skip to content

Commit

Permalink
Implement basic DMI facts for OpenBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
jasperla authored and bcoca committed Nov 1, 2016
1 parent 309f54b commit 88970bc
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/ansible/module_utils/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,8 @@ class OpenBSDHardware(Hardware):
- processor_cores
- processor_count
- processor_speed
- devices
In addition, it also defines number of DMI facts and device facts.
"""
platform = 'OpenBSD'
DMESG_BOOT = '/var/run/dmesg.boot'
Expand Down Expand Up @@ -1665,6 +1666,25 @@ def get_device_facts(self):
devices.extend(self.sysctl['hw.disknames'].split(','))
self.facts['devices'] = devices

def get_dmi_facts(self):
# We don't use dmidecode(1) here because:
# - it would add dependency on an external package
# - dmidecode(1) can only be ran as root
# So instead we rely on sysctl(8) to provide us the information on a
# best-effort basis. As a bonus we also get facts on non-amd64/i386
# platforms this way.
sysctl_to_dmi = {
'hw.product': 'product_name',
'hw.version': 'product_version',
'hw.uuid': 'product_uuid',
'hw.serialno': 'product_serial',
'hw.vendor': 'system_vendor',
}

for mib in sysctl_to_dmi:
if mib in self.sysctl:
self.facts[sysctl_to_dmi[mib]] = self.sysctl[mib]

class FreeBSDHardware(Hardware):
"""
FreeBSD-specific subclass of Hardware. Defines memory and CPU facts:
Expand Down

0 comments on commit 88970bc

Please sign in to comment.