diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-03-26 12:31:04 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-03-26 12:31:04 +0800 |
commit | 0a17fd030f5ba1164a221f1147dfdd971ebda97e (patch) | |
tree | d61b8ffd9e05b2b44b9e0c11220e1a378fa1cd88 /windriver | |
parent | 7127ff91c8f834b525251f4842a4474c3fabc5f1 (diff) |
Add HPA cpupining capabilities for titanium cloud
Change-Id: Iee24fb0058f824aa39d44c5f961497ca45ba7b6e
Issue-ID: MULTICLOUD-200
Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'windriver')
-rw-r--r-- | windriver/titanium_cloud/registration/tests/test_registration.py | 4 | ||||
-rw-r--r-- | windriver/titanium_cloud/registration/views/registration.py | 30 |
2 files changed, 31 insertions, 3 deletions
diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py index 3dcbd547..3e8c5612 100644 --- a/windriver/titanium_cloud/registration/tests/test_registration.py +++ b/windriver/titanium_cloud/registration/tests/test_registration.py @@ -48,7 +48,9 @@ MOCK_GET_FLAVOR_RESPONSE = { MOCK_GET_FLAVOR_EXTRA_SPECS_RESPONSE = { "extra_specs" : { "aggregate_instance_extra_specs:storage" : "local_image", - "capabilities:cpu_info:model" : "Haswell" + "capabilities:cpu_info:model" : "Haswell", + "hw:cpu_policy" : "dedicated", + "hw:cpu_thread_policy" : "prefer" } } diff --git a/windriver/titanium_cloud/registration/views/registration.py b/windriver/titanium_cloud/registration/views/registration.py index d735336c..8a21cb5c 100644 --- a/windriver/titanium_cloud/registration/views/registration.py +++ b/windriver/titanium_cloud/registration/views/registration.py @@ -40,7 +40,7 @@ class Registry(newton_registration.Registry): cloud_owner, cloud_region_id = extsys.decode_vim_id(vimid) for flavor in self._get_list_resources( "/flavors/detail", "compute", session, viminfo, vimid, - "flavors"): + "flavors"): flavor_info = { 'flavor-id': flavor['id'], 'flavor-name': flavor['name'], @@ -88,13 +88,19 @@ class Registry(newton_registration.Registry): self._logger.debug("basic_capabilities_info: %s" % caps_dict) hpa_caps.append(caps_dict) + # cpupining capabilities + caps_dict = self._get_cpupining_capabilities(extra_specs) + if len(caps_dict) > 0: + self._logger.debug("cpupining_capabilities_info: %s" % caps_dict) + hpa_caps.append(caps_dict) + return hpa_caps def _get_hpa_basic_capabilities(self, flavor): basic_capability = {} feature_uuid = uuid.uuid4() - basic_capability['hpaCapabilityID'] = str(feature_uuid) + basic_capability['hpaCapabilityID'] = str(feature_uuid) basic_capability['hpaFeature'] = 'basicCapabilities' basic_capability['hardwareArchitecture'] = 'generic' basic_capability['version'] = 'v1' @@ -107,3 +113,23 @@ class Registry(newton_registration.Registry): return basic_capability + def _get_cpupining_capabilities(self, extra_specs): + cpupining_capability = {} + feature_uuid = uuid.uuid4() + + if extra_specs.has_key('hw:cpu_policy') or extra_specs.has_key('hw:cpu_thread_policy'): + cpupining_capability['hpaCapabilityID'] = str(feature_uuid) + cpupining_capability['hpaFeature'] = 'cpuPining' + cpupining_capability['hardwareArchitecture'] = 'generic' + cpupining_capability['version'] = 'v1' + + cpupining_capability['attributes'] = [] + if extra_specs.has_key('hw:cpu_thread_policy'): + cpupining_capability['attributes'].append({'hpa-attribute-key': 'logicalCpuThreadPinningPolicy', + 'hpa-attribute-value':{'value': str(extra_specs['hw:cpu_thread_policy'])}}) + if extra_specs.has_key('hw:cpu_policy'): + cpupining_capability['attributes'].append({'hpa-attribute-key':'logicalCpuPinningPolicy', + 'hpa-attribute-value': {'value':str(extra_specs['hw:cpu_policy'])}}) + + return cpupining_capability + |