Module Ketrew.Host_io

module Host_io: sig .. end


Definition of a host; a place to run commands or handle files.
module Ssh: sig .. end
Helper functions to build SSH commands.
module Error: sig .. end
type t 
val create : unit -> t
val default_timeout_upper_bound : float Pervasives.ref
Default (upper bound) of the `?timeout` arguments.
type timeout = [ `At_most_seconds of float | `Host_default | `None | `Seconds of float ] 
Timeout specification for execution functions below.

The default value is `At_most_seconds !default_timeout_upper_bound.
val set_named_host : t ->
name:string -> Ketrew_pure.Host.Ssh.t -> (unit, 'a) Unix_io.Deferred_result.t
val delete_named_host : t -> name:string -> (unit, 'a) Unix_io.Deferred_result.t
val execute : ?timeout:timeout ->
t ->
host:Ketrew_pure.Host.t ->
string list ->
(< exited : int; stderr : string; stdout : string >,
[> `Host of
[> `Execution of
< host : string; message : string; stderr : string option;
stdout : string option >
| `Named_host_not_found of string
| `Ssh_failure of
[> `Wrong_log of string
| `Wrong_status of Unix_process.Exit_code.t ] *
string
| `System of [> `Sleep of float ] * [> `Exn of exn ]
| `Timeout of float
| `Unix_exec of string ]
Error.execution ])
Unix_io.Deferred_result.t
Generic execution which tries to behave like Unix.execv even on top of SSH.
type shell = string -> string list 
A “shell” is a function that takes a command and returns, and execv-style string list; the default for each host is "sh"; "-c"; cmd
val shell_sh : sh:string -> shell
Call sh-style commands using the command argument (e.g. shell_sh "/bin/sh" for a known path or command).
val get_shell_command_output : ?timeout:timeout ->
?with_shell:shell ->
t ->
host:Ketrew_pure.Host.t ->
string ->
(string * string,
[> `Host of
[> `Execution of
< host : string; message : string; stderr : string option;
stdout : string option >
| `Named_host_not_found of string
| `Non_zero of string * int
| `Ssh_failure of
[> `Wrong_log of string
| `Wrong_status of Unix_process.Exit_code.t ] *
string
| `System of [> `Sleep of float ] * [> `Exn of exn ]
| `Timeout of float
| `Unix_exec of string ]
Error.execution Error.non_zero_execution ])
Unix_io.Deferred_result.t
Run a shell command on the host, and return its (stdout, stderr) pair (succeeds iff the exit status is 0).
val get_shell_command_return_value : ?timeout:timeout ->
?with_shell:shell ->
t ->
host:Ketrew_pure.Host.t ->
string ->
(int,
[> `Host of
[> `Execution of
< host : string; message : string; stderr : string option;
stdout : string option >
| `Named_host_not_found of string
| `Ssh_failure of
[> `Wrong_log of string
| `Wrong_status of Unix_process.Exit_code.t ] *
string
| `System of [> `Sleep of float ] * [> `Exn of exn ]
| `Timeout of float
| `Unix_exec of string ]
Error.execution ])
Unix_io.Deferred_result.t
Run a shell command on the host, and return its exit status value.
val run_shell_command : ?timeout:timeout ->
?with_shell:shell ->
t ->
host:Ketrew_pure.Host.t ->
string ->
(unit,
[> `Host of
[> `Execution of
< host : string; message : string; stderr : string option;
stdout : string option >
| `Named_host_not_found of string
| `Non_zero of string * int
| `Ssh_failure of
[> `Wrong_log of string
| `Wrong_status of Unix_process.Exit_code.t ] *
string
| `System of [> `Sleep of float ] * [> `Exn of exn ]
| `Timeout of float
| `Unix_exec of string ]
Error.execution Error.non_zero_execution ])
Unix_io.Deferred_result.t
Run a shell command on the host (succeeds iff the exit status is 0).
val do_files_exist : ?timeout:timeout ->
?with_shell:shell ->
t ->
host:Ketrew_pure.Host.t ->
Ketrew_pure.Path.t list ->
(bool,
[> `Host of
[> `Execution of
< host : string; message : string; stderr : string option;
stdout : string option >
| `Named_host_not_found of string
| `Ssh_failure of
[> `Wrong_log of string
| `Wrong_status of Unix_process.Exit_code.t ] *
string
| `System of [> `Sleep of float ] * [> `Exn of exn ]
| `Timeout of float
| `Unix_exec of string ]
Error.execution ])
Unix_io.Deferred_result.t
Check existence of a list of files/directories.
val get_fresh_playground : t -> host:Ketrew_pure.Host.t -> Ketrew_pure.Path.t option
Get a new subdirectory in the host's playground
val ensure_directory : ?timeout:timeout ->
?with_shell:shell ->
t ->
host:Ketrew_pure.Host.t ->
path:Ketrew_pure.Path.t ->
(unit,
[> `Host of
[> `Execution of
< host : string; message : string; stderr : string option;
stdout : string option >
| `Named_host_not_found of string
| `Non_zero of string * int
| `Ssh_failure of
[> `Wrong_log of string
| `Wrong_status of Unix_process.Exit_code.t ] *
string
| `System of [> `Sleep of float ] * [> `Exn of exn ]
| `Timeout of float
| `Unix_exec of string ]
Error.execution Error.non_zero_execution ])
Unix_io.Deferred_result.t
Make sure the directory path exists on the host.
val put_file : ?timeout:timeout ->
t ->
host:Ketrew_pure.Host.t ->
path:Ketrew_pure.Path.t ->
content:string ->
(unit,
[> `Host of
[> `Execution of
< host : string; message : string; stderr : string option;
stdout : string option >
| `Named_host_not_found of string
| `Ssh_failure of
[> `Wrong_log of string
| `Wrong_status of Unix_process.Exit_code.t ] *
string
| `System of [> `Sleep of float ] * [> `Exn of exn ]
| `Timeout of float
| `Unix_exec of string ]
Error.execution
| `IO of [> `Write_file_exn of Unix_io.IO.path * exn ] ])
Unix_io.Deferred_result.t
Write a file on the host at path containing contents.
val get_file : ?timeout:timeout ->
t ->
host:Ketrew_pure.Host.t ->
path:Ketrew_pure.Path.t ->
(string,
[> `Cannot_read_file of string * string
| `Host of [> `Named_host_not_found of string ]
| `Timeout of Ketrew_pure.Internal_pervasives.Time.t ])
Unix_io.Deferred_result.t
Read the file from the host at path.
val grab_file_or_log : ?timeout:timeout ->
t ->
host:Ketrew_pure.Host.t ->
Ketrew_pure.Path.t ->
(string, Ketrew_pure.Internal_pervasives.Log.t) Unix_io.Deferred_result.t
Weakly typed version of Ketrew.Host_io.get_file, it fails with a Log.t (for use in “long-running” plugins).