From 92e4ba4c2b767f245a9fe26605e176b010b22a0c Mon Sep 17 00:00:00 2001 From: jainprasuk1996 Date: Thu, 6 Sep 2018 06:49:16 -0500 Subject: [PATCH] Fix CPU count returned by introspection in Ironic iDRAC driver Change-Id: Id8ff61f7f2fb2c24af64f38f6cf34e5b6d66182c --- dracclient/resources/inventory.py | 12 +++++++++++- dracclient/tests/test_inventory.py | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dracclient/resources/inventory.py b/dracclient/resources/inventory.py index 4ce4eae..e410722 100644 --- a/dracclient/resources/inventory.py +++ b/dracclient/resources/inventory.py @@ -47,7 +47,7 @@ NIC_MODE = { CPU = collections.namedtuple( 'CPU', ['id', 'cores', 'speed_mhz', 'model', 'status', 'ht_enabled', - 'turbo_enabled', 'vt_enabled', 'arch64']) + 'cpu_count', 'turbo_enabled', 'vt_enabled', 'arch64']) Memory = collections.namedtuple( 'Memory', @@ -99,10 +99,20 @@ class InventoryManagement(object): allow_missing=True)), turbo_enabled=bool(self._get_cpu_attr(cpu, 'TurboModeEnabled', allow_missing=True)), + cpu_count=self._get_cpu_count( + int(self._get_cpu_attr(cpu, 'NumberOfProcessorCores')), + bool(self._get_cpu_attr(cpu, 'HyperThreadingEnabled', + allow_missing=True))), vt_enabled=bool(self._get_cpu_attr( cpu, 'VirtualizationTechnologyEnabled', allow_missing=True)), arch64=arch64) + def _get_cpu_count(self, cores, ht_enabled): + if ht_enabled: + return int(cores * 2) + else: + return int(cores) + def _get_cpu_attr(self, cpu, attr_name, allow_missing=False): return utils.get_wsman_resource_attr( cpu, uris.DCIM_CPUView, attr_name, allow_missing=allow_missing) diff --git a/dracclient/tests/test_inventory.py b/dracclient/tests/test_inventory.py index 27b116c..5037021 100644 --- a/dracclient/tests/test_inventory.py +++ b/dracclient/tests/test_inventory.py @@ -40,6 +40,7 @@ class ClientInventoryManagementTestCase(base.BaseTest): model='Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz', status='ok', ht_enabled=True, + cpu_count=12, turbo_enabled=True, vt_enabled=True, arch64=True)] @@ -61,6 +62,7 @@ class ClientInventoryManagementTestCase(base.BaseTest): model='Intel(R) Xeon(R) CPU E5-2440 v2 @ 1.90GHz', status='ok', ht_enabled=False, + cpu_count=8, turbo_enabled=False, vt_enabled=False, arch64=False)]