diff --git a/vitrage/api/controllers/v1/alarm.py b/vitrage/api/controllers/v1/alarm.py index e0a56f7c7..4a590fca4 100755 --- a/vitrage/api/controllers/v1/alarm.py +++ b/vitrage/api/controllers/v1/alarm.py @@ -16,6 +16,7 @@ import json import pecan from oslo_log import log +from oslo_utils import encodeutils from oslo_utils.strutils import bool_from_string from osprofiler import profiler from pecan.core import abort @@ -52,8 +53,9 @@ class AlarmsController(RootRestController): try: return self._get_alarms(vitrage_id, all_tenants) except Exception as e: - LOG.exception('failed to get alarms %s', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to get alarms %s', to_unicode) + abort(404, to_unicode) @staticmethod def _get_alarms(vitrage_id=None, all_tenants=False): @@ -68,5 +70,6 @@ class AlarmsController(RootRestController): return alarms_list except Exception as e: - LOG.exception('failed to open file %s ', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to open file %s ', to_unicode) + abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/count.py b/vitrage/api/controllers/v1/count.py index d716f858f..0100c73d2 100755 --- a/vitrage/api/controllers/v1/count.py +++ b/vitrage/api/controllers/v1/count.py @@ -14,6 +14,7 @@ import json import pecan from oslo_log import log +from oslo_utils import encodeutils from oslo_utils.strutils import bool_from_string from pecan.core import abort @@ -50,5 +51,6 @@ class CountsController(RootRestController): return json.loads(alarm_counts_json) except Exception as e: - LOG.exception('failed to get alarm counts %s', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to get alarm counts %s', to_unicode) + abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/event.py b/vitrage/api/controllers/v1/event.py index 074888441..055cac55d 100644 --- a/vitrage/api/controllers/v1/event.py +++ b/vitrage/api/controllers/v1/event.py @@ -52,6 +52,6 @@ class EventController(RootRestController): event_type=event_type, details=details) except Exception as e: - LOG.exception('Failed to post an event %s', - encodeutils.exception_to_unicode(e)) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('Failed to post an event %s', to_unicode) + abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/rca.py b/vitrage/api/controllers/v1/rca.py index a3b53e786..1d49f453f 100644 --- a/vitrage/api/controllers/v1/rca.py +++ b/vitrage/api/controllers/v1/rca.py @@ -17,6 +17,7 @@ import json import pecan from oslo_log import log +from oslo_utils import encodeutils from oslo_utils.strutils import bool_from_string from osprofiler import profiler from pecan.core import abort @@ -59,5 +60,6 @@ class RCAController(RootRestController): return graph except Exception as e: - LOG.exception('failed to get rca %s ', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to get rca %s ', to_unicode) + abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/resource.py b/vitrage/api/controllers/v1/resource.py index a99b2fa0f..60e189cb6 100644 --- a/vitrage/api/controllers/v1/resource.py +++ b/vitrage/api/controllers/v1/resource.py @@ -13,6 +13,7 @@ import json import pecan from oslo_log import log +from oslo_utils import encodeutils from oslo_utils.strutils import bool_from_string from osprofiler import profiler from pecan.core import abort @@ -46,8 +47,9 @@ class ResourcesController(RootRestController): try: return self._get_resources(resource_type, all_tenants) except Exception as e: - LOG.exception('failed to list resources %s', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to list resources %s', to_unicode) + abort(404, to_unicode) @staticmethod def _get_resources(resource_type=None, all_tenants=False): @@ -63,8 +65,9 @@ class ResourcesController(RootRestController): resources = json.loads(resources_json)['resources'] return resources except Exception as e: - LOG.exception('failed to get resources %s ', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to get resources %s ', to_unicode) + abort(404, to_unicode) @pecan.expose('json') def get(self, vitrage_id): @@ -92,7 +95,7 @@ class ResourcesController(RootRestController): return json.loads(resource) except Exception as e: + to_unicode = encodeutils.exception_to_unicode(e) LOG.exception('failed to show resource with vitrage_id(%s),' - 'Exception: %s', - vitrage_id, e) - abort(404, str(e)) + 'Exception: %s', vitrage_id, to_unicode) + abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/template.py b/vitrage/api/controllers/v1/template.py index e75360c79..9482b4d17 100644 --- a/vitrage/api/controllers/v1/template.py +++ b/vitrage/api/controllers/v1/template.py @@ -15,6 +15,7 @@ import json import pecan from oslo_log import log +from oslo_utils import encodeutils from osprofiler import profiler from pecan.core import abort @@ -41,8 +42,9 @@ class TemplateController(RootRestController): try: return self._get_templates() except Exception as e: - LOG.exception('failed to get template list %s', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to get template list %s', to_unicode) + abort(404, to_unicode) @pecan.expose('json') def get(self, template_uuid): @@ -57,8 +59,11 @@ class TemplateController(RootRestController): try: return self._show_template(template_uuid) except Exception as e: - LOG.exception('failed to show template %s' % template_uuid, e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to show template %s --> %s', + template_uuid, + to_unicode) + abort(404, to_unicode) @pecan.expose('json') def post(self, **kwargs): @@ -75,8 +80,9 @@ class TemplateController(RootRestController): try: return self._validate(templates) except Exception as e: - LOG.exception('failed to validate template(s) %s', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to validate template(s) %s', to_unicode) + abort(404, to_unicode) @staticmethod def _get_templates(): @@ -88,8 +94,9 @@ class TemplateController(RootRestController): template_list = json.loads(templates_json)['templates_details'] return template_list except Exception as e: - LOG.exception('failed to get template list %s ', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to get template list %s ', to_unicode) + abort(404, to_unicode) @staticmethod def _show_template(template_uuid): @@ -102,8 +109,9 @@ class TemplateController(RootRestController): try: return json.loads(template_json) except Exception as e: - LOG.exception('failed to show template with uuid: %s ', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to show template with uuid: %s ', to_unicode) + abort(404, to_unicode) @staticmethod def _validate(templates): @@ -114,5 +122,6 @@ class TemplateController(RootRestController): try: return json.loads(result_json) except Exception as e: - LOG.exception('failed to open template file(s) %s ', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to open template file(s) %s ', to_unicode) + abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/topology.py b/vitrage/api/controllers/v1/topology.py index bbd8b3323..4de4ae04f 100644 --- a/vitrage/api/controllers/v1/topology.py +++ b/vitrage/api/controllers/v1/topology.py @@ -16,6 +16,7 @@ import json from oslo_log import log +from oslo_utils import encodeutils from oslo_utils.strutils import bool_from_string from osprofiler import profiler import pecan @@ -89,8 +90,9 @@ class TopologyController(RootRestController): return RootRestController.as_tree(graph, node_id) except Exception as e: - LOG.exception('failed to get topology %s ', e) - abort(404, str(e)) + to_unicode = encodeutils.exception_to_unicode(e) + LOG.exception('failed to get topology %s ', to_unicode) + abort(404, to_unicode) @staticmethod def _check_input_para(graph_type, depth, query, root, all_tenants):