{"modulePath":"github.com/CS-SI/SafeScale/v21","version":"v21.11.1","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package system\n\n## Constants\n\n```go\nconst (\n\tBashLibraryReservedKeyword            = \"reserved_BashLibrary\"\n\tDefaultDelayReservedKeyword           = \"reserved_DefaultDelay\"\n\tDefaultTimeoutReservedKeyword         = \"reserved_DefaultTimeout\"\n\tLongTimeoutReservedKeyword            = \"reserved_LongTimeout\"\n\tClusterJoinTimeoutReservedKeyword     = \"reserved_ClusterJoinTimeout\"\n\tDockerImagePullTimeoutReservedKeyword = \"reserved_DockerImagePullTimeout\"\n)\n```\n\n## Functions\n\n```go\nfunc CreateTempFileFromString(content string, filemode os.FileMode) (*os.File, fail.Error)\n```\nCreateTempFileFromString creates a temporary file containing 'content'\n\n```go\nfunc SCPErrorString(retcode int) string\n```\nSCPErrorString returns if possible the string corresponding to SCP execution\n\n```go\nfunc SSHErrorString(retcode int) string\n```\nSSHErrorString returns if possible the string corresponding to SSH execution\n\n## Types\n\n```go\ntype BashLibraryDefinition struct {\n\tContent                string `json:\"reserved_BashLibrary\"`\n\tDefaultDelay           uint   `json:\"reserved_DefaultDelay\"`\n\tDefaultTimeout         string `json:\"reserved_DefaultTimeout\"`\n\tLongTimeout            string `json:\"reserved_LongTimeout\"`\n\tClusterJoinTimeout     string `json:\"reserved_ClusterJoinTimeout\"`\n\tDockerImagePullTimeout string `json:\"reserved_DockerImagePullTimeout\"`\n}\n```\n\n```go\nfunc BuildBashLibraryDefinition(\n\ttimings temporal.Timings,\n) (*BashLibraryDefinition, fail.Error)\n```\nBuildBashLibraryDefinition generates the content of {{.reserved\\_BashLibrary}} and other reserved template variables\n\n```go\nfunc (bld *BashLibraryDefinition) ToMap() (map[string]interface{}, fail.Error)\n```\nToMap transforms bld to a map\n\n```go\ntype SSHCommand struct {\n\t// contains filtered or unexported fields\n}\n```\nSSHCommand defines a SSH command\n\n```go\nfunc (scmd *SSHCommand) Close() fail.Error\n```\nClose is called to clean SSHCommand (close tunnel(s), remove temporary files, ...)\n\n```go\nfunc (scmd *SSHCommand) CombinedOutput() ([]byte, fail.Error)\n```\nCombinedOutput returns the combined standard of command started output and standard error.\n\n```go\nfunc (scmd *SSHCommand) Kill() fail.Error\n```\nKill kills SSHCommand process.\n\n```go\nfunc (scmd *SSHCommand) Output() ([]byte, fail.Error)\n```\nOutput returns the standard output of command started. Any returned error will usually be of type \\*ExitError. If c.Stderr was nil, Output populates ExitError.Stderr.\n\n```go\nfunc (scmd *SSHCommand) RunWithTimeout(ctx context.Context, outs outputs.Enum, timeout time.Duration) (int, string, string, fail.Error)\n```\nRunWithTimeout ... returns:\n\n  - retcode int\n  - stdout string\n  - stderr string\n  - xerr fail.Error . \\*fail.ErrNotAvailable if remote SSH is not available . \\*fail.ErrTimeout if 'timeout' is reached\n\nNote: if you want to RunWithTimeout in a loop, you MUST create the scmd inside the loop, otherwise\n\n\tyou risk to call twice os/exec.Wait, which may panic\n\nFIXME: maybe we should move this method inside sshconfig directly with systematically created scmd...\n\n```go\nfunc (scmd *SSHCommand) Start() fail.Error\n```\nStart starts the specified command but does not wait for it to complete. The Wait method will wait for completion and return the exit code.\n\n```go\nfunc (scmd *SSHCommand) Wait() error\n```\nWait waits for the command to exit and waits for any copying to stdin or copying from stdout or stderr to complete. The command must have been started by Start. The returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status. If the command fails to run or doesn't complete successfully, the error is of type \\*ExitError. Other error types may be returned for I/O problems. Wait also waits for the I/O loop copying from c.Stdin into the process's standard input to complete. Wait does not release resources associated with the cmd; SSHCommand.Close() must be called for that. !!!WARNING!!!: the error returned is NOT USING fail.Error because we may NEED TO CAST the error to recover return code\n\n```go\ntype SSHConfig struct {\n\tHostname               string     `json:\"hostname\"`\n\tIPAddress              string     `json:\"ip_address\"`\n\tPort                   int        `json:\"port\"`\n\tUser                   string     `json:\"user\"`\n\tPrivateKey             string     `json:\"private_key\"`\n\tLocalPort              int        `json:\"-\"`\n\tGatewayConfig          *SSHConfig `json:\"primary_gateway_config,omitempty\"`\n\tSecondaryGatewayConfig *SSHConfig `json:\"secondary_gateway_config,omitempty\"`\n}\n```\nSSHConfig helper to manage ssh session\n\n```go\nfunc (sconf *SSHConfig) Clone() *SSHConfig\n```\nClone clones the SSHConfig\n\n```go\nfunc (sconf *SSHConfig) CopyWithTimeout(\n\tctx context.Context, remotePath, localPath string, isUpload bool, timeout time.Duration,\n) (int, string, string, fail.Error)\n```\nCopyWithTimeout copies a file/directory from/to local to/from remote, and fails after 'timeout'\n\n```go\nfunc (sconf *SSHConfig) CreateTunneling() (_ SSHTunnels, _ *SSHConfig, ferr fail.Error)\n```\nCreateTunneling ...\n\n```go\nfunc (sconf *SSHConfig) Enter(username, shell string) (ferr fail.Error)\n```\nEnter to interactive shell, aka 'safescale ssh connect'\n\n```go\nfunc (sconf *SSHConfig) IsNull() bool\n```\nIsNull tells if the instance is a null value\n\n```go\nfunc (sconf *SSHConfig) NewCommand(ctx context.Context, cmdString string) (*SSHCommand, fail.Error)\n```\nNewCommand returns the cmd struct to execute runCmdString remotely\n\n```go\nfunc (sconf *SSHConfig) NewSudoCommand(ctx context.Context, cmdString string) (*SSHCommand, fail.Error)\n```\nNewSudoCommand returns the cmd struct to execute runCmdString remotely. NewCommand is executed with sudo\n\n```go\nfunc (sconf *SSHConfig) WaitServerReady(ctx context.Context, phase string, timeout time.Duration) (out string, ferr fail.Error)\n```\nWaitServerReady waits until the SSH server is ready\n\n```go\ntype SSHTunnel struct {\n\t// contains filtered or unexported fields\n}\n```\nSSHTunnel a SSH tunnel\n\n```go\nfunc (stun *SSHTunnel) Close() fail.Error\n```\nClose closes ssh tunnel\n\n```go\ntype SSHTunnels []*SSHTunnel\n```\n\n```go\nfunc (tunnels SSHTunnels) Close() fail.Error\n```\nClose closes all the tunnels\n\n","path":"github.com/CS-SI/SafeScale/v21/lib/system","name":"system","synopsis":"","isRedistributable":true}
