From 5c36aa0c07f14fb36922d844621e80e0264af4bf Mon Sep 17 00:00:00 2001 From: Patrick Seidensal Date: Fri, 21 Feb 2020 12:42:10 +0100 Subject: [PATCH] mgr/cephadm: provision grafana Signed-off-by: Patrick Seidensal --- src/pybind/mgr/cephadm/module.py | 12 ++++++++++++ src/pybind/mgr/cephadm/tests/test_cephadm.py | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 00dfc374ac0..3a37e4806b3 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2245,6 +2245,18 @@ scrape_configs: def _create_node_exporter(self, daemon_id, host): return self._create_daemon('node-exporter', daemon_id, host) + def add_grafana(self, spec): + # type: (orchestrator.ServiceSpec) -> AsyncCompletion + return self._add_daemon('grafana', spec, self._create_grafana) + + def apply_grafana(self, spec): + # type: (orchestrator.ServiceSpec) -> AsyncCompletion + return self._apply_service('grafana', spec, self.add_grafana) + + @async_map_completion + def _create_grafana(self, daemon_id, host): + return self._create_daemon('grafana', daemon_id, host) + def _get_container_image_id(self, image_name): # pick a random host... host = None diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 36a9f7f1c67..fe2aa47d28d 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -359,6 +359,21 @@ class TestCephadm(object): [out] = wait(cephadm_module, c) match_glob(out, "Deployed node-exporter.* on host 'test'") + @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}')) + @mock.patch("cephadm.module.CephadmOrchestrator.send_command") + @mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command) + @mock.patch("cephadm.module.CephadmOrchestrator._get_connection") + @mock.patch("cephadm.module.HostCache.save_host") + @mock.patch("cephadm.module.HostCache.rm_host") + def test_grafana(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): + # type: (mock.Mock, mock.Mock, mock.Mock, mock.Mock, CephadmOrchestrator) -> None + with self._with_host(cephadm_module, 'test'): + ps = PlacementSpec(hosts=['test'], count=1) + + c = cephadm_module.add_grafana(ServiceSpec(placement=ps)) + [out] = wait(cephadm_module, c) + match_glob(out, "Deployed grafana.* on host 'test'") + @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}')) @mock.patch("cephadm.module.CephadmOrchestrator.send_command") @mock.patch("cephadm.module.CephadmOrchestrator.mon_command", mon_command) -- 2.39.5