components

package
v0.0.0-...-49abd51 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Provide interfaces to work with external communications. To generate mocks use: `mockgen -source=internal/components/components.go -destination internal/components/mocks/components.go -package mocks`

Index

Constants

View Source
const (
	// Default timeout recommended to use when call servod.
	// Some usbkey actions can take 10+ seconds.
	// TODO(b/240605067): Reduce default to 10 seconds by add specific timeout for special commands.
	ServodDefaultTimeoutSec = 20
	ServodDefaultTimeout    = ServodDefaultTimeoutSec * time.Second

	// Default servod call methods.
	ServodSet = "set"
	ServodGet = "get"
	ServodDoc = "doc"
)
View Source
const DefaultFilePermissions fs.FileMode = 0666

DefaultFilePermissions is the default file permissions for log files. Currently, we allow everyone to read and write and nobody to execute.

Variables

View Source
var (
	// ErrCodeTag is the key value pair for storing the error code for the linux command.
	ErrCodeTag = errors.NewTagKey("error_code")

	// StdErrTag is the key value pair for storing the error code
	// associated with the standard error
	StdErrTag = errors.NewTagKey("std_error")

	// 127: linux command line error of command not found.
	SSHErrorCLINotFound = errors.BoolTag{Key: errors.NewTagKey("ssh_error_cli_not_found")}

	// 124: linux command line error of command timeout.
	SSHErrorLinuxTimeout = errors.BoolTag{Key: errors.NewTagKey("linux_timeout")}

	// other linux error tag.
	GeneralError = errors.BoolTag{Key: errors.NewTagKey("general_error")}

	// internal error tag.
	SSHErrorInternal = errors.BoolTag{Key: errors.NewTagKey("ssh_error_internal")}

	// -1: fail to create ssh session.
	FailToCreateSSHErrorInternal = errors.BoolTag{Key: errors.NewTagKey("fail_to_create_ssh_error_internal")}

	// -2: session is down, but the server sends no confirmation of the exit status.
	NoExitStatusErrorInternal = errors.BoolTag{Key: errors.NewTagKey("no_exit_status_error_internal")}

	// other internal error tag.
	OtherErrorInternal = errors.BoolTag{Key: errors.NewTagKey("other_error_internal")}
)

Functions

This section is empty.

Types

type HostAccess

type HostAccess interface {
	// Run executes command by SSH and wait to receive results of the execution.
	//
	// For all exit codes != `0` an error will be generated.
	Run(ctx context.Context, timeout time.Duration, command string, args ...string) (SSHRunResponse, error)
	// Run executes command by SSH and don't wait for results of the execution.
	//
	// For all exit codes != `0` an error will be generated.
	RunBackground(ctx context.Context, timeout time.Duration, command string, args ...string) (SSHRunResponse, error)
	// Ping the host.
	//
	// If error is nil ping is successful.
	Ping(ctx context.Context, pingCount int) error
}

HostAccess provides access to the host to run commands by SSH or ping it.

type Pinger

type Pinger func(ctx context.Context, count int) error

Pinger defines the type for a function that will execute a ping command on a host, and returns error if something went wrong.

type Runner

type Runner func(context.Context, time.Duration, string, ...string) (string, error)

Runner defines the type for a function that will execute a command on a host, and returns the result as a single line.

type SSHRunResponse

type SSHRunResponse interface {
	// Provides exit code.
	GetExitCode() int32
	// Provides standard output.
	GetStdout() string
	// Provides standard error output.
	GetStderr() string
}

SSHRunResponse represents results of executed command by SSH.

type Servod

type Servod interface {
	// Call calls servod method with params.
	Call(ctx context.Context, method string, timeout time.Duration, args ...interface{}) (*xmlrpc.Value, error)
	// Get read value by requested command.
	Get(ctx context.Context, cmd string) (*xmlrpc.Value, error)
	// Set sets value to provided command.
	Set(ctx context.Context, cmd string, val interface{}) error
	// Has verifies that command is known.
	// Error is returned if the control is not listed in the doc.
	Has(ctx context.Context, command string) error
	// Port provides port used for running servod daemon.
	Port() int
}

Servod defines the interface to communicate with servod daemon.

Directories

Path Synopsis
android
adb
Package btpeer contains utilities for accessing and managing btpeer devices.
Package btpeer contains utilities for accessing and managing btpeer devices.
chameleond
Package chameleond contains utilities for managing chameleond releases on btpeers devices.
Package chameleond contains utilities for managing chameleond releases on btpeers devices.
image
Package image contains utilities for managing btpeer images.
Package image contains utilities for managing btpeer images.
Package cache provides utilities for preforming cache-related operations.
Package cache provides utilities for preforming cache-related operations.
cft
Package cft contains methods to work with CFT containers.
Package cft contains methods to work with CFT containers.
adb
Package adb contains methods to work with an ADB-base container.
Package adb contains methods to work with an ADB-base container.
crosdut
Package crosdut contains methods to work with an cros-dut-base container.
Package crosdut contains methods to work with an cros-dut-base container.
foilprovision
Package foilprovision contains methods to work with an foil-provision container.
Package foilprovision contains methods to work with an foil-provision container.
servonexus
Package servonexus contains methods to work with an servo-nexus container.
Package servonexus contains methods to work with an servo-nexus container.
amt
Package amt implements just enough WS-Management to query and set the DUT's power state.
Package amt implements just enough WS-Management to query and set the DUT's power state.
android
Package android contains functions to work with AndroidOS on ChromeOS devices.
Package android contains functions to work with AndroidOS on ChromeOS devices.
camera
Package camera contains utilities for auditing camera on DUTs.
Package camera contains utilities for auditing camera on DUTs.
cbi
CBI corruption detection and repair logic.
CBI corruption detection and repair logic.
cellular
Package cellular contains utilities for repairing cellular DUTs.
Package cellular contains utilities for repairing cellular DUTs.
cellular/starfish
Package starfish contains utilities for interacting with starfish devices.
Package starfish contains utilities for interacting with starfish devices.
firmware
Package firmware implements logic to update firmware for chromeOS devices.
Package firmware implements logic to update firmware for chromeOS devices.
rpm
storage
Package storage implements function to work with cros storages.
Package storage implements function to work with cros storages.
tpm
Package tpm provides function to work with TPM.
Package tpm provides function to work with TPM.
usb
vpd
Package vpd provide ability to read and update VPD values.
Package vpd provide ability to read and update VPD values.
Package dolos is commands related to interacting with dolos, a virtual power source for DUT's.
Package dolos is commands related to interacting with dolos, a virtual power source for DUT's.
Package linux provides utilities for preforming tasks on linux components.
Package linux provides utilities for preforming tasks on linux components.
Package mh contains functions to work with mobileharness.
Package mh contains functions to work with mobileharness.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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