sshclient

package
v1.0.0-alpha.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sshclient contains the interface to speak to bare metal servers with ssh.

Index

Constants

This section is empty.

Variables

View Source
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")

	// 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")
)

Functions

func IsAuthenticationFailedError

func IsAuthenticationFailedError(err error) bool

IsAuthenticationFailedError checks whether the ssh error is an authentication failed error.

func IsCommandExitedWithoutExitSignalError

func IsCommandExitedWithoutExitSignalError(err error) bool

IsCommandExitedWithoutExitSignalError checks whether the ssh error is an unplanned exit error.

func IsConnectionRefusedError

func IsConnectionRefusedError(err error) bool

IsConnectionRefusedError checks whether the ssh error is a connection refused error.

func IsTimeoutError

func IsTimeoutError(err error) bool

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
	CreateAutoSetup(data string) Output
	DownloadImage(path, url string) Output
	CreatePostInstallScript(data string) Output
	ExecuteInstallImage(hasPostInstallScript bool) Output
	Reboot() Output
	EnsureCloudInit() Output
	CreateNoCloudDirectory() Output
	CreateMetaData(hostName string) Output
	CreateUserData(userData string) Output
	CloudInitStatus() Output
	CheckCloudInitLogsForSigTerm() Output
	CleanCloudInitLogs() Output
	CleanCloudInitInstances() Output
}

Client is the interface defining all functions necessary to talk to a bare metal server via SSH.

type Credentials

type Credentials struct {
	Name       string
	PublicKey  string
	PrivateKey string
}

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 Factory

type Factory interface {
	NewClient(Input) Client
}

Factory is the interface for creating new Client objects.

func NewFactory

func NewFactory() Factory

NewFactory creates a new factory for SSH clients.

type Input

type Input struct {
	IP         string
	PrivateKey string
	Port       int
}

Input defines an SSH input.

type Output

type Output struct {
	StdOut string
	StdErr string
	Err    error
}

Output defines the SSH output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL