summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/cephadm/ssh.py
diff options
context:
space:
mode:
authorMichael Fritch <mfritch@suse.com>2021-10-07 18:17:28 +0200
committerMichael Fritch <mfritch@suse.com>2021-10-08 01:57:12 +0200
commit52c20e5551730d27f535cc00ab5f94e8b2f5da4f (patch)
treea288239ebcd104567379a502b88331b34fa69998 /src/pybind/mgr/cephadm/ssh.py
parentmgr/cephadm: use `asyncssh.scp` to write remote files (diff)
downloadceph-52c20e5551730d27f535cc00ab5f94e8b2f5da4f.tar.xz
ceph-52c20e5551730d27f535cc00ab5f94e8b2f5da4f.zip
mgr/cephadm: use str type for `stdin`
avoid encode/decode confusion by using a str data type to both send (stdin) and receive (stdout) data Signed-off-by: Michael Fritch <mfritch@suse.com>
Diffstat (limited to 'src/pybind/mgr/cephadm/ssh.py')
-rw-r--r--src/pybind/mgr/cephadm/ssh.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pybind/mgr/cephadm/ssh.py b/src/pybind/mgr/cephadm/ssh.py
index 57c3ecd7982..eb134960276 100644
--- a/src/pybind/mgr/cephadm/ssh.py
+++ b/src/pybind/mgr/cephadm/ssh.py
@@ -128,14 +128,14 @@ class SSHManager:
async def _execute_command(self,
host: str,
cmd: List[str],
- stdin: Optional[bytes] = None,
+ stdin: Optional[str] = None,
addr: Optional[str] = None,
) -> Tuple[str, str, int]:
conn = await self._remote_connection(host, addr)
cmd = "sudo " + " ".join(quote(x) for x in cmd)
logger.debug(f'Running command: {cmd}')
try:
- r = await conn.run(cmd, input=stdin.decode() if stdin else None)
+ r = await conn.run(cmd, input=stdin)
# handle these Exceptions otherwise you might get a weird error like TypeError: __init__() missing 1 required positional argument: 'reason' (due to the asyncssh error interacting with raise_if_exception)
except (asyncssh.ChannelOpenError, Exception) as e:
# SSH connection closed or broken, will create new connection next call
@@ -150,7 +150,7 @@ class SSHManager:
def execute_command(self,
host: str,
cmd: List[str],
- stdin: Optional[bytes] = None,
+ stdin: Optional[str] = None,
addr: Optional[str] = None,
) -> Tuple[str, str, int]:
return self.mgr.event_loop.get_result(self._execute_command(host, cmd, stdin, addr))
@@ -158,7 +158,7 @@ class SSHManager:
async def _check_execute_command(self,
host: str,
cmd: List[str],
- stdin: Optional[bytes] = None,
+ stdin: Optional[str] = None,
addr: Optional[str] = None,
) -> str:
out, err, code = await self._execute_command(host, cmd, stdin, addr)
@@ -171,7 +171,7 @@ class SSHManager:
def check_execute_command(self,
host: str,
cmd: List[str],
- stdin: Optional[bytes] = None,
+ stdin: Optional[str] = None,
addr: Optional[str] = None,
) -> str:
return self.mgr.event_loop.get_result(self._check_execute_command(host, cmd, stdin, addr))