From: Melissa
Date: Wed, 21 Jul 2021 03:19:33 +0000 (-0400)
Subject: mgr/cephadm: simplify _deploy_cephadm_binary, remove _deploy_cephadm_binary_conn
X-Git-Tag: v17.1.0~1051^2~4
X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1633ba325b03fee19016d8b0bf9e780b9f8f7157;p=ceph.git
mgr/cephadm: simplify _deploy_cephadm_binary, remove _deploy_cephadm_binary_conn
_deploy_cephadm_binary can be simplified to call write_remote_file in ssh.py, and _deploy_cephadm_binary_conn is no longer needed
Fixes: https://tracker.ceph.com/issues/44676
Signed-off-by: Melissa Li
---
diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py
index 8cc13076c7bd..915b93b7c5d5 100644
--- a/src/pybind/mgr/cephadm/serve.py
+++ b/src/pybind/mgr/cephadm/serve.py
@@ -1281,26 +1281,7 @@ class CephadmServe:
return f"Host {host} failed to login to {url} as {username} with given password"
return None
- def _deploy_cephadm_binary(self, host: str) -> None:
+ def _deploy_cephadm_binary(self, host: str, addr: Optional[str] = None) -> None:
# 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
- return self._deploy_cephadm_binary_conn(conn, host)
-
- def _deploy_cephadm_binary_conn(self, conn: "BaseConnection", host: str) -> None:
- _out, _err, code = remoto.process.check(
- conn,
- ['mkdir', '-p', f'/var/lib/ceph/{self.mgr._cluster_fsid}'])
- if code:
- msg = f"Unable to deploy the cephadm binary to {host}: {_err}"
- self.log.warning(msg)
- raise OrchestratorError(msg)
- _out, _err, code = remoto.process.check(
- conn,
- ['tee', '-', self.mgr.cephadm_binary_path],
- stdin=self.mgr._cephadm.encode('utf-8'))
- if code:
- msg = f"Unable to deploy the cephadm binary to {host}: {_err}"
- self.log.warning(msg)
- raise OrchestratorError(msg)
+ self.mgr.ssh.write_remote_file(host, self.mgr.cephadm_binary_path, self.mgr._cephadm.encode('utf-8'), addr=addr)