From d7ba7ff30d0aef3fb4e5c7fcaafee34c5834489d Mon Sep 17 00:00:00 2001 From: Yun Huang Date: Sat, 28 Apr 2018 01:28:52 +0800 Subject: Fix HPA registration bug for Titanium Cloud Change-Id: Ia40640e3077ec6f4a60c2efd3ac4f244021dfb5a Issue-ID: MULTICLOUD-206 Signed-off-by: Yun Huang --- share/newton_base/registration/registration.py | 18 ++++---- .../registration/views/registration.py | 48 +++++++++++----------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/share/newton_base/registration/registration.py b/share/newton_base/registration/registration.py index ecf613b8..726eb691 100644 --- a/share/newton_base/registration/registration.py +++ b/share/newton_base/registration/registration.py @@ -42,11 +42,11 @@ class Registry(APIView): service = {'service_type': service_type, 'interface': 'public', 'region_id': viminfo['cloud_region_id']} - logger.info("making request with URI:%s" % resource_url) + self._logger.info("making request with URI:%s" % resource_url) resp = session.get(resource_url, endpoint_filter=service) - logger.info("request returns with status %s" % resp.status_code) + self._logger.info("request returns with status %s" % resp.status_code) if resp.status_code == status.HTTP_200_OK: - logger.debug("with content:%s" % resp.json()) + self._logger.debug("with content:%s" % resp.json()) pass content = resp.json() @@ -232,11 +232,11 @@ class Registry(APIView): service = {'service_type': "image", 'interface': 'public', 'region_id': viminfo['cloud_region_id']} - logger.info("making request with URI:%s" % req_resource) + self._logger.info("making request with URI:%s" % req_resource) resp = session.get(req_resource, endpoint_filter=service) - logger.info("request returns with status %s" % resp.status_code) + self._logger.info("request returns with status %s" % resp.status_code) if resp.status_code == status.HTTP_200_OK: - logger.debug("with content:%s" % resp.json()) + self._logger.debug("with content:%s" % resp.json()) pass content = resp.json() @@ -275,11 +275,11 @@ class Registry(APIView): service = {'service_type': "compute", 'interface': 'public', 'region_id': viminfo['cloud_region_id']} - logger.info("making request with URI:%s" % req_resource) + self._logger.info("making request with URI:%s" % req_resource) resp = session.get(req_resource, endpoint_filter=service) - logger.info("request returns with status %s" % resp.status_code) + self._logger.info("request returns with status %s" % resp.status_code) if resp.status_code == status.HTTP_200_OK: - logger.debug("with content:%s" % resp.json()) + self._logger.debug("with content:%s" % resp.json()) pass content = resp.json() if resp.status_code != status.HTTP_200_OK and not content[0]: diff --git a/windriver/titanium_cloud/registration/views/registration.py b/windriver/titanium_cloud/registration/views/registration.py index e7b56584..a597dcca 100644 --- a/windriver/titanium_cloud/registration/views/registration.py +++ b/windriver/titanium_cloud/registration/views/registration.py @@ -150,9 +150,9 @@ class Registry(newton_registration.Registry): basic_capability['hpa-feature-attributes'] = [] basic_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numVirtualCpu', - 'hpa-attribute-value':{'value': str(flavor['vcpus']) }}) + 'hpa-attribute-value': str({'value': str(flavor['vcpus']) })}) basic_capability['hpa-feature-attributes'].append({'hpa-attribute-key':'virtualMemSize', - 'hpa-attribute-value': {'value':str(flavor['ram']), 'unit':'MB'}}) + 'hpa-attribute-value': str({'value':str(flavor['ram']), 'unit':'MB'})}) return basic_capability @@ -169,10 +169,10 @@ 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':{'value': str(extra_specs['hw:cpu_thread_policy'])}}) + 'hpa-attribute-value': str({'value': str(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': {'value':str(extra_specs['hw:cpu_policy'])}}) + 'hpa-attribute-value': str({'value':str(extra_specs['hw:cpu_policy'])})}) return cpupining_capability @@ -189,13 +189,13 @@ 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':{'value': str(extra_specs['hw:cpu_sockets'])}}) + 'hpa-attribute-value': str({'value': str(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':{'value': str(extra_specs['hw:cpu_cores'])}}) + 'hpa-attribute-value': str({'value': str(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':{'value': str(extra_specs['hw:cpu_threads'])}}) + 'hpa-attribute-value': str({'value': str(extra_specs['hw:cpu_threads'])})}) return cputopology_capability @@ -212,18 +212,18 @@ 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':{'value': '2', - 'unit': 'MB'}}) + 'hpa-attribute-value': str({'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':{'value': '4', - 'unit': 'KB'}}) + 'hpa-attribute-value': str({'value': '4', + 'unit': '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':{'value': str(extra_specs['hw:mem_page_size']), - 'unit': 'KB'}}) + 'hpa-attribute-value': str({'value': str(extra_specs['hw:mem_page_size']), + 'unit': 'KB'})}) return hugepages_capability def _get_numa_capabilities(self, extra_specs): @@ -238,7 +238,7 @@ class Registry(newton_registration.Registry): numa_capability['hpa-feature-attributes'] = [] numa_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'numaNodes', - 'hpa-attribute-value':{'value': str(extra_specs['hw:numa_nodes'])}}) + 'hpa-attribute-value': str({'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 @@ -248,9 +248,9 @@ 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':{'value': str(extra_specs[numa_cpu_node])}}) + 'hpa-attribute-value': str({'value': str(extra_specs[numa_cpu_node])})}) numa_capability['hpa-feature-attributes'].append({'hpa-attribute-key': numamem_key, - 'hpa-attribute-value':{'value': str(extra_specs[numa_mem_node]),'unit':'MB'}}) + 'hpa-attribute-value': str({'value': str(extra_specs[numa_mem_node]),'unit':'MB'})}) return numa_capability @@ -265,11 +265,11 @@ class Registry(newton_registration.Registry): storage_capability['hpa-feature-attributes'] = [] storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'diskSize', - 'hpa-attribute-value':{'value': str(flavor['disk']), 'unit':'GB'}}) + 'hpa-attribute-value': str({'value': str(flavor['disk']), 'unit':'GB'})}) storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'swapMemSize', - 'hpa-attribute-value':{'value': str(flavor['swap']), 'unit':'MB'}}) + 'hpa-attribute-value': str({'value': str(flavor['swap']), 'unit':'MB'})}) storage_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'ephemeralDiskSize', - 'hpa-attribute-value':{'value': str(flavor['OS-FLV-EXT-DATA:ephemeral']), 'unit':'GB'}}) + 'hpa-attribute-value': str({'value': str(flavor['OS-FLV-EXT-DATA:ephemeral']), 'unit':'GB'})}) return storage_capability def _get_instruction_set_capabilities(self, extra_specs): @@ -284,7 +284,7 @@ class Registry(newton_registration.Registry): instruction_capability['hpa-feature-attributes'] = [] instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'instructionSetExtensions', - 'hpa-attribute-value':{'value': str(extra_specs['hw:capabilities:cpu_info:features'])}}) + 'hpa-attribute-value': str({'value': str(extra_specs['hw:capabilities:cpu_info:features'])})}) return instruction_capability def _get_pci_passthrough_capabilities(self, extra_specs): @@ -303,11 +303,11 @@ class Registry(newton_registration.Registry): instruction_capability['hpa-feature-attributes'] = [] instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciCount', - 'hpa-attribute-value':{'value': str(value1[1])}}) + 'hpa-attribute-value': str({'value': str(value1[1])})}) instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciVendorId', - 'hpa-attribute-value':{'value': str(value2[3])}}) + 'hpa-attribute-value': str({'value': str(value2[3])})}) instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'pciDeviceId', - 'hpa-attribute-value':{'value': str(value2[4])}}) + 'hpa-attribute-value': str({'value': str(value2[4])})}) return instruction_capability @@ -322,5 +322,5 @@ class Registry(newton_registration.Registry): instruction_capability['hpa-feature-attributes'] = [] instruction_capability['hpa-feature-attributes'].append({'hpa-attribute-key': 'dataProcessingAccelerationLibrary', - 'hpa-attribute-value':{'value': str('v17.02')}}) + 'hpa-attribute-value': str({'value': str('v17.02')})}) return instruction_capability -- cgit 1.2.3-korg