summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Hu <bh526r@att.com>2018-03-26 05:23:22 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-26 05:23:22 +0000
commit8dcc989a6bdb0f295568abce8ac2648c95d04ff0 (patch)
treef7110f05930e394eb447a60b4e326220a1d303e5
parente9a54b9c4710a82a43cdd01214fe29d1562c17f6 (diff)
parent0a17fd030f5ba1164a221f1147dfdd971ebda97e (diff)
Merge "Add HPA cpupining capabilities for titanium cloud"
-rw-r--r--windriver/titanium_cloud/registration/tests/test_registration.py4
-rw-r--r--windriver/titanium_cloud/registration/views/registration.py30
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
+