target

package
v0.0.0-...-bbc9ce3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: BSD-2-Clause Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultQEMUNodename is the default nodename given to a QEMU target.
	DefaultQEMUNodename = "botanist-target-qemu"
)

Variables

View Source
var ErrUnimplemented error = errors.New("method unimplemented")

ErrUnimplemented is an error for unimplemented methods.

Functions

This section is empty.

Types

type AEMUTarget

type AEMUTarget struct {
	QEMUTarget
}

AEMUTarget is a AEMU target.

func NewAEMUTarget

func NewAEMUTarget(config QEMUConfig, opts Options) (*AEMUTarget, error)

NewAEMUTarget returns a new AEMU target with a given configuration.

type ConfiguredTarget

type ConfiguredTarget interface {
	// Address returns the target's configured IP address.
	Address() net.IP
}

ConfiguredTarget represents a target that has static configuration.

type DeviceConfig

type DeviceConfig struct {
	// FastbootSernum is the fastboot serial number of the device.
	FastbootSernum string `json:"fastboot_sernum"`

	// Network is the network properties of the target.
	Network NetworkProperties `json:"network"`

	// SSHKeys are the default system keys to be used with the device.
	SSHKeys []string `json:"keys,omitempty"`

	// Serial is the path to the device file for serial i/o.
	Serial string `json:"serial,omitempty"`

	// SerialMux is the path to the device's serial multiplexer.
	SerialMux string `json:"serial_mux,omitempty"`
}

DeviceConfig contains the static properties of a target device.

func LoadDeviceConfigs

func LoadDeviceConfigs(path string) ([]DeviceConfig, error)

LoadDeviceConfigs unmarshalls a slice of device configs from a given file.

type DeviceTarget

type DeviceTarget struct {
	// contains filtered or unexported fields
}

DeviceTarget represents a target device.

func NewDeviceTarget

func NewDeviceTarget(ctx context.Context, config DeviceConfig, opts Options) (*DeviceTarget, error)

NewDeviceTarget returns a new device target with a given configuration.

func (*DeviceTarget) Address

func (t *DeviceTarget) Address() net.IP

Address implements ConfiguredTarget.

func (*DeviceTarget) Nodename

func (t *DeviceTarget) Nodename() string

Nodename returns the name of the node.

func (*DeviceTarget) SSHKey

func (t *DeviceTarget) SSHKey() string

SSHKey returns the private SSH key path associated with the authorized key to be paved.

func (*DeviceTarget) Serial

func (t *DeviceTarget) Serial() io.ReadWriteCloser

Serial returns the serial device associated with the target for serial i/o.

func (*DeviceTarget) Start

func (t *DeviceTarget) Start(ctx context.Context, images []bootserver.Image, args []string, serialSocketPath string) error

Start starts the device target.

func (*DeviceTarget) Stop

func (t *DeviceTarget) Stop(context.Context) error

Stop stops the device.

func (*DeviceTarget) Tftp

func (t *DeviceTarget) Tftp() tftp.Client

Tftp returns a tftp client interface for the device.

func (*DeviceTarget) Wait

func (t *DeviceTarget) Wait(context.Context) error

Wait waits for the device target to stop.

type EMUCommandBuilder

type EMUCommandBuilder interface {
	SetFlag(...string)
	SetBinary(string)
	SetKernel(string)
	SetInitrd(string)
	SetTarget(qemu.Target, bool)
	SetMemory(int)
	SetCPUCount(int)
	AddVirtioBlkPciDrive(qemu.Drive)
	AddSerial(qemu.Chardev)
	AddNetwork(qemu.Netdev)
	AddKernelArg(string)
	Build() ([]string, error)
}

EMUCommandBuilder defines the common set of functions used to build up an EMU command-line.

type GCEConfig

type GCEConfig struct {
	// MediatorURL is the url of the GCE Mediator.
	MediatorURL string `json:"mediator_url"`
	// BuildID is the swarming task ID of the associated build.
	BuildID string `json:"build_id"`
	// CloudProject is the cloud project to create the GCE Instance in.
	CloudProject string `json:"cloud_project"`
	// SwarmingServer is the URL to the swarming server that fed us this
	// task.
	SwarmingServer string `json:"swarming_server"`
	// MachineShape is the shape of the instance we want to create.
	MachineShape string `json:"machine_shape"`
	// InstanceName is the name of the instance.
	InstanceName string `json:"instance_name"`
	// Zone is the cloud zone in which the instance lives.
	Zone string `json:"zone"`
}

GCEConfig represents the on disk config used by botanist to launch a GCE instance.

type GCETarget

type GCETarget struct {
	// contains filtered or unexported fields
}

GCETarget represents a GCE VM running Fuchsia.

func NewGCETarget

func NewGCETarget(ctx context.Context, config GCEConfig, opts Options) (*GCETarget, error)

NewGCETarget creates, starts, and connects to the serial console of a GCE VM.

func (*GCETarget) Address

func (g *GCETarget) Address() net.IP

func (*GCETarget) Nodename

func (g *GCETarget) Nodename() string

func (*GCETarget) SSHKey

func (g *GCETarget) SSHKey() string

func (*GCETarget) Serial

func (g *GCETarget) Serial() io.ReadWriteCloser

func (*GCETarget) Start

func (g *GCETarget) Start(ctx context.Context, _ []bootserver.Image, args []string, _ string) error

func (*GCETarget) Stop

func (g *GCETarget) Stop(context.Context) error

func (*GCETarget) Wait

func (g *GCETarget) Wait(context.Context) error

type MinFS

type MinFS struct {
	// Image is the path to the filesystem image.
	Image string `json:"image"`

	// PCIAddress is the PCI address to map the device at.
	PCIAddress string `json:"pci_address"`
}

MinFS is the configuration for the MinFS filesystem image.

type NetworkProperties

type NetworkProperties struct {
	// Nodename is the hostname of the device that we want to boot on.
	Nodename string `json:"nodename"`

	// IPv4Addr is the IPv4 address, if statically given. If not provided, it may be
	// resolved via the netstack's MDNS server.
	IPv4Addr string `json:"ipv4"`
}

NetworkProperties are the static network properties of a target.

type Options

type Options struct {
	// Netboot gives whether to netboot or pave. Netboot here is being used in the
	// colloquial sense of only sending netsvc a kernel to mexec. If false, the target
	// will be paved. Ignored for QEMUTarget.
	Netboot bool

	// SSHKey is a private SSH key file, corresponding to an authorized key to be paved or
	// to one baked into a boot image.
	SSHKey string
}

Options represents lifecycle options for a target. The options will not necessarily make sense for all target types.

type QEMUConfig

type QEMUConfig struct {
	// Path is a path to a directory that contains QEMU system binary.
	Path string `json:"path"`

	// Target is the QEMU target to emulate.
	Target string `json:"target"`

	// CPU is the number of processors to emulate.
	CPU int `json:"cpu"`

	// Memory is the amount of memory (in MB) to provide.
	Memory int `json:"memory"`

	// KVM specifies whether to enable hardware virtualization acceleration.
	KVM bool `json:"kvm"`

	// Serial gives whether to create a 'serial device' for the QEMU instance.
	// This option should be used judiciously, as it can slow the process down.
	Serial bool `json:"serial"`

	// Logfile saves emulator standard output to a file if set.
	Logfile string `json:"logfile"`

	// Whether User networking is enabled; if false, a Tap interface will be used.
	UserNetworking bool `json:"user_networking"`

	// MinFS is the filesystem to mount as a device.
	MinFS *MinFS `json:"minfs,omitempty"`

	// Path to the fvm host tool.
	FVMTool string `json:"fvm_tool"`
}

QEMUConfig is a QEMU configuration.

type QEMUTarget

type QEMUTarget struct {
	// contains filtered or unexported fields
}

QEMUTarget is a QEMU target.

func NewQEMUTarget

func NewQEMUTarget(config QEMUConfig, opts Options) (*QEMUTarget, error)

NewQEMUTarget returns a new QEMU target with a given configuration.

func (*QEMUTarget) Nodename

func (t *QEMUTarget) Nodename() string

Nodename returns the name of the target node.

func (*QEMUTarget) SSHKey

func (t *QEMUTarget) SSHKey() string

SSHKey returns the private SSH key path associated with a previously embedded authorized key.

func (*QEMUTarget) Serial

func (t *QEMUTarget) Serial() io.ReadWriteCloser

Serial returns the serial device associated with the target for serial i/o.

func (*QEMUTarget) Start

func (t *QEMUTarget) Start(ctx context.Context, images []bootserver.Image, args []string, _ string) (err error)

Start starts the QEMU target.

func (*QEMUTarget) Stop

func (t *QEMUTarget) Stop(ctx context.Context) error

Stop stops the QEMU target.

func (*QEMUTarget) Wait

func (t *QEMUTarget) Wait(ctx context.Context) error

Wait waits for the QEMU target to stop.

type Target

type Target interface {
	// Nodename returns the name of the target node.
	Nodename() string

	// Serial returns the serial device associated with the target for serial i/o.
	Serial() io.ReadWriteCloser

	// SSHKey returns the private key corresponding an authorized SSH key of the target.
	SSHKey() string

	// Start starts the target.
	Start(ctx context.Context, images []bootserver.Image, args []string, serialSocketPath string) error

	// Stop stops the target.
	Stop(context.Context) error

	// Wait waits for the target to finish running.
	Wait(context.Context) error
}

Target represents a fuchsia instance.

Jump to

Keyboard shortcuts

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