From a6f36938edd7c25a2ed72605084d39625238e92e Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 6 Jan 2021 14:48:04 +0100 Subject: [PATCH] mgr/cephadm: move _deploy_cephadm_binary to serve.py Signed-off-by: Sebastian Wagner --- src/pybind/mgr/cephadm/module.py | 11 ----------- src/pybind/mgr/cephadm/serve.py | 13 ++++++++++++- src/pybind/mgr/cephadm/tests/test_cephadm.py | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 9ce330d33ab68..8a22a42e1dc9c 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1896,17 +1896,6 @@ To check that the host is reachable: deps.append(dd.name()) return sorted(deps) - def _deploy_cephadm_binary(self, host: str) -> bool: - # Use tee (from coreutils) to create a copy of cephadm on the target machine - self.log.info(f"Deploying cephadm binary to {host}") - with self._remote_connection(host) as tpl: - conn, _connr = tpl - _out, _err, code = remoto.process.check( - conn, - ['tee', '-', '/var/lib/ceph/{}/cephadm'.format(self._cluster_fsid)], - stdin=self._cephadm.encode('utf-8')) - return code == 0 - @forall_hosts def _remove_daemons(self, name: str, host: str) -> str: return CephadmServe(self)._remove_daemon(name, host) diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 0974728ac3d9b..cfd40dce4dbc0 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -757,7 +757,7 @@ class CephadmServe: if daemon_spec.daemon_type == 'cephadm-exporter': if not reconfig: assert daemon_spec.host - deploy_ok = self.mgr._deploy_cephadm_binary(daemon_spec.host) + deploy_ok = self._deploy_cephadm_binary(daemon_spec.host) if not deploy_ok: msg = f"Unable to deploy the cephadm binary to {daemon_spec.host}" self.log.warning(msg) @@ -1012,3 +1012,14 @@ class CephadmServe: if code: return f"Host {host} failed to login to {url} as {username} with given password" return None + + def _deploy_cephadm_binary(self, host: str) -> bool: + # Use tee (from coreutils) to create a copy of cephadm on the target machine + self.log.info(f"Deploying cephadm binary to {host}") + with self.mgr._remote_connection(host) as tpl: + conn, _connr = tpl + _out, _err, code = remoto.process.check( + conn, + ['tee', '-', '/var/lib/ceph/{}/cephadm'.format(self.mgr._cluster_fsid)], + stdin=self.mgr._cephadm.encode('utf-8')) + return code == 0 diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index c296ccdbadaaf..c8a9715983e52 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -576,7 +576,7 @@ class TestCephadm(object): (ServiceSpec('cephadm-exporter'), CephadmOrchestrator.add_cephadm_exporter), ] ) - @mock.patch("cephadm.module.CephadmOrchestrator._deploy_cephadm_binary", _deploy_cephadm_binary('test')) + @mock.patch("cephadm.serve.CephadmServe._deploy_cephadm_binary", _deploy_cephadm_binary('test')) @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}')) @mock.patch("cephadm.services.cephadmservice.RgwService.create_realm_zonegroup_zone", lambda _, __, ___: None) def test_daemon_add(self, spec: ServiceSpec, meth, cephadm_module): @@ -743,7 +743,7 @@ class TestCephadm(object): (ServiceSpec('cephadm-exporter'), CephadmOrchestrator.apply_cephadm_exporter), ] ) - @mock.patch("cephadm.module.CephadmOrchestrator._deploy_cephadm_binary", _deploy_cephadm_binary('test')) + @mock.patch("cephadm.serve.CephadmServe._deploy_cephadm_binary", _deploy_cephadm_binary('test')) @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}')) @mock.patch("cephadm.services.cephadmservice.RgwService.create_realm_zonegroup_zone", lambda _, __, ___: None) def test_apply_save(self, spec: ServiceSpec, meth, cephadm_module: CephadmOrchestrator): -- 2.39.5