Correctly count processors on ARM systems. (#52884)

- Add unit tests for Linux CPU info
- Add cpuinfo output from several systems for unit tests

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Sam Doran 2019-03-14 10:31:47 -04:00 committed by GitHub
commit 55306906cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 951 additions and 0 deletions

View file

@ -159,6 +159,7 @@ class LinuxHardware(Hardware):
i = 0
vendor_id_occurrence = 0
model_name_occurrence = 0
processor_occurence = 0
physid = 0
coreid = 0
sockets = {}
@ -206,6 +207,8 @@ class LinuxHardware(Hardware):
vendor_id_occurrence += 1
if key == 'model name':
model_name_occurrence += 1
if key == 'processor':
processor_occurence += 1
i += 1
elif key == 'physical id':
physid = data[1].strip()
@ -229,6 +232,12 @@ class LinuxHardware(Hardware):
if vendor_id_occurrence == model_name_occurrence:
i = vendor_id_occurrence
# The fields for ARM CPUs do not always include 'vendor_id' or 'model name',
# and sometimes includes both 'processor' and 'Processor'.
# Always use 'processor' count for ARM systems
if collected_facts.get('ansible_architecture').startswith(('armv', 'aarch')):
i = processor_occurence
# FIXME
if collected_facts.get('ansible_architecture') != 's390x':
if xen_paravirt: