1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Rework how OpenBSD processor facts are resolved

This commit is contained in:
Jasper Lievisse Adriaanse 2016-11-01 10:29:07 +01:00 committed by Toshio Kuratomi
parent 2131eaba0c
commit c17dad0def

View file

@ -1594,7 +1594,6 @@ class OpenBSDHardware(Hardware):
In addition, it also defines number of DMI facts and device facts.
"""
platform = 'OpenBSD'
DMESG_BOOT = '/var/run/dmesg.boot'
def populate(self):
self.sysctl = self.get_sysctl()
@ -1652,19 +1651,19 @@ class OpenBSDHardware(Hardware):
def get_processor_facts(self):
processor = []
dmesg_boot = get_file_content(OpenBSDHardware.DMESG_BOOT)
if not dmesg_boot:
rc, dmesg_boot, err = self.module.run_command("/sbin/dmesg")
i = 0
for line in dmesg_boot.splitlines():
if line.split(' ', 1)[0] == 'cpu%i:' % i:
processor.append(line.split(' ', 1)[1])
i = i + 1
processor_count = i
for i in range(int(self.sysctl['hw.ncpu'])):
processor.append(self.sysctl['hw.model'])
self.facts['processor'] = processor
self.facts['processor_count'] = processor_count
# I found no way to figure out the number of Cores per CPU in OpenBSD
self.facts['processor_cores'] = 'NA'
# The following is partly a lie because there is no reliable way to
# determine the number of physical CPUs in the system. We can only
# query the number of logical CPUs, which hides the number of cores.
# On amd64/i386 we could try to inspect the smt/core/package lines in
# dmesg, however even those have proven to be unreliable.
# So take a shortcut and report the logical number of processors in
# 'processor_count' and 'processor_cores' and leave it at that.
self.facts['processor_count'] = self.sysctl['hw.ncpu']
self.facts['processor_cores'] = self.sysctl['hw.ncpu']
def get_device_facts(self):
devices = []