]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: provision grafana
authorPatrick Seidensal <pseidensal@suse.com>
Fri, 21 Feb 2020 11:42:10 +0000 (12:42 +0100)
committerPatrick Seidensal <pseidensal@suse.com>
Tue, 25 Feb 2020 12:17:02 +0000 (13:17 +0100)
Signed-off-by: Patrick Seidensal <pseidensal@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index 00dfc374ac0d50b20743809ecebcbafd98993708..3a37e4806b3d3ac04b8f77ed59767432f747f361 100644 (file)
@@ -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
index 36a9f7f1c677bde4e6089063d624888e9ac97862..fe2aa47d28dfc39f8a0f0327954523b0d2034286 100644 (file)
@@ -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)