]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/cephadm: Provision alertmanager
authorKristoffer Grönlund <kgronlund@suse.com>
Wed, 26 Feb 2020 12:14:43 +0000 (13:14 +0100)
committerKristoffer Grönlund <kgronlund@suse.com>
Thu, 27 Feb 2020 08:58:16 +0000 (09:58 +0100)
Signed-off-by: Kristoffer Grönlund <kgronlund@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index 5cde47230d35c69b0e8e31244191cb0e954da7a0..1a37a1c91e791b57868b59b230b9707542569371 100644 (file)
@@ -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
index fe2aa47d28dfc39f8a0f0327954523b0d2034286..e1350c516ee43df95a1326c399585bc0d4797563 100644 (file)
@@ -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)