Documentation
¶
Overview ¶
Package execs provides collection of execution functions for actions and ability to execute them.
Index ¶
- Constants
- Variables
- func Exist(name string) bool
- func Register(name string, f ExecFunction)
- func Run(ctx context.Context, ei *ExecInfo) (rErr error)
- type ExecFunction
- type ExecInfo
- func (ei *ExecInfo) AddObservation(observation *metrics.Observation)
- func (ei *ExecInfo) CopyDirectoryFrom(ctx context.Context, resourceName, srcDir, destDir string) error
- func (ei *ExecInfo) CopyFrom(ctx context.Context, resourceName, srcFile, destDir string) error
- func (ei *ExecInfo) DefaultHostAccess() *hostAccess
- func (ei *ExecInfo) DefaultPinger() components.Pinger
- func (ei *ExecInfo) DefaultRunner() components.Runner
- func (ei *ExecInfo) GetAccess() tlw.Access
- func (ei *ExecInfo) GetActionArgs(ctx context.Context) ParsedArgs
- func (ei *ExecInfo) GetActiveResource() string
- func (ei *ExecInfo) GetAdditionalMetrics() []*metrics.Action
- func (ei *ExecInfo) GetAndroid() *tlw.Android
- func (ei *ExecInfo) GetChromeos() *tlw.ChromeOS
- func (ei *ExecInfo) GetDeviceName(code string) (string, error)
- func (ei *ExecInfo) GetDut() *tlw.Dut
- func (ei *ExecInfo) GetExecArgs() []string
- func (ei *ExecInfo) GetExecTimeout() time.Duration
- func (ei *ExecInfo) GetLogRoot() string
- func (ei *ExecInfo) GetMetrics() metrics.Metrics
- func (ei *ExecInfo) NewBackgroundRunner(host string) components.Runner
- func (ei *ExecInfo) NewHostAccess(host string) *hostAccess
- func (ei *ExecInfo) NewLogger() logger.Logger
- func (ei *ExecInfo) NewMetric(kind string) *metrics.Action
- func (ei *ExecInfo) NewPinger(resource string) components.Pinger
- func (ei *ExecInfo) NewRunner(host string) components.Runner
- func (ei *ExecInfo) NewServod() components.Servod
- func (ei *ExecInfo) RPMAction(ctx context.Context, hostname string, o *tlw.RPMOutlet, ...) error
- type ParsedArgs
- func (parsedArgs ParsedArgs) AsBool(ctx context.Context, key string, defaultValue bool) bool
- func (parsedArgs ParsedArgs) AsDuration(ctx context.Context, key string, defaultValue int, unit time.Duration) time.Duration
- func (parsedArgs ParsedArgs) AsFloat64(ctx context.Context, key string, defaultValue float64) float64
- func (parsedArgs ParsedArgs) AsInt(ctx context.Context, key string, defaultValue int) int
- func (parsedArgs ParsedArgs) AsString(ctx context.Context, key, defaultValue string) string
- func (parsedArgs ParsedArgs) AsStringSlice(ctx context.Context, key string, defaultValue []string) []string
- func (parsedArgs ParsedArgs) Has(key string) bool
- type RunArgs
- type Runner
Constants ¶
const ( // This character separates the name and values for extra // arguments defined for actions. DefaultSplitter = ":" // This character demarcates the individual values among // multi-valued extra arguments defined for actions. MultiValueSplitter = "," )
Variables ¶
var ( // Error tag to track error with request to start critical actions over. PlanStartOverTag = errors.BoolTag{Key: errors.NewTagKey("plan-start-over")} // Error tag to track error with request to stop execution of the current plan. PlanAbortTag = errors.BoolTag{Key: errors.NewTagKey("plan-abort")} )
var ( // TODO: need remove these errors to use them from components. ErrCodeTag = components.ErrCodeTag StdErrTag = components.StdErrTag SSHErrorCLINotFound = components.SSHErrorCLINotFound SSHErrorLinuxTimeout = components.SSHErrorLinuxTimeout GeneralError = components.GeneralError SSHErrorInternal = components.SSHErrorInternal FailToCreateSSHErrorInternal = components.FailToCreateSSHErrorInternal NoExitStatusErrorInternal = components.NoExitStatusErrorInternal OtherErrorInternal = components.OtherErrorInternal )
Functions ¶
func Register ¶
func Register(name string, f ExecFunction)
Register registers new exec function to be used with recovery engine. We panic if a name is reused.
Types ¶
type ExecFunction ¶
ExecFunction represents an execution function of the action. The single exec can be associated with one or more actions.
type ExecInfo ¶
type ExecInfo struct {
// contains filtered or unexported fields
}
ExecInfo holds all data required to run exec. The struct created every time new for each exec run.
func NewExecInfo ¶
func NewExecInfo(runArgs *RunArgs, name string, actionArgs []string, actionTimeout time.Duration, metric *metrics.Action) *ExecInfo
NewExecInfo creates new instance of ExecInfo.
func (*ExecInfo) AddObservation ¶
func (ei *ExecInfo) AddObservation(observation *metrics.Observation)
AddObservation adds observation to the metric assigned to the current exec.
func (*ExecInfo) CopyDirectoryFrom ¶
func (ei *ExecInfo) CopyDirectoryFrom(ctx context.Context, resourceName, srcDir, destDir string) error
CopyDirectoryFrom copies a directory from resource to localhost.
func (*ExecInfo) DefaultHostAccess ¶
func (ei *ExecInfo) DefaultHostAccess() *hostAccess
DefaultHostAccess returns HostAccess for current resource name specified per plan.
func (*ExecInfo) DefaultPinger ¶
func (ei *ExecInfo) DefaultPinger() components.Pinger
DefaultPinger returns pinger for current resource name specified per plan.
func (*ExecInfo) DefaultRunner ¶
func (ei *ExecInfo) DefaultRunner() components.Runner
DefaultRunner returns runner for current resource name specified per plan.
func (*ExecInfo) GetActionArgs ¶
func (ei *ExecInfo) GetActionArgs(ctx context.Context) ParsedArgs
GetActionArgs returns parsed action arguments with default splitter.
func (*ExecInfo) GetActiveResource ¶
GetActiveResource returns what is active resource.
func (*ExecInfo) GetAdditionalMetrics ¶
GetAdditionalMetrics returns additional metrics created by execs.
func (*ExecInfo) GetAndroid ¶
GetAndroid returns Android device from DUT.
func (*ExecInfo) GetChromeos ¶
GetChromeos returns ChromeOS device from DUT.
func (*ExecInfo) GetDeviceName ¶
GetDeviceName returns name of the devices requested by code.
func (*ExecInfo) GetExecArgs ¶
GetExecArgs returns list of arguments provided for an exec.
func (*ExecInfo) GetExecTimeout ¶
GetExecTimeout returns timeout specified for an exec.
func (*ExecInfo) GetLogRoot ¶
GetLogRoot returns path to logs directory.
func (*ExecInfo) GetMetrics ¶
GetMetrics returns Metrics.
func (*ExecInfo) NewBackgroundRunner ¶
func (ei *ExecInfo) NewBackgroundRunner(host string) components.Runner
NewBackgroundRunner returns runner for requested resource specified per plan.
TODO(b/222698101): At this time this method is a placeholder. This will eventually be replaced with an implementation that will submit a command for background execution, and will return without waiting for it to complete.
func (*ExecInfo) NewHostAccess ¶
NewHostAccess creates new instance of HostAccess.
func (*ExecInfo) NewPinger ¶
func (ei *ExecInfo) NewPinger(resource string) components.Pinger
NewPinger returns pinger for requested resource.
func (*ExecInfo) NewRunner ¶
func (ei *ExecInfo) NewRunner(host string) components.Runner
NewRunner returns a function of type Runner that executes a command on a host and returns the results as a single line. This function defines the specific host on which the command will be executed. Examples of such specific hosts can be the DUT, or the servo-host etc.
func (*ExecInfo) NewServod ¶
func (ei *ExecInfo) NewServod() components.Servod
NewServod returns a struct of type components.Servod that allowes communication with servod service.
type ParsedArgs ¶
ParsedArgs is the map representing key-value pairs parsed from extra args in the configuration.
func ParseActionArgs ¶
func ParseActionArgs(ctx context.Context, actionArgs []string, splitter string) ParsedArgs
ParseActionArgs parses the action arguments using the splitter, and returns ParsedArgs object containing key and values in the action arguments. If any mal-formed action arguments are found their value is set to empty string.
func (ParsedArgs) AsBool ¶
AsBool returns the value for the passed key as a boolean. If the key does not exist in the parsed arguments, the passed defaultValue is returned.
func (ParsedArgs) AsDuration ¶
func (parsedArgs ParsedArgs) AsDuration(ctx context.Context, key string, defaultValue int, unit time.Duration) time.Duration
AsDuration returns the value of the passed key as type: time.Duration. If the value cannot be interpreted as int, then the passed defaultValue is returned.
@params unit: the unit of the time Duration, can be Nanosecond, Mircrosecond, Millisecond, Second, Minute
func (ParsedArgs) AsFloat64 ¶
func (parsedArgs ParsedArgs) AsFloat64(ctx context.Context, key string, defaultValue float64) float64
AsFloat64 returns the value for the passed key as a float64. If the value cannot be interpreted as int, then the passed defaultValue is returned.
func (ParsedArgs) AsInt ¶
AsInt returns the value for the passed key as a int. If the value cannot be interpreted as int, then the passed defaultValue is returned.
func (ParsedArgs) AsString ¶
func (parsedArgs ParsedArgs) AsString(ctx context.Context, key, defaultValue string) string
AsString returns the value for the passed key as a string. If the key does not exist in the parsed arguments, the passed defaultValue is returned.
func (ParsedArgs) AsStringSlice ¶
func (parsedArgs ParsedArgs) AsStringSlice(ctx context.Context, key string, defaultValue []string) []string
AsStringSlice returns the value for the passed key as a slice of string. If the key does not exist in the parsed arguments, an empty slice is returned.
func (ParsedArgs) Has ¶
func (parsedArgs ParsedArgs) Has(key string) bool
Has returns true if key is found.
type RunArgs ¶
type RunArgs struct { // Resource name targeted by plan. ResourceName string DUT *tlw.Dut Access tlw.Access // Logger prints message to the logs. Logger logger.Logger // Provide option to stop use steps. ShowSteps bool // Metrics records actions and observations. Metrics metrics.Metrics // EnableRecovery tells if recovery actions are enabled. EnableRecovery bool // SwarmingTaskID is the ID of the swarming task we're running under. SwarmingTaskID string // BuildbucketID is the ID of the buildbucket build we're running under. BuildbucketID string // LogRoot is an absolute path to a directory that contains logs. LogRoot string }
RunArgs holds plan input arguments.
Keep this type up to date with recovery.go:RunArgs . Also update recovery.go:runDUTPlans .
type Runner ¶
type Runner = components.Runner
Runner defines the type for a function that will execute a command on a host, and returns the result as a single line. TODO: Remove as we do not need extra type.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package amt contains execs used by the AMTManager peripheral.
|
Package amt contains execs used by the AMTManager peripheral. |
Package btpeer contains execs meant to be run on btpeer peripherals.
|
Package btpeer contains execs meant to be run on btpeer peripherals. |
CBI corruption detection and repair logic.
|
CBI corruption detection and repair logic. |
Package ctr contains functions with cros-tool-runner.
|
Package ctr contains functions with cros-tool-runner. |
Package dolos implements execs for dolos devices.
|
Package dolos implements execs for dolos devices. |
Package dut provides execs to work with proto data only.
|
Package dut provides execs to work with proto data only. |
Package env provide exec which based on environment variables.
|
Package env provide exec which based on environment variables. |
Package wifirouter initializes execs to be used with wifi routers.
|
Package wifirouter initializes execs to be used with wifi routers. |
controller
Package controller defines a common router controller class and implementations of this class per router type.
|
Package controller defines a common router controller class and implementations of this class per router type. |
ssh
Package ssh is a collection of ssh utilities for executing remote ssh commands on hosts.
|
Package ssh is a collection of ssh utilities for executing remote ssh commands on hosts. |
ssh/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |