summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordigambar <digambarpatil15@yahoo.co.in>2018-10-30 11:57:38 -0500
committerRichard Pioso <richard.pioso@dell.com>2019-02-04 07:19:19 -0500
commit000ce3d365f48bf3a35f92e63dbdc14d7d101810 (patch)
tree6d5a83b7eb0fd519275e2bc2a766b6645b30346a
parent08c0c117838d516cab195adfce9673b0c0bf7a2c (diff)
downloadironic-000ce3d365f48bf3a35f92e63dbdc14d7d101810.tar.gz
Fix CPU count returned by introspection in Ironic iDRAC driver
If list_cpus in dracclient, it returns below values - [CPU(id='CPU.Socket.1', cores=14, ht__enabled=True), CPU(id='CPU.Socket.2', cores=14, ht_enabled=True)] Each CPU socket has cores with hyperthreading enabled, so if we calculate the cpu per socket, we will get actual cpu count per socket, So objective of this patch to fetch actual CPU's per socket and sum it Story: #2004155 Change-Id: Ia86b0462a3e73af7a2ce0a6439286f7071f74caa (cherry picked from commit 3e1fe5f7e45c66f606b179b4c7e57a5d2bbc6e75)
-rw-r--r--ironic/drivers/modules/drac/inspect.py15
-rw-r--r--ironic/tests/unit/drivers/modules/drac/test_inspect.py24
-rw-r--r--releasenotes/notes/fix-cpu-count-8904a4e1a24456f4.yaml7
3 files changed, 41 insertions, 5 deletions
diff --git a/ironic/drivers/modules/drac/inspect.py b/ironic/drivers/modules/drac/inspect.py
index 1d53d67b6..51fb0c561 100644
--- a/ironic/drivers/modules/drac/inspect.py
+++ b/ironic/drivers/modules/drac/inspect.py
@@ -80,7 +80,8 @@ class DracInspect(base.InspectInterface):
[memory.size_mb for memory in client.list_memory()])
cpus = client.list_cpus()
if cpus:
- properties['cpus'] = len(cpus)
+ properties['cpus'] = sum(
+ [self._calculate_cpus(cpu) for cpu in cpus])
properties['cpu_arch'] = 'x86_64' if cpus[0].arch64 else 'x86'
virtual_disks = client.list_virtual_disks()
@@ -199,3 +200,15 @@ class DracInspect(base.InspectInterface):
pxe_dev_nics.append(nic.id)
return pxe_dev_nics
+
+ def _calculate_cpus(self, cpu):
+ """Find actual CPU count.
+
+ :param cpu: Pass cpu.
+
+ :returns: returns total cpu count.
+ """
+ if cpu.ht_enabled:
+ return cpu.cores * 2
+ else:
+ return cpu.cores
diff --git a/ironic/tests/unit/drivers/modules/drac/test_inspect.py b/ironic/tests/unit/drivers/modules/drac/test_inspect.py
index cb6638b5a..902e633b5 100644
--- a/ironic/tests/unit/drivers/modules/drac/test_inspect.py
+++ b/ironic/tests/unit/drivers/modules/drac/test_inspect.py
@@ -67,7 +67,7 @@ class DracInspectionTestCase(db_base.DbTestCase):
'speed': 2400,
'model': 'Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz',
'state': 'ok',
- 'ht_enabled': True,
+ 'ht_enabled': False,
'turbo_enabled': True,
'vt_enabled': True,
'arch64': True}]
@@ -162,7 +162,7 @@ class DracInspectionTestCase(db_base.DbTestCase):
expected_node_properties = {
'memory_mb': 32768,
'local_gb': 1116,
- 'cpus': 2,
+ 'cpus': 18,
'cpu_arch': 'x86_64'}
mock_client = mock.Mock()
mock_get_drac_client.return_value = mock_client
@@ -206,7 +206,7 @@ class DracInspectionTestCase(db_base.DbTestCase):
expected_node_properties = {
'memory_mb': 32768,
'local_gb': 279,
- 'cpus': 2,
+ 'cpus': 18,
'cpu_arch': 'x86_64'}
mock_client = mock.Mock()
mock_get_drac_client.return_value = mock_client
@@ -252,7 +252,7 @@ class DracInspectionTestCase(db_base.DbTestCase):
expected_node_properties = {
'memory_mb': 32768,
'local_gb': 1116,
- 'cpus': 2,
+ 'cpus': 18,
'cpu_arch': 'x86_64'}
mock_client = mock.Mock()
mock_get_drac_client.return_value = mock_client
@@ -361,3 +361,19 @@ class DracInspectionTestCase(db_base.DbTestCase):
mock_client, self.nics, self.node)
self.assertEqual(expected_pxe_nic, pxe_dev_nics)
+
+ def test__calculate_cpus(self):
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=True) as task:
+ cpu = task.driver.inspect._calculate_cpus(
+ self.cpus[0])
+
+ self.assertEqual(12, cpu)
+
+ def test__calculate_cpus_without_ht_enabled(self):
+ with task_manager.acquire(self.context, self.node.uuid,
+ shared=True) as task:
+ cpu = task.driver.inspect._calculate_cpus(
+ self.cpus[1])
+
+ self.assertEqual(6, cpu)
diff --git a/releasenotes/notes/fix-cpu-count-8904a4e1a24456f4.yaml b/releasenotes/notes/fix-cpu-count-8904a4e1a24456f4.yaml
new file mode 100644
index 000000000..e609f2ab5
--- /dev/null
+++ b/releasenotes/notes/fix-cpu-count-8904a4e1a24456f4.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+ - |
+ Fixes a bug where the number of CPU sockets was being returned by the
+ ``idrac`` hardware type during introspection, instead of the number of
+ virtual CPUs. See bug `2004155
+ <https://storyboard.openstack.org/#!/story/2004155>`_ for details.