diff --git a/doc/source/admin/how_it_works.rst b/doc/source/admin/how_it_works.rst index 831013264..062a34346 100644 --- a/doc/source/admin/how_it_works.rst +++ b/doc/source/admin/how_it_works.rst @@ -171,7 +171,7 @@ fields: ``cpu`` CPU information: ``model_name``, ``frequency``, ``count``, - ``architecture`` and ``flags``. + ``architecture``, ``flags`` and ``socket_count``. ``memory`` RAM information: ``total`` (total size in bytes), ``physical_mb`` diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index ca481935d..e575a51a2 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -803,13 +803,14 @@ class NetworkInterface(encoding.SerializableComparable): class CPU(encoding.SerializableComparable): serializable_fields = ('model_name', 'frequency', 'count', 'architecture', - 'flags') + 'flags', 'socket_count') def __init__(self, model_name, frequency, count, architecture, - flags=None): + flags=None, socket_count=None): self.model_name = model_name self.frequency = frequency self.count = count + self.socket_count = socket_count self.architecture = architecture self.flags = flags or [] @@ -1491,7 +1492,8 @@ class GenericHardwareManager(HardwareManager): # this includes hyperthreading cores count=int(cpu_info.get('cpu(s)')), architecture=cpu_info.get('architecture'), - flags=flags) + flags=flags, + socket_count=int(cpu_info.get('socket(s)', 0))) def get_memory(self): # psutil returns a long, so we force it to an int diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py index 827a2cdfc..4724cb005 100644 --- a/ironic_python_agent/tests/unit/test_hardware.py +++ b/ironic_python_agent/tests/unit/test_hardware.py @@ -871,6 +871,7 @@ class TestGenericHardwareManager(base.IronicAgentTest): cpus.model_name) self.assertEqual('2400.0000', cpus.frequency) self.assertEqual(4, cpus.count) + self.assertEqual(1, cpus.socket_count) self.assertEqual('x86_64', cpus.architecture) self.assertEqual(['fpu', 'vme', 'de', 'pse'], cpus.flags) @@ -884,6 +885,7 @@ class TestGenericHardwareManager(base.IronicAgentTest): cpus.model_name) self.assertEqual('1794.433', cpus.frequency) self.assertEqual(12, cpus.count) + self.assertEqual(1, cpus.socket_count) self.assertEqual('x86_64', cpus.architecture) self.assertEqual(['fpu', 'vme', 'de', 'pse'], cpus.flags) diff --git a/releasenotes/notes/collect-cpu-sockets-0dbc09a1ebccfe77.yaml b/releasenotes/notes/collect-cpu-sockets-0dbc09a1ebccfe77.yaml new file mode 100644 index 000000000..17d5d8afb --- /dev/null +++ b/releasenotes/notes/collect-cpu-sockets-0dbc09a1ebccfe77.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add support for collecting the cpu socket number.