From d2f06dfe231e43c57883fbdc8df655199ac82b2d Mon Sep 17 00:00:00 2001 From: Yun Huang Date: Mon, 26 Mar 2018 13:05:44 +0800 Subject: Add HPA cpu topology capabilities for TC Change-Id: I6e787e26ccc4288e1ff4055c5f4b3cbab52c5c61 Issue-ID: MULTICLOUD-200 Signed-off-by: Yun Huang --- .../registration/tests/test_registration.py | 5 +++- .../registration/views/registration.py | 29 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'windriver/titanium_cloud/registration') diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py index 3e8c5612..53e8a47b 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration.py +++ b/windriver/titanium_cloud/registration/tests/test_registration.py @@ -50,7 +50,10 @@ MOCK_GET_FLAVOR_EXTRA_SPECS_RESPONSE = { "aggregate_instance_extra_specs:storage" : "local_image", "capabilities:cpu_info:model" : "Haswell", "hw:cpu_policy" : "dedicated", - "hw:cpu_thread_policy" : "prefer" + "hw:cpu_thread_policy" : "prefer", + "hw:cpu_sockets" : "2", + "hw:cpu_cores" : "4", + "hw:cpu_threads" : "16" } } diff --git a/windriver/titanium_cloud/registration/views/registration.py b/windriver/titanium_cloud/registration/views/registration.py index 8a21cb5c..c2d2f07a 100644 --- a/windriver/titanium_cloud/registration/views/registration.py +++ b/windriver/titanium_cloud/registration/views/registration.py @@ -94,6 +94,12 @@ class Registry(newton_registration.Registry): self._logger.debug("cpupining_capabilities_info: %s" % caps_dict) hpa_caps.append(caps_dict) + # cputopology capabilities + caps_dict = self._get_cputopology_capabilities(extra_specs) + if len(caps_dict) > 0: + self._logger.debug("cputopology_capabilities_info: %s" % caps_dict) + hpa_caps.append(caps_dict) + return hpa_caps def _get_hpa_basic_capabilities(self, flavor): @@ -133,3 +139,26 @@ class Registry(newton_registration.Registry): return cpupining_capability + def _get_cputopology_capabilities(self, extra_specs): + cputopology_capability = {} + feature_uuid = uuid.uuid4() + + if extra_specs.has_key('hw:cpu_sockets') or extra_specs.has_key('hw:cpu_cores') or extra_specs.has_key('hw:cpu_threads'): + cputopology_capability['hpaCapabilityID'] = str(feature_uuid) + cputopology_capability['hpaFeature'] = 'cpuTopology' + cputopology_capability['hardwareArchitecture'] = 'generic' + cputopology_capability['version'] = 'v1' + + cputopology_capability['attributes'] = [] + if extra_specs.has_key('hw:cpu_sockets'): + cputopology_capability['attributes'].append({'hpa-attribute-key': 'numCpuSockets', + 'hpa-attribute-value':{'value': str(extra_specs['hw:cpu_sockets'])}}) + if extra_specs.has_key('hw:cpu_cores'): + cputopology_capability['attributes'].append({'hpa-attribute-key': 'numCpuCores', + 'hpa-attribute-value':{'value': str(extra_specs['hw:cpu_cores'])}}) + if extra_specs.has_key('hw:cpu_threads'): + cputopology_capability['attributes'].append({'hpa-attribute-key': 'numCpuThreads', + 'hpa-attribute-value':{'value': str(extra_specs['hw:cpu_threads'])}}) + + return cputopology_capability + -- cgit 1.2.3-korg