Documentation
¶
Overview ¶
Package sshclient contains the interface to speak to bare metal servers with ssh.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCommandExitedWithoutExitSignal means the ssh command exited unplanned. ErrCommandExitedWithoutExitSignal = errors.New("wait: remote command exited without exit status or exit signal") // ErrCommandExitedWithStatusOne means the ssh command exited with sttatus 1. ErrCommandExitedWithStatusOne = errors.New("Process exited with status 1") //nolint:stylecheck // this is used to check ssh errors // ErrConnectionRefused means the ssh connection was refused. ErrConnectionRefused = errors.New("connect: connection refused") // ErrAuthenticationFailed means ssh was unable to authenticate. ErrAuthenticationFailed = errors.New("ssh: unable to authenticate") // ErrEmptyStdOut means that StdOut equals empty string. ErrEmptyStdOut = errors.New("unexpected empty output in stdout") // ErrTimeout means that there is a timeout error. ErrTimeout = errors.New("i/o timeout") // ErrCheckDiskBrokenDisk means that a disk seams broken. ErrCheckDiskBrokenDisk = errors.New("CheckDisk failed") )
var ( // ErrInvalidWWN indicates that a WWN has an invalid syntax. ErrInvalidWWN = fmt.Errorf("WWN does not match regex %q", isValidWWNRegex.String()) )
Functions ¶
func IsAuthenticationFailedError ¶
IsAuthenticationFailedError checks whether the ssh error is an authentication failed error.
func IsCommandExitedWithoutExitSignalError ¶
IsCommandExitedWithoutExitSignalError checks whether the ssh error is an unplanned exit error.
func IsConnectionRefusedError ¶
IsConnectionRefusedError checks whether the ssh error is a connection refused error.
func IsTimeoutError ¶
IsTimeoutError checks whether the ssh error is an unplanned exit error.
Types ¶
type Client ¶
type Client interface { GetHostName() Output GetHardwareDetailsRAM() Output GetHardwareDetailsNics() Output GetHardwareDetailsStorage() Output GetHardwareDetailsCPUArch() Output GetHardwareDetailsCPUModel() Output GetHardwareDetailsCPUClockGigahertz() Output GetHardwareDetailsCPUFlags() Output GetHardwareDetailsCPUThreads() Output GetHardwareDetailsCPUCores() Output GetHardwareDetailsDebug() Output GetInstallImageState() (InstallImageState, error) GetResultOfInstallImage() (string, error) GetCloudInitOutput() Output CreateAutoSetup(data string) Output DownloadImage(path, url string) Output CreatePostInstallScript(data string) Output ExecuteInstallImage(hasPostInstallScript bool) Output Reboot() Output CloudInitStatus() Output CheckCloudInitLogsForSigTerm() Output CleanCloudInitLogs() Output CleanCloudInitInstances() Output ResetKubeadm() Output UntarTGZ() Output DetectLinuxOnAnotherDisk(sliceOfWwns []string) Output // Erase filesystem, raid and partition-table signatures. // String "all" will wipe all disks. WipeDisk(ctx context.Context, sliceOfWwns []string) (string, error) // CheckDisk checks the given disks via smartctl. // ErrCheckDiskBrokenDisk gets returned, if a disk is broken. CheckDisk(ctx context.Context, sliceOfWwns []string) (info string, err error) }
Client is the interface defining all functions necessary to talk to a bare metal server via SSH.
type Credentials ¶
Credentials defines the credentials for SSH calls specified in a secret.
func CredentialsFromSecret ¶
func CredentialsFromSecret(secret *corev1.Secret, secretRef infrav1.SSHSecretRef) Credentials
CredentialsFromSecret generates the credentials object from a secret and a secretRef.
func (Credentials) Validate ¶
func (creds Credentials) Validate() error
Validate returns an error if the ssh credentials are invalid.
type InstallImageState ¶
type InstallImageState string
InstallImageState defines three states of the process.
const ( // InstallImageStateNotStartedYet means the process has not started yet. InstallImageStateNotStartedYet InstallImageState = "not-started-yet" // InstallImageStateRunning means the process is still running. InstallImageStateRunning InstallImageState = "running" // InstallImageStateFinished has finished. InstallImageStateFinished InstallImageState = "finished" )
type Output ¶
Output defines the SSH output.
func (Output) ExitStatus ¶
ExitStatus returns the exit status of the remote shell command. There are three case: First case: Remote command finished with exit 0: 0, nil. Second case: Remote command finished with non zero: N, nil. Third case: Remote command was not called successfully (like host not reachable): 0, err.