pub struct RemoteShell { /* private fields */ }Expand description
How one node’s ssh and sftp invocations are built and run.
Implementations§
Source§impl RemoteShell
impl RemoteShell
Sourcepub fn from_ssh(
repo: &Path,
target_file: &str,
label: &str,
ssh: &Ssh,
runner: Arc<dyn ProcessRunner>,
) -> Result<RemoteShell, CoreError>
pub fn from_ssh( repo: &Path, target_file: &str, label: &str, ssh: &Ssh, runner: Arc<dyn ProcessRunner>, ) -> Result<RemoteShell, CoreError>
Build the shell for ssh of node label (nodes.master), reading
the key from the process environment.
Sourcepub fn from_ssh_with_env(
repo: &Path,
target_file: &str,
label: &str,
ssh: &Ssh,
runner: Arc<dyn ProcessRunner>,
env: &dyn Fn(&str) -> Option<String>,
) -> Result<RemoteShell, CoreError>
pub fn from_ssh_with_env( repo: &Path, target_file: &str, label: &str, ssh: &Ssh, runner: Arc<dyn ProcessRunner>, env: &dyn Fn(&str) -> Option<String>, ) -> Result<RemoteShell, CoreError>
from_ssh with an injectable environment lookup
(tests; avoids mutating the process environment).
Sourcepub fn op_timeout(&self) -> Duration
pub fn op_timeout(&self) -> Duration
The per-call timeout.
Sourcepub fn temp_dir(&self) -> Option<&Path>
pub fn temp_dir(&self) -> Option<&Path>
This shell’s private temp dir (known_hosts copy and key).
Sourcepub fn known_hosts_copy(&self) -> &Path
pub fn known_hosts_copy(&self) -> &Path
The known_hosts copy ssh is pointed at.
Sourcepub fn identity(&self) -> Option<&Path>
pub fn identity(&self) -> Option<&Path>
The identity file passed with -i, when one is configured.
Sourcepub fn ssh_argv(&self, remote_command: Option<&RemoteCommand>) -> Vec<OsString>
pub fn ssh_argv(&self, remote_command: Option<&RemoteCommand>) -> Vec<OsString>
ssh argv: -T -p <port> [-i <key>] -o k=v… -- user@host [command].
remote_command is sent to the remote shell as one argument; a
RemoteCommand can only be built injection-safe.
Sourcepub fn sftp_argv(&self) -> Vec<OsString>
pub fn sftp_argv(&self) -> Vec<OsString>
sftp argv: -q -b - -P <port> [-i <key>] -o k=v… -- user@host
(the batch comes on stdin).
Sourcepub async fn sftp_batch(
&self,
ops: &[SftpOp],
) -> Result<ProcessOutput, CoreError>
pub async fn sftp_batch( &self, ops: &[SftpOp], ) -> Result<ProcessOutput, CoreError>
Run sftp with ops as the batch on stdin, then close stdin. Every
op is rendered first, so one op with an unsafe path refuses the whole
batch before anything spawns.
Sourcepub fn require_success(
&self,
operation: &str,
out: ProcessOutput,
) -> Result<ProcessOutput, CoreError>
pub fn require_success( &self, operation: &str, out: ProcessOutput, ) -> Result<ProcessOutput, CoreError>
Map a finished invocation to Ok only when it exited 0 within its
timeout with nothing on stderr. Anything else is
CoreError::TransportFailed whose detail is the scrubbed stderr
tail (never the stdout, never the key).
Sourcepub async fn exec_powershell(
&self,
script: &WinScript,
) -> Result<Value, CoreError>
pub async fn exec_powershell( &self, script: &WinScript, ) -> Result<Value, CoreError>
Run a fixed WinScript on a Windows host over ssh and return its
result. The remote command is built by
winps::encoded_command (the typed
RemoteCommand::powershell_encoded, held to the 8000 character
budget before anything spawns); success needs exit 0 within the
per-call timeout and exactly one IGN-RESULT: stdout line, and
anything else, CLIXML on stderr included, is
CoreError::TransportFailed (see winps).
Sourcepub async fn exec_powershell_within(
&self,
script: &WinScript,
limit: Duration,
) -> Result<Value, CoreError>
pub async fn exec_powershell_within( &self, script: &WinScript, limit: Duration, ) -> Result<Value, CoreError>
exec_powershell with limit as the per-call
timeout instead of ssh.op_timeout_s (the commit’s, which must not
outlive the scan-lock hold by much, review WR-04).
Sourcepub async fn exec_posix(
&self,
op: &str,
command: &RemoteCommand,
) -> Result<Value, CoreError>
pub async fn exec_posix( &self, op: &str, command: &RemoteCommand, ) -> Result<Value, CoreError>
Run one POSIX command (built by RemoteCommand::posix) on a Linux
host over ssh and return the JSON of its one IGN-RESULT: stdout
line. op names the script operation in every error. Success needs
exit 0 within the per-call timeout and exactly one sentinel line; a
non-zero exit, a timeout, a missing or doubled sentinel and text after
the sentinel that is not JSON are all CoreError::TransportFailed
naming op. The detail carries a scrubbed stderr tail and never the
stdout.
Sourcepub async fn exec_posix_within(
&self,
op: &str,
command: &RemoteCommand,
limit: Duration,
) -> Result<Value, CoreError>
pub async fn exec_posix_within( &self, op: &str, command: &RemoteCommand, limit: Duration, ) -> Result<Value, CoreError>
exec_posix with limit as the per-call timeout
instead of ssh.op_timeout_s (the commit’s, review WR-04).
Sourcepub async fn exec_posix_status(
&self,
op: &str,
command: &RemoteCommand,
) -> Result<(), CoreError>
pub async fn exec_posix_status( &self, op: &str, command: &RemoteCommand, ) -> Result<(), CoreError>
Run one POSIX command (built by RemoteCommand::posix) for its
exit status alone: success is exit 0 within the per-call timeout, and
the stdout is not read. For a program that prints nothing on success
(mv), where no IGN-RESULT: line can be asked for without wrapping
the program in a shell script. A non-zero exit and a timeout are
CoreError::TransportFailed naming op, with the scrubbed stderr
tail and never the stdout.