mgr/cephadm: point dashboard at grafana automatically

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2020-03-03 10:15:28 -06:00
parent 739c23da1b
commit b2384e0291

View File

@ -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):
"""