summaryrefslogtreecommitdiffstats
path: root/windriver/titanium_cloud/registration
diff options
context:
space:
mode:
Diffstat (limited to 'windriver/titanium_cloud/registration')
-rw-r--r--windriver/titanium_cloud/registration/tests/test_registration.py10
-rw-r--r--windriver/titanium_cloud/registration/views/registration.py111
2 files changed, 119 insertions, 2 deletions
diff --git a/windriver/titanium_cloud/registration/tests/test_registration.py b/windriver/titanium_cloud/registration/tests/test_registration.py
index 231a4358..0b3a516d 100644
--- a/windriver/titanium_cloud/registration/tests/test_registration.py
+++ b/windriver/titanium_cloud/registration/tests/test_registration.py
@@ -54,7 +54,15 @@ MOCK_GET_FLAVOR_EXTRA_SPECS_RESPONSE = {
"hw:cpu_sockets" : "2",
"hw:cpu_cores" : "4",
"hw:cpu_threads" : "16",
- "hw:mem_page_size" : "large"
+ "hw:mem_page_size" : "large",
+ "hw:numa_nodes" : "2",
+ "hw:numa_cpus.0" : "0,1",
+ "hw:numa_cpus.1" : "2,3,4,5",
+ "hw:numa_mem.0" : "2048",
+ "hw:numa_mem.1" : "2048",
+ "hw:capabilities:cpu_info:features":"avx,acpi",
+ "pci_passthrough:alias":"sriov-vf-intel-8086-15b3:4"
+
}
}
diff --git a/windriver/titanium_cloud/registration/views/registration.py b/windriver/titanium_cloud/registration/views/registration.py
index 7fce48a6..769040ff 100644
--- a/windriver/titanium_cloud/registration/views/registration.py
+++ b/windriver/titanium_cloud/registration/views/registration.py
@@ -26,7 +26,7 @@ from keystoneauth1.exceptions import HttpError
logger = logging.getLogger(__name__)
-DEBUG=True
+# DEBUG=True
class Registry(newton_registration.Registry):
@@ -106,6 +106,30 @@ class Registry(newton_registration.Registry):
self._logger.debug("hugepages_capabilities_info: %s" % caps_dict)
hpa_caps.append(caps_dict)
+ # numa capabilities
+ caps_dict = self._get_numa_capabilities(extra_specs)
+ if len(caps_dict) > 0:
+ self._logger.debug("numa_capabilities_info: %s" % caps_dict)
+ hpa_caps.append(caps_dict)
+
+ # storage capabilities
+ caps_dict = self._get_storage_capabilities(flavor)
+ if len(caps_dict) > 0:
+ self._logger.debug("storage_capabilities_info: %s" % caps_dict)
+ hpa_caps.append(caps_dict)
+
+ # CPU instruction set extension capabilities
+ caps_dict = self._get_instruction_set_capabilities(extra_specs)
+ if len(caps_dict) > 0:
+ self._logger.debug("instruction_set_capabilities_info: %s" % caps_dict)
+ hpa_caps.append(caps_dict)
+
+ # PCI passthrough capabilities
+ caps_dict = self._get_pci_passthrough_capabilities(extra_specs)
+ if len(caps_dict) > 0:
+ self._logger.debug("pci_passthrough_capabilities_info: %s" % caps_dict)
+ hpa_caps.append(caps_dict)
+
return hpa_caps
def _get_hpa_basic_capabilities(self, flavor):
@@ -182,3 +206,88 @@ class Registry(newton_registration.Registry):
hugepages_capability['attributes'].append({'hpa-attribute-key': 'memoryPageSize',
'hpa-attribute-value':{'value': str(extra_specs['hw:mem_page_size'])}})
return hugepages_capability
+
+ def _get_numa_capabilities(self, extra_specs):
+ numa_capability = {}
+ feature_uuid = uuid.uuid4()
+
+ if extra_specs.has_key('hw:numa_nodes'):
+ numa_capability['hpaCapabilityID'] = str(feature_uuid)
+ numa_capability['hpaFeature'] = 'numa'
+ numa_capability['hardwareArchitecture'] = 'generic'
+ numa_capability['version'] = 'v1'
+
+ numa_capability['attributes'] = []
+ numa_capability['attributes'].append({'hpa-attribute-key': 'numaNodes',
+ 'hpa-attribute-value':{'value': str(extra_specs['hw:numa_nodes'])}})
+
+ for num in range(0, int(extra_specs['hw:numa_nodes'])):
+ numa_cpu_node = "hw:numa_cpus.%s" % num
+ numa_mem_node = "hw:numa_mem.%s" % num
+ numacpu_key = "numaCpu-%s" % num
+ numamem_key = "numaMem-%s" % num
+
+ if extra_specs.has_key(numa_cpu_node) and extra_specs.has_key(numa_mem_node):
+ numa_capability['attributes'].append({'hpa-attribute-key': numacpu_key,
+ 'hpa-attribute-value':{'value': str(extra_specs[numa_cpu_node])}})
+ numa_capability['attributes'].append({'hpa-attribute-key': numamem_key,
+ 'hpa-attribute-value':{'value': str(extra_specs[numa_mem_node]),'unit':'MB'}})
+
+ return numa_capability
+
+ def _get_storage_capabilities(self, flavor):
+ storage_capability = {}
+ feature_uuid = uuid.uuid4()
+
+ storage_capability['hpaCapabilityID'] = str(feature_uuid)
+ storage_capability['hpaFeature'] = 'localStorage'
+ storage_capability['hardwareArchitecture'] = 'generic'
+ storage_capability['version'] = 'v1'
+
+ storage_capability['attributes'] = []
+ storage_capability['attributes'].append({'hpa-attribute-key': 'diskSize',
+ 'hpa-attribute-value':{'value': str(flavor['disk']), 'unit':'GB'}})
+ storage_capability['attributes'].append({'hpa-attribute-key': 'swapMemSize',
+ 'hpa-attribute-value':{'value': str(flavor['swap']), 'unit':'MB'}})
+ storage_capability['attributes'].append({'hpa-attribute-key': 'ephemeralDiskSize',
+ 'hpa-attribute-value':{'value': str(flavor['OS-FLV-EXT-DATA:ephemeral']), 'unit':'GB'}})
+ return storage_capability
+
+ def _get_instruction_set_capabilities(self, extra_specs):
+ instruction_capability = {}
+ feature_uuid = uuid.uuid4()
+
+ if extra_specs.has_key('hw:capabilities:cpu_info:features'):
+ instruction_capability['hpaCapabilityID'] = str(feature_uuid)
+ instruction_capability['hpaFeature'] = 'instructionSetExtensions'
+ instruction_capability['hardwareArchitecture'] = 'Intel64'
+ instruction_capability['version'] = 'v1'
+
+ instruction_capability['attributes'] = []
+ instruction_capability['attributes'].append({'hpa-attribute-key': 'instructionSetExtensions',
+ 'hpa-attribute-value':{'value': str(extra_specs['hw:capabilities:cpu_info:features'])}})
+ return instruction_capability
+
+ def _get_pci_passthrough_capabilities(self, extra_specs):
+ instruction_capability = {}
+ feature_uuid = uuid.uuid4()
+
+ if extra_specs.has_key('pci_passthrough:alias'):
+ value1 = extra_specs['pci_passthrough:alias'].split(':')
+ value2 = value1[0].split('-')
+
+ instruction_capability['hpaCapabilityID'] = str(feature_uuid)
+ instruction_capability['hpaFeature'] = 'pciePassthrough'
+ instruction_capability['hardwareArchitecture'] = str(value2[2])
+ instruction_capability['version'] = 'v1'
+
+
+ instruction_capability['attributes'] = []
+ instruction_capability['attributes'].append({'hpa-attribute-key': 'pciCount',
+ 'hpa-attribute-value':{'value': str(value1[1])}})
+ instruction_capability['attributes'].append({'hpa-attribute-key': 'pciVendorId',
+ 'hpa-attribute-value':{'value': str(value2[3])}})
+ instruction_capability['attributes'].append({'hpa-attribute-key': 'pciDeviceId',
+ 'hpa-attribute-value':{'value': str(value2[4])}})
+
+ return instruction_capability