Add HPA huge pages capabilities for TC 69/38369/1
authorYun Huang <yun.huang@windriver.com>
Mon, 26 Mar 2018 05:48:41 +0000 (13:48 +0800)
committerYun Huang <yun.huang@windriver.com>
Mon, 26 Mar 2018 05:51:08 +0000 (13:51 +0800)
Change-Id: I023cdfd3023a48ef7a036942486bedc9c9940701
Issue-ID: MULTICLOUD-200
Signed-off-by: Yun Huang <yun.huang@windriver.com>
windriver/titanium_cloud/registration/tests/test_registration.py
windriver/titanium_cloud/registration/views/registration.py

index 53e8a47..231a435 100644 (file)
@@ -53,7 +53,8 @@ MOCK_GET_FLAVOR_EXTRA_SPECS_RESPONSE = {
       "hw:cpu_thread_policy" : "prefer",
       "hw:cpu_sockets" : "2",
       "hw:cpu_cores" : "4",
-      "hw:cpu_threads" : "16"
+      "hw:cpu_threads" : "16",
+      "hw:mem_page_size" : "large"
    }
 }
 
index c2d2f07..7fce48a 100644 (file)
@@ -100,6 +100,12 @@ class Registry(newton_registration.Registry):
             self._logger.debug("cputopology_capabilities_info: %s" % caps_dict)
             hpa_caps.append(caps_dict)
 
+        # hugepages capabilities
+        caps_dict = self._get_hugepages_capabilities(extra_specs)
+        if len(caps_dict) > 0:
+            self._logger.debug("hugepages_capabilities_info: %s" % caps_dict)
+            hpa_caps.append(caps_dict)
+
         return hpa_caps
 
     def _get_hpa_basic_capabilities(self, flavor):
@@ -162,3 +168,17 @@ class Registry(newton_registration.Registry):
 
         return cputopology_capability
 
+    def _get_hugepages_capabilities(self, extra_specs):
+        hugepages_capability = {}
+        feature_uuid = uuid.uuid4()
+
+        if extra_specs.has_key('hw:mem_page_size'):
+            hugepages_capability['hpaCapabilityID'] = str(feature_uuid)
+            hugepages_capability['hpaFeature'] = 'hugePages'
+            hugepages_capability['hardwareArchitecture'] = 'generic'
+            hugepages_capability['version'] = 'v1'
+
+            hugepages_capability['attributes'] = []
+            hugepages_capability['attributes'].append({'hpa-attribute-key': 'memoryPageSize',
+                                                       'hpa-attribute-value':{'value': str(extra_specs['hw:mem_page_size'])}})
+        return hugepages_capability