fix log exception parameters
Change-Id: I7575d66a16e7cba2758370f66d07557147ad1a62
This commit is contained in:
parent
526aae0a9c
commit
eddcfe8bc9
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user