try:
out, err, code = self.mgr.ssh.execute_command(
- host, cmd, stdin=stdin.encode('utf-8') if stdin else None, addr=addr)
+ host, cmd, stdin=stdin, addr=addr)
if code == 2:
ls_cmd = ['ls', self.mgr.cephadm_binary_path]
out_ls, err_ls, code_ls = self.mgr.ssh.execute_command(host, ls_cmd, addr=addr)
if code_ls == 2:
self._deploy_cephadm_binary(host, addr)
out, err, code = self.mgr.ssh.execute_command(
- host, cmd, stdin=stdin.encode('utf-8') if stdin else None, addr=addr)
+ host, cmd, stdin=stdin, addr=addr)
except Exception as e:
self.mgr.ssh._reset_con(host)
try:
cmd = ['/usr/bin/cephadm'] + final_args
out, err, code = self.mgr.ssh.execute_command(
- host, cmd, stdin=stdin.encode('utf-8') if stdin else None, addr=addr)
+ host, cmd, stdin=stdin, addr=addr)
except Exception as e:
self.mgr.ssh._reset_con(host)
if error_ok:
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
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))
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)
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))