From cab0d3156bdfa15a869e95a6618fb30ac53cf5c4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 18 Dec 2019 10:02:31 -0600 Subject: [PATCH] mgr/cephadm: check-host on 'host add' Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/module.py | 5 +++++ src/pybind/mgr/cephadm/tests/test_cephadm.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index b68b52c91d027..bc34e77156497 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -685,6 +685,11 @@ class CephadmOrchestrator(MgrModule, orchestrator.Orchestrator): :param host: host name """ + out, err, code = self._run_cephadm(host, '', 'check-host', [], + error_ok=True, no_fsid=True) + if code: + raise OrchestratorError('New host %s failed check: %s' % (host, err)) + self.inventory[host] = {} self._save_inventory() self.inventory_cache[host] = orchestrator.OutdatableData() diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 76da7561ebc0c..5d45cef90cabb 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -73,7 +73,9 @@ class TestCephadm(object): assert new_mon.startswith('mon.') assert new_mon != 'mon.a' - def test_host(self, cephadm_module): + @mock.patch("cephadm.module.CephadmOrchestrator._get_connection") + @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('[]')) + def test_host(self, _get_connection, cephadm_module): with self._with_host(cephadm_module, 'test'): assert self._wait(cephadm_module, cephadm_module.get_hosts()) == [InventoryNode('test')] c = cephadm_module.get_hosts() -- 2.39.5