diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-03-26 13:05:44 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-03-26 13:08:57 +0800 |
commit | d2f06dfe231e43c57883fbdc8df655199ac82b2d (patch) | |
tree | 8193c56ddb295876c7aadb089d6eafb93a746a37 /windriver/titanium_cloud/registration | |
parent | 0a17fd030f5ba1164a221f1147dfdd971ebda97e (diff) |
Add HPA cpu topology capabilities for TC
Change-Id: I6e787e26ccc4288e1ff4055c5f4b3cbab52c5c61
Issue-ID: MULTICLOUD-200
Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/registration')
-rw-r--r-- | windriver/titanium_cloud/registration/tests/test_registration.py | 5 | ||||
-rw-r--r-- | windriver/titanium_cloud/registration/views/registration.py | 29 |
2 files changed, 33 insertions, 1 deletions
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 + |