]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: point dashboard at grafana automatically 33700/head
authorSage Weil <sage@redhat.com>
Tue, 3 Mar 2020 16:15:28 +0000 (10:15 -0600)
committerSage Weil <sage@redhat.com>
Fri, 6 Mar 2020 17:30:18 +0000 (11:30 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py

index 8c43daff2afedadfc294736a0f2340ae743e41d6..3fe55d0ac883b9768ad305a8386be1c56531b463 100644 (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):
         """