diff --git a/lib/ansible/module_utils/facts/hardware/linux.py b/lib/ansible/module_utils/facts/hardware/linux.py index 192f757def0..e8d8cd2519b 100644 --- a/lib/ansible/module_utils/facts/hardware/linux.py +++ b/lib/ansible/module_utils/facts/hardware/linux.py @@ -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: diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/aarch64-4cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/aarch64-4cpu-cpuinfo new file mode 100644 index 00000000000..c3caa01ccdf --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/aarch64-4cpu-cpuinfo @@ -0,0 +1,40 @@ +processor : 0 +Processor : AArch64 Processor rev 4 (aarch64) +Hardware : sun50iw1p1 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 1 +Processor : AArch64 Processor rev 4 (aarch64) +Hardware : sun50iw1p1 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 2 +Processor : AArch64 Processor rev 4 (aarch64) +Hardware : sun50iw1p1 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 3 +Processor : AArch64 Processor rev 4 (aarch64) +Hardware : sun50iw1p1 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/arm64-4cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/arm64-4cpu-cpuinfo new file mode 100644 index 00000000000..38fd06e7d49 --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/arm64-4cpu-cpuinfo @@ -0,0 +1,32 @@ +processor : 0 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 1 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 2 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 3 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/armv6-rev7-1cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/armv6-rev7-1cpu-cpuinfo new file mode 100644 index 00000000000..84ee16c9091 --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/armv6-rev7-1cpu-cpuinfo @@ -0,0 +1,12 @@ +processor : 0 +model name : ARMv6-compatible processor rev 7 (v6l) +BogoMIPS : 697.95 +Features : half thumb fastmult vfp edsp java tls +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xb76 +CPU revision : 7 +Hardware : BCM2835 +Revision : 0010 +Serial : 000000004a0abca9 diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/armv7-rev3-8cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/armv7-rev3-8cpu-cpuinfo new file mode 100644 index 00000000000..d4b4d3b6679 --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/armv7-rev3-8cpu-cpuinfo @@ -0,0 +1,75 @@ +processor : 0 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 12.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xc07 +CPU revision : 3 +processor : 1 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 12.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xc07 +CPU revision : 3 +processor : 2 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 12.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xc07 +CPU revision : 3 +processor : 3 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 12.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xc07 +CPU revision : 3 +processor : 4 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 120.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x2 +CPU part : 0xc0f +CPU revision : 3 +processor : 5 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 120.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x2 +CPU part : 0xc0f +CPU revision : 3 +processor : 6 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 120.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x2 +CPU part : 0xc0f +CPU revision : 3 +processor : 7 +model name : ARMv7 Processor rev 3 (v7l) +BogoMIPS : 120.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x2 +CPU part : 0xc0f +CPU revision : 3 +Hardware : ODROID-XU4 +Revision : 0100 +Serial : 0000000000000000 diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/armv7-rev4-4cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/armv7-rev4-4cpu-cpuinfo new file mode 100644 index 00000000000..f36075c2515 --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/armv7-rev4-4cpu-cpuinfo @@ -0,0 +1,39 @@ +processor : 0 +model name : ARMv7 Processor rev 4 (v7l) +BogoMIPS : 38.40 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 1 +model name : ARMv7 Processor rev 4 (v7l) +BogoMIPS : 38.40 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 2 +model name : ARMv7 Processor rev 4 (v7l) +BogoMIPS : 38.40 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +processor : 3 +model name : ARMv7 Processor rev 4 (v7l) +BogoMIPS : 38.40 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 4 +Hardware : BCM2835 +Revision : a02082 +Serial : 000000007881bb80 diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/ppc64-power7-rhel7-8cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/ppc64-power7-rhel7-8cpu-cpuinfo new file mode 100644 index 00000000000..1309c585048 --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/ppc64-power7-rhel7-8cpu-cpuinfo @@ -0,0 +1,44 @@ +processor : 0 +cpu : POWER7 (architected), altivec supported +clock : 3550.000000MHz +revision : 2.1 (pvr 003f 0201) + +processor : 1 +cpu : POWER7 (architected), altivec supported +clock : 3550.000000MHz +revision : 2.1 (pvr 003f 0201) + +processor : 2 +cpu : POWER7 (architected), altivec supported +clock : 3550.000000MHz +revision : 2.1 (pvr 003f 0201) + +processor : 3 +cpu : POWER7 (architected), altivec supported +clock : 3550.000000MHz +revision : 2.1 (pvr 003f 0201) + +processor : 4 +cpu : POWER7 (architected), altivec supported +clock : 3550.000000MHz +revision : 2.1 (pvr 003f 0201) + +processor : 5 +cpu : POWER7 (architected), altivec supported +clock : 3550.000000MHz +revision : 2.1 (pvr 003f 0201) + +processor : 6 +cpu : POWER7 (architected), altivec supported +clock : 3550.000000MHz +revision : 2.1 (pvr 003f 0201) + +processor : 7 +cpu : POWER7 (architected), altivec supported +clock : 3550.000000MHz +revision : 2.1 (pvr 003f 0201) + +timebase : 512000000 +platform : pSeries +model : IBM,8231-E2B +machine : CHRP IBM,8231-E2B \ No newline at end of file diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/ppc64le-power8-24cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/ppc64le-power8-24cpu-cpuinfo new file mode 100644 index 00000000000..4cbd5ac0056 --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/ppc64le-power8-24cpu-cpuinfo @@ -0,0 +1,125 @@ +processor : 0 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 1 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 2 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 3 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 4 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 5 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 6 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 7 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 8 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 9 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 10 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 11 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 12 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 13 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 14 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 15 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 16 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 17 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 18 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 19 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 20 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 21 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 22 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +processor : 23 +cpu : POWER8 (architected), altivec supported +clock : 3425.000000MHz +revision : 2.1 (pvr 004b 0201) + +timebase : 512000000 +platform : pSeries +model : IBM,8247-21L +machine : CHRP IBM,8247-21L + diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-2cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-2cpu-cpuinfo new file mode 100644 index 00000000000..1d233f8dc8a --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-2cpu-cpuinfo @@ -0,0 +1,56 @@ +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 62 +model name : Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz +stepping : 4 +microcode : 0x1 +cpu MHz : 2799.998 +cache size : 16384 KB +physical id : 0 +siblings : 1 +core id : 0 +cpu cores : 1 +apicid : 0 +initial apicid : 0 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp l' +m constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadlin' +e_timer aes xsave avx f16c rdrand hypervisor lahf_lm pti fsgsbase tsc_adjust smep erms xsaveopt arat +bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf +bogomips : 5602.32 +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: +processor : 1 +vendor_id : GenuineIntel +cpu family : 6 +model : 62 +model name : Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz +stepping : 4 +microcode : 0x1 +cpu MHz : 2799.998 +cache size : 16384 KB +physical id : 1 +siblings : 1 +core id : 0 +cpu cores : 1 +apicid : 1 +initial apicid : 1 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp l' +m constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadlin' +e_timer aes xsave avx f16c rdrand hypervisor lahf_lm pti fsgsbase tsc_adjust smep erms xsaveopt arat +bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf +bogomips : 5602.32 +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-4cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-4cpu-cpuinfo new file mode 100644 index 00000000000..fcc396db8d9 --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-4cpu-cpuinfo @@ -0,0 +1,104 @@ +processor : 0 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2216 +stepping : 2 +cpu MHz : 1000.000 +cache size : 1024 KB +physical id : 0 +siblings : 2 +core id : 0 +cpu cores : 2 +apicid : 0 +initial apicid : 0 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt ' +rdtscp lm 3dnowext 3dnow art rep_good nopl extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy retpoline_amd vmmcall +bogomips : 1994.60 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc +processor : 1 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2216 +stepping : 2 +cpu MHz : 1000.000 +cache size : 1024 KB +physical id : 0 +siblings : 2 +core id : 1 +cpu cores : 2 +apicid : 1 +initial apicid : 1 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt ' +rdtscp lm 3dnowext 3dnow art rep_good nopl extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy retpoline_amd vmmcall +bogomips : 1994.60 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc +processor : 2 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2216 +stepping : 2 +cpu MHz : 1000.000 +cache size : 1024 KB +physical id : 1 +siblings : 2 +core id : 0 +cpu cores : 2 +apicid : 2 +initial apicid : 2 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt ' +rdtscp lm 3dnowext 3dnow art rep_good nopl extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy retpoline_amd vmmcall +bogomips : 1994.60 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc +processor : 3 +vendor_id : AuthenticAMD +cpu family : 15 +model : 65 +model name : Dual-Core AMD Opteron(tm) Processor 2216 +stepping : 2 +cpu MHz : 1000.000 +cache size : 1024 KB +physical id : 1 +siblings : 2 +core id : 1 +cpu cores : 2 +apicid : 3 +initial apicid : 3 +fpu : yes +fpu_exception : yes +cpuid level : 1 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt ' +rdtscp lm 3dnowext 3dnow art rep_good nopl extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy retpoline_amd vmmcall +bogomips : 1994.60 +TLB size : 1024 4K pages +clflush size : 64 +cache_alignment : 64 +address sizes : 40 bits physical, 48 bits virtual +power management: ts fid vid ttp tm stc diff --git a/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-8cpu-cpuinfo b/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-8cpu-cpuinfo new file mode 100644 index 00000000000..63abea2cec6 --- /dev/null +++ b/test/units/module_utils/facts/fixtures/cpuinfo/x86_64-8cpu-cpuinfo @@ -0,0 +1,216 @@ +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz +stepping : 3 +microcode : 0x20 +cpu MHz : 2703.625 +cache size : 6144 KB +physical id : 0 +siblings : 8 +core id : 0 +cpu cores : 4 +apicid : 0 +initial apicid : 0 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts +bugs : +bogomips : 5388.06 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + +processor : 1 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz +stepping : 3 +microcode : 0x20 +cpu MHz : 3398.565 +cache size : 6144 KB +physical id : 0 +siblings : 8 +core id : 0 +cpu cores : 4 +apicid : 1 +initial apicid : 1 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts +bugs : +bogomips : 5393.53 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + +processor : 2 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz +stepping : 3 +microcode : 0x20 +cpu MHz : 3390.325 +cache size : 6144 KB +physical id : 0 +siblings : 8 +core id : 1 +cpu cores : 4 +apicid : 2 +initial apicid : 2 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts +bugs : +bogomips : 5391.63 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + +processor : 3 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz +stepping : 3 +microcode : 0x20 +cpu MHz : 3262.774 +cache size : 6144 KB +physical id : 0 +siblings : 8 +core id : 1 +cpu cores : 4 +apicid : 3 +initial apicid : 3 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts +bugs : +bogomips : 5392.08 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + +processor : 4 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz +stepping : 3 +microcode : 0x20 +cpu MHz : 2905.169 +cache size : 6144 KB +physical id : 0 +siblings : 8 +core id : 2 +cpu cores : 4 +apicid : 4 +initial apicid : 4 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts +bugs : +bogomips : 5391.97 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + +processor : 5 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz +stepping : 3 +microcode : 0x20 +cpu MHz : 1834.826 +cache size : 6144 KB +physical id : 0 +siblings : 8 +core id : 2 +cpu cores : 4 +apicid : 5 +initial apicid : 5 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts +bugs : +bogomips : 5392.11 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + +processor : 6 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz +stepping : 3 +microcode : 0x20 +cpu MHz : 2781.573 +cache size : 6144 KB +physical id : 0 +siblings : 8 +core id : 3 +cpu cores : 4 +apicid : 6 +initial apicid : 6 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts +bugs : +bogomips : 5391.98 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + +processor : 7 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz +stepping : 3 +microcode : 0x20 +cpu MHz : 3593.353 +cache size : 6144 KB +physical id : 0 +siblings : 8 +core id : 3 +cpu cores : 4 +apicid : 7 +initial apicid : 7 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts +bugs : +bogomips : 5392.07 +clflush size : 64 +cache_alignment : 64 +address sizes : 39 bits physical, 48 bits virtual +power management: + diff --git a/test/units/module_utils/facts/hardware/linux_data.py b/test/units/module_utils/facts/hardware/linux_data.py index f41c4d6f70b..7455b26bd4f 100644 --- a/test/units/module_utils/facts/hardware/linux_data.py +++ b/test/units/module_utils/facts/hardware/linux_data.py @@ -16,6 +16,8 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +import os + LSBLK_OUTPUT = b""" /dev/sda /dev/sda1 32caaec3-ef40-4691-a3b6-438c3f9bc1c0 @@ -360,3 +362,178 @@ STATVFS_INFO = {'/': {'block_available': 10192323, # ['/dev/sdz4', '/not/a/real/bind_mount', 'ext4', 'rw,seclabel,relatime,data=ordered', '0', '0'], BIND_MOUNTS = ['/not/a/real/bind_mount'] + +CPU_INFO_TEST_SCENARIOS = [ + { + 'architecture': 'armv61', + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/armv6-rev7-1cpu-cpuinfo')).readlines(), + 'expected_result': { + 'processor': ['0', 'ARMv6-compatible processor rev 7 (v6l)'], + 'processor_cores': 1, + 'processor_count': 1, + 'processor_threads_per_core': 1, + 'processor_vcpus': 1}, + }, + { + 'architecture': 'armv71', + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/armv7-rev4-4cpu-cpuinfo')).readlines(), + 'expected_result': { + 'processor': [ + '0', 'ARMv7 Processor rev 4 (v7l)', + '1', 'ARMv7 Processor rev 4 (v7l)', + '2', 'ARMv7 Processor rev 4 (v7l)', + '3', 'ARMv7 Processor rev 4 (v7l)', + ], + 'processor_cores': 1, + 'processor_count': 4, + 'processor_threads_per_core': 1, + 'processor_vcpus': 4}, + }, + { + 'architecture': 'aarch64', + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/aarch64-4cpu-cpuinfo')).readlines(), + 'expected_result': { + 'processor': [ + '0', 'AArch64 Processor rev 4 (aarch64)', + '1', 'AArch64 Processor rev 4 (aarch64)', + '2', 'AArch64 Processor rev 4 (aarch64)', + '3', 'AArch64 Processor rev 4 (aarch64)', + ], + 'processor_cores': 1, + 'processor_count': 4, + 'processor_threads_per_core': 1, + 'processor_vcpus': 4}, + }, + { + 'architecture': 'x86_64', + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/x86_64-4cpu-cpuinfo')).readlines(), + 'expected_result': { + 'processor': [ + '0', 'AuthenticAMD', 'Dual-Core AMD Opteron(tm) Processor 2216', + '1', 'AuthenticAMD', 'Dual-Core AMD Opteron(tm) Processor 2216', + '2', 'AuthenticAMD', 'Dual-Core AMD Opteron(tm) Processor 2216', + '3', 'AuthenticAMD', 'Dual-Core AMD Opteron(tm) Processor 2216', + ], + 'processor_cores': 2, + 'processor_count': 2, + 'processor_threads_per_core': 1, + 'processor_vcpus': 4}, + }, + { + 'architecture': 'x86_64', + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/x86_64-8cpu-cpuinfo')).readlines(), + 'expected_result': { + 'processor': [ + '0', 'GenuineIntel', 'Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz', + '1', 'GenuineIntel', 'Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz', + '2', 'GenuineIntel', 'Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz', + '3', 'GenuineIntel', 'Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz', + '4', 'GenuineIntel', 'Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz', + '5', 'GenuineIntel', 'Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz', + '6', 'GenuineIntel', 'Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz', + '7', 'GenuineIntel', 'Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz', + ], + 'processor_cores': 4, + 'processor_count': 1, + 'processor_threads_per_core': 2, + 'processor_vcpus': 8}, + }, + { + 'architecture': 'arm64', + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/arm64-4cpu-cpuinfo')).readlines(), + 'expected_result': { + 'processor': ['0', '1', '2', '3'], + 'processor_cores': 1, + 'processor_count': 4, + 'processor_threads_per_core': 1, + 'processor_vcpus': 4}, + }, + { + 'architecture': 'armv71', + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/armv7-rev3-8cpu-cpuinfo')).readlines(), + 'expected_result': { + 'processor': [ + '0', 'ARMv7 Processor rev 3 (v7l)', + '1', 'ARMv7 Processor rev 3 (v7l)', + '2', 'ARMv7 Processor rev 3 (v7l)', + '3', 'ARMv7 Processor rev 3 (v7l)', + '4', 'ARMv7 Processor rev 3 (v7l)', + '5', 'ARMv7 Processor rev 3 (v7l)', + '6', 'ARMv7 Processor rev 3 (v7l)', + '7', 'ARMv7 Processor rev 3 (v7l)', + ], + 'processor_cores': 1, + 'processor_count': 8, + 'processor_threads_per_core': 1, + 'processor_vcpus': 8}, + }, + { + 'architecture': 'x86_64', + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/x86_64-2cpu-cpuinfo')).readlines(), + 'expected_result': { + 'processor': [ + '0', 'GenuineIntel', 'Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz', + '1', 'GenuineIntel', 'Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz', + ], + 'processor_cores': 1, + 'processor_count': 2, + 'processor_threads_per_core': 1, + 'processor_vcpus': 2}, + }, + { + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/ppc64-power7-rhel7-8cpu-cpuinfo')).readlines(), + 'architecture': 'ppc64', + 'expected_result': { + 'processor': [ + '0', 'POWER7 (architected), altivec supported', + '1', 'POWER7 (architected), altivec supported', + '2', 'POWER7 (architected), altivec supported', + '3', 'POWER7 (architected), altivec supported', + '4', 'POWER7 (architected), altivec supported', + '5', 'POWER7 (architected), altivec supported', + '6', 'POWER7 (architected), altivec supported', + '7', 'POWER7 (architected), altivec supported' + ], + 'processor_cores': 1, + 'processor_count': 16, + 'processor_threads_per_core': 1, + 'processor_vcpus': 16 + }, + }, + { + 'cpuinfo': open(os.path.join(os.path.dirname(__file__), '../fixtures/cpuinfo/ppc64le-power8-24cpu-cpuinfo')).readlines(), + 'architecture': 'ppc64le', + 'expected_result': { + 'processor': [ + '0', 'POWER8 (architected), altivec supported', + '1', 'POWER8 (architected), altivec supported', + '2', 'POWER8 (architected), altivec supported', + '3', 'POWER8 (architected), altivec supported', + '4', 'POWER8 (architected), altivec supported', + '5', 'POWER8 (architected), altivec supported', + '6', 'POWER8 (architected), altivec supported', + '7', 'POWER8 (architected), altivec supported', + '8', 'POWER8 (architected), altivec supported', + '9', 'POWER8 (architected), altivec supported', + '10', 'POWER8 (architected), altivec supported', + '11', 'POWER8 (architected), altivec supported', + '12', 'POWER8 (architected), altivec supported', + '13', 'POWER8 (architected), altivec supported', + '14', 'POWER8 (architected), altivec supported', + '15', 'POWER8 (architected), altivec supported', + '16', 'POWER8 (architected), altivec supported', + '17', 'POWER8 (architected), altivec supported', + '18', 'POWER8 (architected), altivec supported', + '19', 'POWER8 (architected), altivec supported', + '20', 'POWER8 (architected), altivec supported', + '21', 'POWER8 (architected), altivec supported', + '22', 'POWER8 (architected), altivec supported', + '23', 'POWER8 (architected), altivec supported', + ], + 'processor_cores': 1, + 'processor_count': 48, + 'processor_threads_per_core': 1, + 'processor_vcpus': 48 + }, + }, +] diff --git a/test/units/module_utils/facts/hardware/test_linux_get_cpu_info.py b/test/units/module_utils/facts/hardware/test_linux_get_cpu_info.py new file mode 100644 index 00000000000..bf34c62302e --- /dev/null +++ b/test/units/module_utils/facts/hardware/test_linux_get_cpu_info.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.module_utils.facts.hardware import linux + +from . linux_data import CPU_INFO_TEST_SCENARIOS + + +def test_get_cpu_info(mocker): + module = mocker.Mock() + inst = linux.LinuxHardware(module) + + mocker.patch('os.path.exists', return_value=False) + mocker.patch('os.access', return_value=True) + for test in CPU_INFO_TEST_SCENARIOS: + mocker.patch('ansible.module_utils.facts.hardware.linux.get_file_lines', side_effect=[[], test['cpuinfo']]) + collected_facts = {'ansible_architecture': test['architecture']} + assert test['expected_result'] == inst.get_cpu_facts(collected_facts=collected_facts)