platform

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: Apache-2.0 Imports: 30 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNeedSizeOrFile  = errors.New("Disks need either Size or BackingFile specified")
	ErrBothSizeAndFile = errors.New("Only one of Size and BackingFile can be specified")
)

Functions

func CheckMachine added in v0.2.0

func CheckMachine(ctx context.Context, m Machine) error

CheckMachine tests a machine for various error conditions such as ssh being available and no systemd units failing at the time ssh is reachable. It also ensures the remote system is running Container Linux by CoreOS or Red Hat CoreOS.

TODO(mischief): better error messages.

func CreateQEMUCommand added in v0.13.0

func CreateQEMUCommand(board, uuid, biosImage, consolePath, confPath, diskImagePath string, isIgnition bool, options MachineOptions) ([]string, []*os.File, error)

func EnableSelinux added in v0.2.0

func EnableSelinux(m Machine) error

Enable SELinux on a machine (skip on machines without SELinux support)

func GenerateFakeKey added in v0.13.0

func GenerateFakeKey() (string, error)

GenerateFakeKey generates a SSH key pair, returns the public key, and discards the private key. This is useful for droplets that don't need a public key, since DO & Azure insists on requiring one.

func InstallFile

func InstallFile(in io.Reader, m Machine, to string) error

InstallFile copies data from in to the path to on m.

func MakeCLDiskTemplate added in v0.13.0

func MakeCLDiskTemplate(inputPath string) (output *os.File, result error)

Copy Container Linux input image and specialize copy for running kola tests. Return FD to the copy, which is a deleted file. This is not mandatory; the tests will do their best without it.

func Manhole

func Manhole(m Machine) error

Manhole connects os.Stdin, os.Stdout, and os.Stderr to an interactive shell session on the Machine m. Manhole blocks until the shell session has ended. If os.Stdin does not refer to a TTY, Manhole returns immediately with a nil error.

func ReadFile added in v0.0.10

func ReadFile(m Machine, path string) (io.ReadCloser, error)

ReadFile returns a io.ReadCloser that streams the requested file. The caller should close the reader when finished.

func RebootMachine added in v0.7.0

func RebootMachine(m Machine, j *Journal) error

RebootMachine will reboot a given machine, provided the machine's journal.

func StartMachine added in v0.7.0

func StartMachine(m Machine, j *Journal) error

StartMachine will start a given machine, provided the machine's journal.

func StartReboot added in v0.3.0

func StartReboot(m Machine) error

Reboots a machine, stopping ssh first. Afterwards run CheckMachine to verify the system is back and operational.

func TransferFile added in v0.0.10

func TransferFile(src Machine, srcPath string, dst Machine, dstPath string) error

Copy a file between two machines in a cluster.

func Virtio added in v0.13.0

func Virtio(board, device, args string) string

The virtio device name differs between machine types but otherwise configuration is the same. Use this to help construct device args.

Types

type BaseCluster added in v0.2.0

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

func NewBaseCluster added in v0.2.0

func NewBaseCluster(bf *BaseFlight, rconf *RuntimeConfig) (*BaseCluster, error)

func (*BaseCluster) AddMach added in v0.2.0

func (bc *BaseCluster) AddMach(m Machine)

func (*BaseCluster) ConsoleOutput added in v0.6.0

func (bc *BaseCluster) ConsoleOutput() map[string]string

func (*BaseCluster) DelMach added in v0.2.0

func (bc *BaseCluster) DelMach(m Machine)

func (*BaseCluster) Destroy added in v0.2.0

func (bc *BaseCluster) Destroy()

Destroy destroys each machine in the cluster.

func (*BaseCluster) Distribution added in v0.12.0

func (bc *BaseCluster) Distribution() string

func (*BaseCluster) GetDiscoveryURL added in v0.2.0

func (bc *BaseCluster) GetDiscoveryURL(size int) (string, error)

XXX(mischief): i don't really think this belongs here, but it completes the interface we've established.

func (*BaseCluster) IgnitionVersion added in v0.13.0

func (bc *BaseCluster) IgnitionVersion() string

func (*BaseCluster) JournalOutput added in v0.12.0

func (bc *BaseCluster) JournalOutput() map[string]string

func (*BaseCluster) Keys added in v0.2.0

func (bc *BaseCluster) Keys() ([]*agent.Key, error)

func (*BaseCluster) Machines added in v0.2.0

func (bc *BaseCluster) Machines() []Machine

func (*BaseCluster) Name added in v0.2.0

func (bc *BaseCluster) Name() string

func (*BaseCluster) PasswordSSHClient added in v0.2.0

func (bc *BaseCluster) PasswordSSHClient(ip string, user string, password string) (*ssh.Client, error)

func (*BaseCluster) Platform added in v0.8.0

func (bc *BaseCluster) Platform() Name

func (*BaseCluster) RenderUserData added in v0.6.0

func (bc *BaseCluster) RenderUserData(userdata *conf.UserData, ignitionVars map[string]string) (*conf.Conf, error)

func (*BaseCluster) RuntimeConf added in v0.6.0

func (bc *BaseCluster) RuntimeConf() RuntimeConfig

func (*BaseCluster) SSH added in v0.2.0

func (bc *BaseCluster) SSH(m Machine, cmd string) ([]byte, []byte, error)

SSH executes the given command, cmd, on the given Machine, m. It returns the stdout and stderr of the command and an error. Leading and trailing whitespace is trimmed from each.

func (*BaseCluster) SSHClient added in v0.2.0

func (bc *BaseCluster) SSHClient(ip string) (*ssh.Client, error)

func (*BaseCluster) UserSSHClient added in v0.6.0

func (bc *BaseCluster) UserSSHClient(ip, user string) (*ssh.Client, error)

type BaseFlight added in v0.12.0

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

func NewBaseFlight added in v0.12.0

func NewBaseFlight(opts *Options, platform Name, ctPlatform string) (*BaseFlight, error)

func NewBaseFlightWithDialer added in v0.12.0

func NewBaseFlightWithDialer(opts *Options, platform Name, ctPlatform string, dialer network.Dialer) (*BaseFlight, error)

func (*BaseFlight) AddCluster added in v0.12.0

func (bf *BaseFlight) AddCluster(c Cluster)

func (*BaseFlight) Clusters added in v0.12.0

func (bf *BaseFlight) Clusters() []Cluster

func (*BaseFlight) DelCluster added in v0.12.0

func (bf *BaseFlight) DelCluster(c Cluster)

func (*BaseFlight) Destroy added in v0.12.0

func (bf *BaseFlight) Destroy()

Destroy destroys each Cluster in the Flight and closes the SSH agent.

func (*BaseFlight) Keys added in v0.12.0

func (bf *BaseFlight) Keys() ([]*agent.Key, error)

func (*BaseFlight) Name added in v0.12.0

func (bf *BaseFlight) Name() string

func (*BaseFlight) Platform added in v0.12.0

func (bf *BaseFlight) Platform() Name

type Cluster

type Cluster interface {
	// Platform returns the name of the platform.
	Platform() Name

	// Name returns a unique name for the Cluster.
	Name() string

	// NewMachine creates a new Container Linux machine.
	NewMachine(userdata *conf.UserData) (Machine, error)

	// Machines returns a slice of the active machines in the Cluster.
	Machines() []Machine

	// GetDiscoveryURL returns a new etcd discovery URL.
	GetDiscoveryURL(size int) (string, error)

	// Destroy terminates each machine in the cluster and frees any other
	// associated resources. It should log any failures; since they are not
	// actionable, it does not return an error
	Destroy()

	// ConsoleOutput returns a map of console output from destroyed
	// cluster machines.
	ConsoleOutput() map[string]string

	// JournalOutput returns a map of journal output from destroyed
	// cluster machines.
	JournalOutput() map[string]string

	// IgnitionVersion returns the version of Ignition supported by the
	// cluster
	IgnitionVersion() string
}

Cluster represents a cluster of machines within a single Flight.

type Disk added in v0.13.0

type Disk struct {
	Size        string   // disk image size in bytes, optional suffixes "K", "M", "G", "T" allowed. Incompatible with BackingFile
	BackingFile string   // raw disk image to use. Incompatible with Size.
	DeviceOpts  []string // extra options to pass to qemu. "serial=XXXX" makes disks show up as /dev/disk/by-id/virtio-<serial>
}

type Flight added in v0.12.0

type Flight interface {
	// NewCluster creates a new Cluster.
	NewCluster(rconf *RuntimeConfig) (Cluster, error)

	// Name returns a unique name for the Flight.
	Name() string

	// Platform returns the name of the platform.
	Platform() Name

	// Clusters returns a slice of the active Clusters.
	Clusters() []Cluster

	// Destroy terminates each cluster and frees any other associated
	// resources.  It should log any failures; since they are not
	// actionable, it does not return an error.
	Destroy()
}

Flight represents a group of Clusters within a single platform.

type Journal added in v0.3.0

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

Journal manages recording the journal of a Machine.

func NewJournal added in v0.3.0

func NewJournal(dir string) (*Journal, error)

NewJournal creates a Journal recorder that will log to "journal.txt" and "journal-raw.txt.gz" inside the given output directory.

func (*Journal) Destroy added in v0.3.0

func (j *Journal) Destroy()

func (*Journal) Read added in v0.10.0

func (j *Journal) Read() ([]byte, error)

There is no guarantee that anything is returned if called before Destroy

func (*Journal) Start added in v0.3.0

func (j *Journal) Start(ctx context.Context, m Machine) error

Start begins/resumes streaming the system journal to journal.txt.

type Machine

type Machine interface {
	// ID returns the plaform-specific machine identifier.
	ID() string

	// IP returns the machine's public IP.
	IP() string

	// PrivateIP returns the machine's private IP.
	PrivateIP() string

	// RuntimeConf returns the cluster's runtime configuration.
	RuntimeConf() RuntimeConfig

	// SSHClient establishes a new SSH connection to the machine.
	SSHClient() (*ssh.Client, error)

	// PasswordSSHClient establishes a new SSH connection using the provided credentials.
	PasswordSSHClient(user string, password string) (*ssh.Client, error)

	// SSH runs a single command over a new SSH connection.
	SSH(cmd string) ([]byte, []byte, error)

	// Reboot restarts the machine and waits for it to come back.
	Reboot() error

	// Destroy terminates the machine and frees associated resources. It should log
	// any failures; since they are not actionable, it does not return an error.
	Destroy()

	// ConsoleOutput returns the machine's console output if available,
	// or an empty string.  Only expected to be valid after Destroy().
	ConsoleOutput() string

	// JournalOutput returns the machine's journal output if available,
	// or an empty string.  Only expected to be valid after Destroy().
	JournalOutput() string
}

Machine represents a Container Linux instance.

func NewMachines

func NewMachines(c Cluster, userdata *conf.UserData, n int) ([]Machine, error)

NewMachines spawns n instances in cluster c, with each instance passed the same userdata.

type MachineOptions added in v0.13.0

type MachineOptions struct {
	AdditionalDisks []Disk
}

type Name added in v0.8.0

type Name string

Name is a unique identifier for a platform.

type Options added in v0.1.4

type Options struct {
	BaseName        string
	Distribution    string
	IgnitionVersion string
	SystemdDropins  []SystemdDropin

	// OSContainer is an image pull spec that can be given to the pivot service
	// in RHCOS machines to perform machine content upgrades.
	// When specified additional files & units will be automatically generated
	// inside of RenderUserData
	OSContainer string
}

Options contains the base options for all clusters.

type RuntimeConfig added in v0.6.0

type RuntimeConfig struct {
	OutputDir string

	NoSSHKeyInUserData bool // don't inject SSH key into Ignition/cloud-config
	NoSSHKeyInMetadata bool // don't add SSH key to platform metadata
	NoEnableSelinux    bool // don't enable selinux when starting or rebooting a machine
	AllowFailedUnits   bool // don't fail CheckMachine if a systemd unit has failed
}

RuntimeConfig contains cluster-specific configuration.

type SystemdDropin added in v0.9.0

type SystemdDropin struct {
	Unit     string
	Name     string
	Contents string
}

SystemdDropin is a userdata type agnostic struct representing a systemd dropin

Directories

Path Synopsis
api
aws
do
esx
machine
aws
do
esx

Jump to

Keyboard shortcuts

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