]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/controllers/grafana.py
1 # -*- coding: utf-8 -*-
2 from __future__
import absolute_import
4 from . import (ApiController
, BaseController
, Endpoint
, ReadPermission
,
7 from ..exceptions
import DashboardException
8 from ..grafana
import GrafanaRestClient
, push_local_dashboards
9 from ..security
import Scope
10 from ..settings
import Settings
13 @ApiController('/grafana', Scope
.GRAFANA
)
14 class Grafana(BaseController
):
18 grafana_url
= mgr
.get_module_option('GRAFANA_API_URL')
19 grafana_frontend_url
= mgr
.get_module_option('GRAFANA_FRONTEND_API_URL')
20 if grafana_frontend_url
!= '' and grafana_url
== '':
23 url
= (mgr
.get_module_option('GRAFANA_FRONTEND_API_URL')
24 or mgr
.get_module_option('GRAFANA_API_URL')).rstrip('/')
25 response
= {'instance': url
}
30 def validation(self
, params
):
31 grafana
= GrafanaRestClient()
33 url
= str(Settings
.GRAFANA_API_URL
).rstrip('/') + \
34 '/api/dashboards/uid/' + params
35 response
= grafana
.url_validation(method
, url
)
38 @Endpoint(method
='POST')
43 response
['success'] = push_local_dashboards()
44 except Exception as e
: # pylint: disable=broad-except
45 raise DashboardException(