device

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: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client manages the connection to the device.

func NewClient

func NewClient(
	ctx context.Context,
	deviceFinder *DeviceFinder,
	deviceResolver DeviceResolver,
	privateKey ssh.Signer,
	sshConnectBackoff retry.Backoff,
	workaroundBrokenTimeSkip bool,
) (*Client, error)

NewClient creates a new Client.

func (*Client) Close

func (c *Client) Close()

Close the Client connection

func (*Client) DeleteRemotePath

func (c *Client) DeleteRemotePath(ctx context.Context, path string) error

DeleteRemotePath deletes a file off the remote device.

func (*Client) DisconnectionListener

func (c *Client) DisconnectionListener() <-chan struct{}

DisconnectionListener returns a channel that is closed when the client is disconnected.

func (*Client) ExpectDisconnect

func (c *Client) ExpectDisconnect(ctx context.Context, f func() error) error

func (*Client) ExpectReboot

func (c *Client) ExpectReboot(ctx context.Context, f func() error) error

ExpectReboot prepares a device for a reboot, runs a closure `f` that should reboot the device, then finally verifies whether a reboot actually took place. It does this by writing a unique value to `/tmp/ota_test_should_reboot`, then executing the closure. After we reconnect, we check if `/tmp/ota_test_should_reboot` exists. If not, exit with `nil`. Otherwise, we failed to reboot, or some competing test is also trying to reboot the device. Either way, err out.

func (*Client) GetSSHConnection

func (c *Client) GetSSHConnection(ctx context.Context) (string, error)

func (*Client) GetSystemImageMerkle

func (c *Client) GetSystemImageMerkle(ctx context.Context) (string, error)

func (*Client) Name

func (c *Client) Name() string

func (*Client) Pave

func (c *Client) Pave(ctx context.Context, build artifacts.Build) error

Pave paves the device to the specified build. It assumes the device is already in recovery, since there are multiple ways to get a device into recovery.

func (*Client) ReadRemotePath

func (c *Client) ReadRemotePath(ctx context.Context, path string) ([]byte, error)

ReadRemotePath read a file off the remote device.

func (*Client) Reboot

func (c *Client) Reboot(ctx context.Context) error

Reboot asks the device to reboot. It waits until the device reconnects before returning.

func (*Client) RebootToRecovery

func (c *Client) RebootToRecovery(ctx context.Context) error

RebootToRecovery asks the device to reboot into the recovery partition. It waits until the device disconnects before returning.

func (*Client) Reconnect

func (c *Client) Reconnect(ctx context.Context) error

func (*Client) RegisterPackageRepository

func (c *Client) RegisterPackageRepository(ctx context.Context, repo *packages.Server, createRewriteRule bool) error

RegisterPackageRepository adds the repository as a repository inside the device.

func (*Client) RemoteFileExists

func (c *Client) RemoteFileExists(ctx context.Context, path string) (bool, error)

RemoteFileExists checks if a file exists on the remote device.

func (*Client) Run

func (c *Client) Run(ctx context.Context, command []string, stdout io.Writer, stderr io.Writer) error

Run a command to completion on the remote device and write STDOUT and STDERR to the passed in io.Writers.

func (*Client) ServePackageRepository

func (c *Client) ServePackageRepository(
	ctx context.Context,
	repo *packages.Repository,
	name string,
	createRewriteRule bool,
) (*packages.Server, error)

func (*Client) StartRpcSession

func (c *Client) StartRpcSession(ctx context.Context, repo *packages.Repository) (*sl4f.Client, error)

func (*Client) ValidateStaticPackages

func (c *Client) ValidateStaticPackages(ctx context.Context) error

ValidateStaticPackages checks that all static packages have no missing blobs.

type ConstantHostResolver

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

ConstnatAddressResolver returns a fixed hostname for the specified nodename.

func NewConstantHostResolver

func NewConstantHostResolver(ctx context.Context, nodeName string, host string) ConstantHostResolver

NewConstantAddressResolver constructs a fixed host.

func (ConstantHostResolver) NodeNames

func (r ConstantHostResolver) NodeNames() []string

func (ConstantHostResolver) ResolveName

func (r ConstantHostResolver) ResolveName(ctx context.Context) (string, error)

type DeviceEntry

type DeviceEntry struct {
	Address  string
	NodeName string
}

DeviceEntry describes the result from `List` and `ListNetboot`.

type DeviceFinder

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

DeviceFinder wraps the logic around the `device-finder` tool. This tools allows the discovery and resolution of device node names to their IP addresses.

func NewDeviceFinder

func NewDeviceFinder(deviceFinderPath string) *DeviceFinder

NewDeviceFinder constructs a `DeviceFinder` type wrapping the `device-finder` path pointed to by the `deviceFinderPath`.

func (*DeviceFinder) List

func (d *DeviceFinder) List(ctx context.Context, mode DeviceFinderMode, nodeNames ...string) ([]DeviceEntry, error)

List wraps running `device-finder list ...`. This can be filtered down for specific nodenames.

func (*DeviceFinder) Resolve

func (d *DeviceFinder) Resolve(ctx context.Context, mode DeviceFinderMode, nodeNames []string) (DeviceEntry, error)

Resolves nodenames to an IP address.

type DeviceFinderMode

type DeviceFinderMode int

DeviceFinderMode selects the protocol to use to resolve a nodename to an IP Address.

const (
	// Mdns uses the mDNS protocol to resolve a nodename to an IP address.
	Mdns DeviceFinderMode = iota

	// Netboot uses the netboot protocol to resolve a nodename to an IP address.
	Netboot
)

func (DeviceFinderMode) String

func (m DeviceFinderMode) String() string

type DeviceFinderResolver

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

DeviceFinderResolver uses `device-finder` to resolve a nodename into a hostname. The logic here should match get-fuchsia-device-addr (//tools/devshell/lib/vars.sh).

func NewDeviceFinderResolver

func NewDeviceFinderResolver(ctx context.Context, deviceFinder *DeviceFinder, nodeName string) (*DeviceFinderResolver, error)

NewDeviceFinderResolver constructs a new `DeviceFinderResolver` for the specific

func (*DeviceFinderResolver) NodeNames

func (r *DeviceFinderResolver) NodeNames() []string

func (*DeviceFinderResolver) ResolveName

func (r *DeviceFinderResolver) ResolveName(ctx context.Context) (string, error)

type DeviceResolver

type DeviceResolver interface {
	// NodeNames returns a list of nodenames for a device.
	NodeNames() []string

	// Resolve the device's nodename into a hostname.
	ResolveName(ctx context.Context) (string, error)
}

type EstimatedMonotonicTime

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

EstimatedMonotonicTime is a structure that will return a string estimate of a device's current monotonic time.

func NewEstimatedMonotonicTime

func NewEstimatedMonotonicTime(client *Client, suffix string) *EstimatedMonotonicTime

NewEstimatedMonotonicTime constructs a new EstimatedMonotonicTime.

func (*EstimatedMonotonicTime) String

func (p *EstimatedMonotonicTime) String() string

String() will return a string prefixed by the device's monotonic time.

Jump to

Keyboard shortcuts

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