summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--windriver/titanium_cloud/registration/tests/test_registration.py10
-rw-r--r--windriver/titanium_cloud/registration/views/registration.py109
-rw-r--r--windriver/titanium_cloud/resource/views/capacity.py16
3 files changed, 132 insertions, 3 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..bdf89a15 100644
--- a/windriver/titanium_cloud/registration/views/registration.py
+++ b/windriver/titanium_cloud/registration/views/registration.py
@@ -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
diff --git a/windriver/titanium_cloud/resource/views/capacity.py b/windriver/titanium_cloud/resource/views/capacity.py
index d73cc0fb..0d44d0c4 100644
--- a/windriver/titanium_cloud/resource/views/capacity.py
+++ b/windriver/titanium_cloud/resource/views/capacity.py
@@ -38,8 +38,8 @@ class CapacityCheck(APIView):
self._logger = logger
def post(self, request, vimid=""):
- self._logger.info("CapacityCheck--post::vimid, data> %s, %s" % (vimid, request.data))
- self._logger.debug("CapacityCheck--post::META> %s" % request.META)
+ self._logger.info("vimid, data> %s, %s" % (vimid, request.data))
+ self._logger.debug("META> %s" % request.META)
hasEnoughResource = False
try :
@@ -58,22 +58,31 @@ class CapacityCheck(APIView):
#get limit for this tenant
req_resouce = "/limits"
+ self._logger.info("check limits> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check limits> status:%s" % resp.status_code)
content = resp.json()
compute_limits = content['limits']['absolute']
+ self._logger.debug("check limits> resp data:%s" % content)
#get total resource of this cloud region
req_resouce = "/os-hypervisors/statistics"
+ self._logger.info("check os-hypervisors statistics> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check os-hypervisors statistics> status:%s" % resp.status_code)
content = resp.json()
hypervisor_statistics = content['hypervisor_statistics']
+ self._logger.debug("check os-hypervisors statistics> resp data:%s" % content)
#get storage limit for this tenant
service['service_type'] = 'volumev2'
req_resouce = "/limits"
+ self._logger.info("check volumev2 limits> URI:%s" % req_resouce)
resp = sess.get(req_resouce, endpoint_filter=service)
+ self._logger.info("check volumev2> status:%s" % resp.status_code)
content = resp.json()
storage_limits = content['limits']['absolute']
+ self._logger.debug("check volumev2> resp data:%s" % content)
# compute actual available resource for this tenant
remainVCPU = compute_limits['maxTotalCores'] - compute_limits['totalCoresUsed']
@@ -102,8 +111,11 @@ class CapacityCheck(APIView):
else:
hasEnoughResource = True
+ self._logger.info("RESP with data> result:%s" % hasEnoughResource)
return Response(data={'result': hasEnoughResource}, status=status.HTTP_200_OK)
except VimDriverNewtonException as e:
+ self._logger.error("Plugin exception> status:%s,error:%s"
+ % (e.status_code, e.content))
return Response(data={'result': hasEnoughResource,'error': e.content}, status=e.status_code)
except HttpError as e:
self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))