ansible/ansible — pull request #3427 by insom (2013-07-03 15:37:03+00:00)
Title: Make the CPU facts Hyperthreading aware

Regarding and building on #3409, the CPU fact in setup also doesn't handle Hyperthreads correctly. I've run the below against Darren's gist referenced in that issue, and get:

{'processor_vcpus': 2, 'processor_threads_per_core': 1, 'processor_cores': 1, 'processor_count': 2}
{'processor_vcpus': 4, 'processor_threads_per_core': 4, 'processor_cores': 1, 'processor_count': 1}
{'processor_vcpus': 24, 'processor_threads_per_core': 2, 'processor_cores': 6, 'processor_count': 2}

For a dual VCPU KVM install, a 4 CPU EC2 instance (Xen) and a dual CPU, 6 core, Hyperthreaded physical host. I've followed [this page](http://www.richweb.com/cpu_info) which, while not an authority, was the clearest write up of how this is supposed to use that I could find.

I've also remove the special casing for one CPU which returned the `processor_cores` as NA - even an Raspberry Pi technically has one "core". The value `processor_vcpus` matches up with what `top(1)` and other Linux utilities give for their CPU count (that is; they are things that can have a process run on them, whether a full core or a hardware thread).

I've avoided Python's ternary syntax as it's only for 2.5 and higher, and I believe we're still aiming to be 2.4 compatible?