diff options
Diffstat (limited to 'windriver')
-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 + |