From: Sage Weil Date: Tue, 3 Mar 2020 16:15:28 +0000 (-0600) Subject: mgr/cephadm: point dashboard at grafana automatically X-Git-Tag: v15.1.1~80^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33700%2Fhead;p=ceph.git mgr/cephadm: point dashboard at grafana automatically Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 8c43daff2afe..3fe55d0ac883 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2241,7 +2241,11 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): def _refresh_configs(self): daemons = self.cache.get_daemons() + grafanas = [] # type: List[orchestrator.DaemonDescription] for dd in daemons: + if dd.daemon_type == 'grafana': + # put running instances at the front of the list + grafanas.insert(0, dd) deps = self._calc_daemon_deps(dd.daemon_type, dd.daemon_id) last_deps, last_config = self.cache.get_daemon_last_config_deps( dd.hostname, dd.name()) @@ -2255,6 +2259,23 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): self._create_daemon(dd.daemon_type, dd.daemon_id, dd.hostname, reconfig=True) + # make sure the dashboard [does not] references grafana + try: + current_url = self.get_module_option_ex('dashboard', + 'GRAFANA_API_URL') + if grafanas: + host = grafanas[0].hostname + url = 'https://%s:3000' % (self.inventory[host].get('addr', + host)) + if current_url != url: + self.log.info('Setting dashboard grafana config to %s' % url) + self.set_module_option_ex('dashboard', 'GRAFANA_API_URL', + url) + # FIXME: is it a signed cert?? + except Exception as e: + self.log.debug('got exception fetching dashboard grafana state: %s', + e) + def _add_daemon(self, daemon_type, spec, create_func, config_func=None): """