From 94becbfde7234decd903a6152709818f07edf848 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristoffer=20Gr=C3=B6nlund?= Date: Wed, 26 Feb 2020 13:14:43 +0100 Subject: [PATCH] mgr/cephadm: Provision alertmanager MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristoffer Grönlund --- src/pybind/mgr/cephadm/module.py | 13 +++++++++++++ src/pybind/mgr/cephadm/tests/test_cephadm.py | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 5cde47230d3..1a37a1c91e7 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2373,6 +2373,19 @@ datasources: def _create_grafana(self, daemon_id, host): return self._create_daemon('grafana', daemon_id, host) + def add_alertmanager(self, spec): + # type: (orchestrator.ServiceSpec) -> AsyncCompletion + return self._add_daemon('alertmanager', spec, self._create_alertmanager) + + def apply_alertmanager(self, spec): + # type: (orchestrator.ServiceSpec) -> AsyncCompletion + return self._apply_service('alertmanager', spec, self._create_alertmanager) + + @async_map_completion + def _create_alertmanager(self, daemon_id, host): + return self._create_daemon('alertmanager', 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 fe2aa47d28d..e1350c516ee 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -374,6 +374,21 @@ class TestCephadm(object): [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) + @mock.patch("cephadm.module.CephadmOrchestrator._get_connection") + @mock.patch("cephadm.module.HostCache.save_host") + @mock.patch("cephadm.module.HostCache.rm_host") + def test_alertmanager(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_alertmanager(ServiceSpec(placement=ps)) + [out] = wait(cephadm_module, c) + match_glob(out, "Deployed alertmanager.* 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