From 2b69e0e245ff4cf81d9f41e5e05947f6aef0004f Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Tue, 17 Jan 2017 12:03:52 +0100 Subject: [PATCH] Don't try to store i18n messages Serialize i18n messages before they reach the sql layer, to prevent an issue with python3. This also fixes an issue with map behavior. Change-Id: Ib934f5ac27cc1983a12c73f38927a116d50a5e6e --- heat/engine/resource.py | 4 ++-- heat/engine/service.py | 12 +++++++----- heat/engine/service_software_config.py | 4 ++-- heat/engine/stack.py | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 587b36672d..613cefe590 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -1736,7 +1736,7 @@ class Resource(object): try: rs = {'action': self.action, 'status': self.status, - 'status_reason': self.status_reason, + 'status_reason': str(self.status_reason), 'stack_id': self.stack.id, 'physical_resource_id': self.resource_id, 'name': self.name, @@ -1777,7 +1777,7 @@ class Resource(object): data = { 'action': self.action, 'status': self.status, - 'status_reason': reason, + 'status_reason': str(reason), 'stack_id': self.stack.id, 'updated_at': self.updated_time, 'needed_by': self.needed_by, diff --git a/heat/engine/service.py b/heat/engine/service.py index 102e92c715..ab47c37771 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -1041,11 +1041,13 @@ class EngineService(service.ServiceBase): return api.format_stack_resource(current.resources.get(k)) return { - 'unchanged': map(fmt_updated_res, act.get('unchanged', [])), - 'updated': map(fmt_current_res, act.get('updated', [])), - 'replaced': map(fmt_updated_res, act.get('replaced', [])), - 'added': map(fmt_updated_res, act.get('added', [])), - 'deleted': map(fmt_current_res, act.get('deleted', [])), + 'unchanged': list( + map(fmt_updated_res, act.get('unchanged', []))), + 'updated': list(map(fmt_current_res, act.get('updated', []))), + 'replaced': list( + map(fmt_updated_res, act.get('replaced', []))), + 'added': list(map(fmt_updated_res, act.get('added', []))), + 'deleted': list(map(fmt_current_res, act.get('deleted', []))), } updated_stack.id = current_stack.id diff --git a/heat/engine/service_software_config.py b/heat/engine/service_software_config.py index 72801e0254..6c11f095cb 100644 --- a/heat/engine/service_software_config.py +++ b/heat/engine/service_software_config.py @@ -256,7 +256,7 @@ class SoftwareConfigService(object): 'stack_user_project_id': stack_user_project_id, 'action': action, 'status': status, - 'status_reason': status_reason}) + 'status_reason': str(status_reason)}) self._push_metadata_software_deployments( cnxt, server_id, stack_user_project_id) return api.format_software_deployment(sd) @@ -337,7 +337,7 @@ class SoftwareConfigService(object): if status: update_data['status'] = status if status_reason: - update_data['status_reason'] = status_reason + update_data['status_reason'] = str(status_reason) if updated_at: update_data['updated_at'] = timeutils.normalize_time( timeutils.parse_isotime(updated_at)) diff --git a/heat/engine/stack.py b/heat/engine/stack.py index afd8d9e80e..930a4278e6 100644 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -607,7 +607,7 @@ class Stack(collections.Mapping): stack.update({ 'action': self.action, 'status': self.status, - 'status_reason': self.status_reason}) + 'status_reason': str(self.status_reason)}) if only_db: stack['parent_resource_name'] = self.parent_resource_name @@ -951,7 +951,7 @@ class Stack(collections.Mapping): if stack is not None: values = {'action': self.action, 'status': self.status, - 'status_reason': self.status_reason} + 'status_reason': str(self.status_reason)} self._send_notification_and_add_event() if self.convergence: # do things differently for convergence @@ -983,7 +983,7 @@ class Stack(collections.Mapping): if stack is not None: values = {'action': self.action, 'status': self.status, - 'status_reason': self.status_reason} + 'status_reason': str(self.status_reason)} self._send_notification_and_add_event() stack.persist_state_and_release_lock(self.context, self.id, engine_id, values)