console

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PromptExpression = `(\$ |\# )`
	CRLF             = "\r\n"
	UTFPosEscape     = "\u001b\\[[0-9]+;[0-9]+H"
)

Variables

View Source
var (
	ShellSuccess       = RetValue("0")
	ShellFail          = RetValue("[1-9].*")
	ShellSuccessRegexp = regexp.MustCompile(ShellSuccess)
	ShellFailRegexp    = regexp.MustCompile(ShellFail)
)

Functions

func ExpectBatch

func ExpectBatch(vmi *v1.VirtualMachineInstance, expected []expect.Batcher, timeout time.Duration) error

ExpectBatch runs the batch from `expected` connecting to the `vmi` console and wait `timeout` for the batch to return. NOTE: there is a safer version that validates sended commands `SafeExpectBatch` refer to it about limitations.

func ExpectBatchWithValidatedSend

func ExpectBatchWithValidatedSend(expecter expect.Expecter, batch []expect.Batcher, timeout time.Duration) ([]expect.BatchRes, error)

ExpectBatchWithValidatedSend adds the expect.BSnd command to the exect.BExp expression. It is done to make sure the match was found in the result of the expect.BSnd command and not in a leftover that wasn't removed from the buffer. NOTE: the method contains the following limitations:

  • Use of `BatchSwitchCase`
  • Multiline commands
  • No more than one sequential send or receive

func LoginToAlpine added in v0.36.0

func LoginToAlpine(vmi *v1.VirtualMachineInstance) error

LoginToAlpine performs a console login to an Alpine base VM

func LoginToCirros added in v0.36.0

func LoginToCirros(vmi *v1.VirtualMachineInstance) error

LoginToCirros performs a console login to a Cirros base VM

func LoginToFedora added in v0.36.0

func LoginToFedora(vmi *v1.VirtualMachineInstance) error

LoginToFedora performs a console login to a Fedora base VM

func NetBootExpecter

func NetBootExpecter(vmi *v1.VirtualMachineInstance) error

NetBootExpecter should be called on a VMI that has BIOS serial logging enabled It will parse the SeaBIOS output and succeed if it finds the string "iPXE"

func NewExpecter

func NewExpecter(virtCli kubecli.KubevirtClient, vmi *v1.VirtualMachineInstance, timeout time.Duration, opts ...expect.Option) (expect.Expecter, <-chan error, error)

NewExpecter will connect to an already logged in VMI console and return the generated expecter it will wait `timeout` for the connection.

func OnPrivilegedPrompt added in v0.36.0

func OnPrivilegedPrompt(vmi *v1.VirtualMachineInstance, timeout int) bool

OnPrivilegedPrompt performs a console check that the prompt is privileged.

func RetValue

func RetValue(retcode string) string

func RunCommand

func RunCommand(vmi *v1.VirtualMachineInstance, command string, timeout time.Duration) error

RunCommand runs the command line from `command connecting to an already logged in console at vmi and wait `timeout` for command to return. NOTE: The safer version `ExpectBatchWithValidatedSend` is not used here since it does not support cases.

func SafeExpectBatch

func SafeExpectBatch(vmi *v1.VirtualMachineInstance, expected []expect.Batcher, wait int) error

SafeExpectBatch runs the batch from `expected` connecting to a VMI's console and wait `timeout` for the batch to return, it also check that the sended commands arrives to console checking. NOTE: This functions heritage limitations from `ExpectBatchWithValidatedSend` refer to it to check them.

func SafeExpectBatchWithResponse added in v0.36.0

func SafeExpectBatchWithResponse(vmi *v1.VirtualMachineInstance, expected []expect.Batcher, wait int) ([]expect.BatchRes, error)

SafeExpectBatchWithResponse runs the batch from `expected` connecting to a VMI's console and wait `timeout` for the batch to return with a response. It includes a safety check which validates that the commands arrive to the console. NOTE: This functions inherits limitations from `ExpectBatchWithValidatedSend`, refer to it for more information.

func SecureBootExpecter

func SecureBootExpecter(vmi *v1.VirtualMachineInstance) error

SecureBootExpecter should be called on a VMI that has EFI enabled It will parse the kernel output (dmesg) and succeed if it finds that Secure boot is enabled

Types

type LoginToFactory added in v0.36.0

type LoginToFactory func(*v1.VirtualMachineInstance) error

LoginToFactory represents the LogIn* functions signature

Jump to

Keyboard shortcuts

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