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

facts: fix SPARC cpu count on linux (#30261)

On sparc64, /proc/cpuinfo has no usual 'model name', 'Processor', 'vendor_id', 'Vendor',
as a result "ansible_processor_vcpus" is always 1.
Add check element "ncpus active" to fix the issue.
This commit is contained in:
Anatoly Pugachev 2017-09-22 21:48:00 +03:00 committed by Adrian Likins
parent e1dcfda172
commit e93ecac0da

View file

@ -193,6 +193,7 @@ class LinuxHardware(Hardware):
# model name is for Intel arch, Processor (mind the uppercase P) # model name is for Intel arch, Processor (mind the uppercase P)
# works for some ARM devices, like the Sheevaplug. # works for some ARM devices, like the Sheevaplug.
# 'ncpus active' is SPARC attribute
if key in ['model name', 'Processor', 'vendor_id', 'cpu', 'Vendor', 'processor']: if key in ['model name', 'Processor', 'vendor_id', 'cpu', 'Vendor', 'processor']:
if 'processor' not in cpu_facts: if 'processor' not in cpu_facts:
cpu_facts['processor'] = [] cpu_facts['processor'] = []
@ -216,6 +217,8 @@ class LinuxHardware(Hardware):
cores[coreid] = int(data[1].strip()) cores[coreid] = int(data[1].strip())
elif key == '# processors': elif key == '# processors':
cpu_facts['processor_cores'] = int(data[1].strip()) cpu_facts['processor_cores'] = int(data[1].strip())
elif key == 'ncpus active':
i = int(data[1].strip())
# Skip for platforms without vendor_id/model_name in cpuinfo (e.g ppc64le) # Skip for platforms without vendor_id/model_name in cpuinfo (e.g ppc64le)
if vendor_id_occurrence > 0: if vendor_id_occurrence > 0: