diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-05-16 08:53:33 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-05-16 08:53:33 +0800 |
commit | be067e5c7c253ad4509aa173d4fc5782209fe288 (patch) | |
tree | 5430c436b25ca1c813cbc54ba56ae99375922590 /windriver/titanium_cloud/registration/views/registration.py | |
parent | 036d96e7d532393631e2dc92b1ad6ea3b0eb1e86 (diff) |
Fix hpa-attribute-value string format
Change-Id: I476a189c621b48a8d48becce50c9c6fe1102318c
Issue-ID: MULTICLOUD-232
Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud/registration/views/registration.py')
-rw-r--r-- | windriver/titanium_cloud/registration/views/registration.py | 87 |
1 files changed, 63 insertions, 24 deletions
diff --git a/windriver/titanium_cloud/registration/views/registration.py b/windriver/titanium_cloud/registration/views/registration.py index 36d0e1d0..3f1e5790 100644 --- a/windriver/titanium_cloud/registration/views/registration.py +++ b/windriver/titanium_cloud/registration/views/registration.py @@ -150,9 +150,13 @@ class Registry(newton_registration.Registry): basic_capability['hpa-feature-attributes'] = [] basic_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numVirtualCpu', - 'hpa-attribute-value': str({'value': str(flavor['vcpus']) })}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(flavor['vcpus']) + }) basic_capability['hpa-feature-attributes'].append({'hpa-attribute-key':'virtualMemSize', - 'hpa-attribute-value': str({'value':str(flavor['ram']), 'unit':'MB'})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['ram'],"MB") + }) return basic_capability @@ -169,10 +173,14 @@ class Registry(newton_registration.Registry): cpupining_capability['hpa-feature-attributes'] = [] if extra_specs.has_key('hw:cpu_thread_policy'): cpupining_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'logicalCpuThreadPinningPolicy', - 'hpa-attribute-value': str({'value': str(extra_specs['hw:cpu_thread_policy'])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_thread_policy']) + }) if extra_specs.has_key('hw:cpu_policy'): cpupining_capability['hpa-feature-attributes'].append({'hpa-attribute-key':'logicalCpuPinningPolicy', - 'hpa-attribute-value': str({'value':str(extra_specs['hw:cpu_policy'])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_policy']) + }) return cpupining_capability @@ -189,13 +197,19 @@ class Registry(newton_registration.Registry): cputopology_capability['hpa-feature-attributes'] = [] if extra_specs.has_key('hw:cpu_sockets'): cputopology_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numCpuSockets', - 'hpa-attribute-value': str({'value': str(extra_specs['hw:cpu_sockets'])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_sockets']) + }) if extra_specs.has_key('hw:cpu_cores'): cputopology_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numCpuCores', - 'hpa-attribute-value': str({'value': str(extra_specs['hw:cpu_cores'])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_cores']) + }) if extra_specs.has_key('hw:cpu_threads'): cputopology_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numCpuThreads', - 'hpa-attribute-value': str({'value': str(extra_specs['hw:cpu_threads'])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:cpu_threads']) + }) return cputopology_capability @@ -212,18 +226,21 @@ class Registry(newton_registration.Registry): 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': str({'value': '2', - 'unit': 'MB'})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(2,"MB") + }) elif extra_specs['hw:mem_page_size'] == 'small': hugepages_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'memoryPageSize', - 'hpa-attribute-value': str({'value': '4', - 'unit': 'KB'})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(4,"KB") + }) elif extra_specs['hw:mem_page_size'] == 'any': self._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': str({'value': str(extra_specs['hw:mem_page_size']), - 'unit': 'KB'})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(extra_specs['hw:mem_page_size'],"KB") + }) return hugepages_capability def _get_numa_capabilities(self, extra_specs): @@ -238,7 +255,9 @@ class Registry(newton_registration.Registry): numa_capability['hpa-feature-attributes'] = [] numa_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numaNodes', - 'hpa-attribute-value': str({'value': str(extra_specs['hw:numa_nodes'])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:numa_nodes'] or 0) + }) for num in range(0, int(extra_specs['hw:numa_nodes'])): numa_cpu_node = "hw:numa_cpus.%s" % num @@ -248,9 +267,13 @@ class Registry(newton_registration.Registry): if extra_specs.has_key(numa_cpu_node) and extra_specs.has_key(numa_mem_node): numa_capability['hpa-feature-attributes'].append({'hpa-attribute-key': numacpu_key, - 'hpa-attribute-value': str({'value': str(extra_specs[numa_cpu_node])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(extra_specs[numa_cpu_node]) + }) numa_capability['hpa-feature-attributes'].append({'hpa-attribute-key': numamem_key, - 'hpa-attribute-value': str({'value': str(extra_specs[numa_mem_node]),'unit':'MB'})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(extra_specs[numa_mem_node],"MB") + }) return numa_capability @@ -265,11 +288,17 @@ class Registry(newton_registration.Registry): storage_capability['hpa-feature-attributes'] = [] storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'diskSize', - 'hpa-attribute-value': str({'value': str(flavor['disk']), 'unit':'GB'})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['disk'] or 0,"GB") + }) storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'swapMemSize', - 'hpa-attribute-value': str({'value': str(flavor['swap']), 'unit':'MB'})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['swap'] or 0,"MB") + }) storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'ephemeralDiskSize', - 'hpa-attribute-value': str({'value': str(flavor['OS-FLV-EXT-DATA:ephemeral']), 'unit':'GB'})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\",\"unit\":\"{1}\"}}'.format(flavor['OS-FLV-EXT-DATA:ephemeral'] or 0,"GB") + }) return storage_capability def _get_instruction_set_capabilities(self, extra_specs): @@ -284,7 +313,9 @@ class Registry(newton_registration.Registry): instruction_capability['hpa-feature-attributes'] = [] instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'instructionSetExtensions', - 'hpa-attribute-value': str({'value': str(extra_specs['hw:capabilities:cpu_info:features'])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(extra_specs['hw:capabilities:cpu_info:features']) + }) return instruction_capability def _get_pci_passthrough_capabilities(self, extra_specs): @@ -303,11 +334,17 @@ class Registry(newton_registration.Registry): instruction_capability['hpa-feature-attributes'] = [] instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciCount', - 'hpa-attribute-value': str({'value': str(value1[1])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(value1[1]) + }) instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciVendorId', - 'hpa-attribute-value': str({'value': str(value2[3])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(value2[3]) + }) instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciDeviceId', - 'hpa-attribute-value': str({'value': str(value2[4])})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format(value2[4]) + }) return instruction_capability @@ -322,5 +359,7 @@ class Registry(newton_registration.Registry): instruction_capability['hpa-feature-attributes'] = [] instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'dataProcessingAccelerationLibrary', - 'hpa-attribute-value': str({'value': str('v17.02')})}) + 'hpa-attribute-value': + '{{\"value\":\"{0}\"}}'.format("v17.02") + }) return instruction_capability |