console

package
v1.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 14 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" The VMI was just created and may not be running yet. This is because we want to catch early boot logs.

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 waiting `timeout` for command to return. NOTE: The safer version `ExpectBatchWithValidatedSend` is not used here since it does not support cases.

func RunCommandAndStoreOutput added in v0.55.0

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

RunCommandAndStoreOutput runs the command line from `command` connecting to an already logged in console in vmi. The output of `command` is returned as a string

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 waiting `wait` seconds for the batch to return. It validates that the commands arrive to the console. 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 waiting `wait` seconds for the batch to return with a response. It 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 The VMI was just created and may not be running yet. This is because we want to catch early boot logs.

Types

type LoginToFunction added in v0.50.0

type LoginToFunction func(*v1.VirtualMachineInstance) error

LoginToFunction represents any of the LoginTo* functions

Jump to

Keyboard shortcuts

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