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