- def _get_cpupinning_capabilities(self, extra_specs):
- cpupining_capability = {}
- feature_uuid = uuid.uuid4()
-
- if (extra_specs.get('hw:cpu_policy') or
- extra_specs.get('hw:cpu_thread_policy')):
- cpupining_capability['hpa-capability-id'] = str(feature_uuid)
- cpupining_capability['hpa-feature'] = 'cpuPinning'
- cpupining_capability['architecture'] = 'generic'
- cpupining_capability['hpa-version'] = 'v1'
-
- cpupining_capability['hpa-feature-attributes'] = []
- if extra_specs.get('hw:cpu_thread_policy'):
- cpupining_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'logicalCpuThreadPinningPolicy',
- 'hpa-attribute-value': json.dumps({'value': str(
- extra_specs['hw:cpu_thread_policy'])})})
- if extra_specs.get('hw:cpu_policy'):
- cpupining_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'logicalCpuPinningPolicy',
- 'hpa-attribute-value': json.dumps({'value': str(
- extra_specs['hw:cpu_policy'])})})
-
- return cpupining_capability
-
- def _get_cputopology_capabilities(self, extra_specs):
- cputopology_capability = {}
- feature_uuid = uuid.uuid4()
-
- if (extra_specs.get('hw:cpu_sockets') or
- extra_specs.get('hw:cpu_cores') or
- extra_specs.get('hw:cpu_threads')):
- cputopology_capability['hpa-capability-id'] = str(feature_uuid)
- cputopology_capability['hpa-feature'] = 'cpuTopology'
- cputopology_capability['architecture'] = 'generic'
- cputopology_capability['hpa-version'] = 'v1'
-
- cputopology_capability['hpa-feature-attributes'] = []
- if extra_specs.get('hw:cpu_sockets'):
- cputopology_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'numCpuSockets',
- 'hpa-attribute-value': json.dumps({'value': str(
- extra_specs['hw:cpu_sockets'])})})
- if extra_specs.get('hw:cpu_cores'):
- cputopology_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'numCpuCores',
- 'hpa-attribute-value': json.dumps({'value': str(
- extra_specs['hw:cpu_cores'])})})
- if extra_specs.get('hw:cpu_threads'):
- cputopology_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'numCpuThreads',
- 'hpa-attribute-value': json.dumps({'value': str(
- extra_specs['hw:cpu_threads'])})})
-
- return cputopology_capability
-
- def _get_hugepages_capabilities(self, extra_specs):
- hugepages_capability = {}
- feature_uuid = uuid.uuid4()
-
- if extra_specs.get('hw:mem_page_size'):
- hugepages_capability['hpa-capability-id'] = str(feature_uuid)
- hugepages_capability['hpa-feature'] = 'hugePages'
- hugepages_capability['architecture'] = 'generic'
- hugepages_capability['hpa-version'] = 'v1'
-
- hugepages_capability['hpa-feature-attributes'] = []
- if extra_specs['hw:mem_page_size'] == 'large':
- hugepages_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'memoryPageSize',
- 'hpa-attribute-value': json.dumps(
- {'value': '2', 'unit': 'MB'})})
- elif extra_specs['hw:mem_page_size'] == 'small':
- hugepages_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'memoryPageSize',
- 'hpa-attribute-value': json.dumps(
- {'value': '4', 'unit': 'KB'})})
- elif extra_specs['hw:mem_page_size'] == 'any':
- logger.info("Currently HPA feature memoryPageSize "
- "did not support 'any' page!!")
- else:
- hugepages_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'memoryPageSize',
- 'hpa-attribute-value': json.dumps({'value': str(
- extra_specs['hw:mem_page_size']), 'unit': 'KB'})
- })
-
- return hugepages_capability
-
- def _get_numa_capabilities(self, extra_specs):
- numa_capability = {}
- feature_uuid = uuid.uuid4()
-
- if extra_specs.get('hw:numa_nodes'):
- numa_capability['hpa-capability-id'] = str(feature_uuid)
- numa_capability['hpa-feature'] = 'numa'
- numa_capability['architecture'] = 'generic'
- numa_capability['hpa-version'] = 'v1'
-
- numa_capability['hpa-feature-attributes'] = []
- numa_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': 'numaNodes',
- 'hpa-attribute-value': json.dumps({'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.get(numa_cpu_node) and
- extra_specs.get(numa_mem_node)):
- numa_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': numacpu_key,
- 'hpa-attribute-value': json.dumps({'value': str(
- extra_specs[numa_cpu_node])})
- })
- numa_capability['hpa-feature-attributes'].append({
- 'hpa-attribute-key': numamem_key,
- 'hpa-attribute-value': json.dumps({'value': str(
- extra_specs[numa_mem_node]), 'unit': 'MB'})
- })
-
- return numa_capability
-