]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/controllers/grafana.py
import ceph quincy 17.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / grafana.py
index d5c9b19f8087830133c5a5ae493ba134462578f8..79a6806715fd79ca115b44471d7e391a265bf4ce 100644 (file)
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 from .. import mgr
-from ..exceptions import DashboardException
 from ..grafana import GrafanaRestClient, push_local_dashboards
 from ..security import Scope
+from ..services.exception import handle_error
 from ..settings import Settings
 from . import APIDoc, APIRouter, BaseController, Endpoint, EndpointDoc, \
     ReadPermission, UpdatePermission
@@ -31,6 +31,7 @@ class Grafana(BaseController):
 
     @Endpoint()
     @ReadPermission
+    @handle_error('grafana')
     def validation(self, params):
         grafana = GrafanaRestClient()
         method = 'GET'
@@ -41,14 +42,8 @@ class Grafana(BaseController):
 
     @Endpoint(method='POST')
     @UpdatePermission
+    @handle_error('grafana', 500)
     def dashboards(self):
         response = dict()
-        try:
-            response['success'] = push_local_dashboards()
-        except Exception as e:  # pylint: disable=broad-except
-            raise DashboardException(
-                msg=str(e),
-                component='grafana',
-                http_status_code=500,
-            )
+        response['success'] = push_local_dashboards()
         return response