vm

package
v0.0.0-...-2e3fc24 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

This package is inspired from the code in https://gitlab.com/bootc-org/podman-bootc-cli/-/tree/main/pkg/vm as a very quick way to get bootc VMs running for testing purposes.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestVM

type TestVM struct {
	TestDir       string
	VMName        string
	LibvirtUri    string //linux only
	DiskImagePath string
	VMUser        string //user to use when connecting to the VM
	CloudInitDir  string
	NoCredentials bool
	CloudInitData bool
	SSHPassword   string
	SSHPort       int
	Cmd           []string
	RemoveVm      bool
	// contains filtered or unexported fields
}

func (*TestVM) ParseCloudInit

func (v *TestVM) ParseCloudInit() error

func (*TestVM) RunSSH

func (v *TestVM) RunSSH(inputArgs []string, stdin *bytes.Buffer) (*bytes.Buffer, error)

func (*TestVM) SSHCommand

func (v *TestVM) SSHCommand(inputArgs []string) *exec.Cmd

RunSSH runs a command over ssh or starts an interactive ssh connection if no command is provided

func (*TestVM) WaitForSSHToBeReady

func (v *TestVM) WaitForSSHToBeReady() error

type TestVMInterface

type TestVMInterface interface {
	Run() error
	ForceDelete() error
	Shutdown() error
	Delete() error
	IsRunning() (bool, error)
	WaitForSSHToBeReady() error
	RunAndWaitForSSH() error
	SSHCommand(inputArgs []string) *exec.Cmd
	RunSSH(inputArgs []string, stdin *bytes.Buffer) (*bytes.Buffer, error)
	Exists() (bool, error)
	GetConsoleOutput() string
}

func StartAndWaitForSSH

func StartAndWaitForSSH(params TestVM) (vm TestVMInterface, err error)

type VMInLibvirt

type VMInLibvirt struct {
	TestVM
	// contains filtered or unexported fields
}

func NewVM

func NewVM(params TestVM) (vm *VMInLibvirt, err error)

func (*VMInLibvirt) Delete

func (v *VMInLibvirt) Delete() (err error)

Delete the VM definition

func (*VMInLibvirt) Exists

func (v *VMInLibvirt) Exists() (bool, error)

func (*VMInLibvirt) ForceDelete

func (v *VMInLibvirt) ForceDelete() (err error)

ForceDelete stops and removes the VM

func (*VMInLibvirt) GetConsoleOutput

func (v *VMInLibvirt) GetConsoleOutput() string

cummulatively read console output from the VM

func (*VMInLibvirt) IsRunning

func (v *VMInLibvirt) IsRunning() (exists bool, err error)

func (*VMInLibvirt) Run

func (v *VMInLibvirt) Run() error

func (*VMInLibvirt) RunAndWaitForSSH

func (v *VMInLibvirt) RunAndWaitForSSH() error

func (*VMInLibvirt) Shutdown

func (v *VMInLibvirt) Shutdown() (err error)

Shutdown the VM

Jump to

Keyboard shortcuts

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