Documentation
¶
Overview ¶
DLC constants and helpers
Firmware constants and common types ¶
Common helper methods ¶
Partition constants and helpers ¶
Service interfaces bases for state-machine construction ¶
General utility related bits for provisioning.
Index ¶
- Constants
- Variables
- func BucketJoin(bucket string, append string) string
- func CreateLogFile(fullPath string) (*os.File, error)
- func ExecuteStateMachine(ctx context.Context, cs ServiceState, log *log.Logger) (api.InstallResponse_Status, *anypb.Any, error)
- func GetMiniOSPartitions() []string
- func NewLogger(logFile *os.File) *log.Logger
- func ParseAndroidProvisionRequest(path string) (*api.AndroidProvisionRequest, error)
- func ParseCrosProvisionRequest(path string) (*api.CrosProvisionRequest, error)
- func ParseInstallRequest(path string) (*api.InstallRequest, error)
- func ParseProvisionStartupRequest(path string) (*api.ProvisionStartupRequest, error)
- func WaitLongRunningOp(ctx context.Context, log *log.Logger, operation *longrunning.Operation) (*anypb.Any, error)
- func WrapStringInAny(s string) *anypb.Any
- type CommandInterface
- type FirmwareManifest
- type FirmwareManifestData
- type PartitionInfo
- type ServiceAdapter
- func (s ServiceAdapter) CopyData(ctx context.Context, sourceUrl string, destPath string) error
- func (s ServiceAdapter) CreateDirectories(ctx context.Context, dirs []string) error
- func (s ServiceAdapter) DeleteDirectory(ctx context.Context, dir string) error
- func (s ServiceAdapter) FetchFile(ctx context.Context, path string) (io.ReadCloser, error)
- func (s ServiceAdapter) ForceReconnectWithBackoff(ctx context.Context) error
- func (s ServiceAdapter) PathExists(ctx context.Context, path string) (bool, error)
- func (s ServiceAdapter) PipeData(ctx context.Context, sourceUrl string, pipeCommand string) error
- func (s ServiceAdapter) Restart(ctx context.Context) error
- func (s ServiceAdapter) RunCmd(ctx context.Context, cmd string, args []string) (string, error)
- type ServiceAdapterInterface
- type ServiceInterface
- type ServiceState
Constants ¶
const ( DlcCacheDir = "/var/cache/dlc" DlcImage = "dlc.img" DlcLibDir = "/var/lib/dlcservice/dlc" DlcPackage = "package" DlcVerified = "verified" DlcserviceUtil = "dlcservice_util" )
const ( FirmwareUpdaterPath = "/usr/sbin/chromeos-firmwareupdate" CrossystemCurrentFirmwareSlotKey = "mainfw_act" CrossystemNextFirmwareSlotKey = "fw_try_next" )
const ( PartitionNumStateful = "1" PartitionNumKernelA = "2" PartitionNumKernelB = "4" PartitionNumRootA = "3" PartitionNumRootB = "5" PartitionNumMiniOSA = "9" PartitionNumMiniOSB = "10" )
const ( StatefulPath = "/mnt/stateful_partition" UpdateStatefulFilePath = StatefulPath + "/.update_available" // ProvisionMarker - This file acts as a flag to signal failed provisions. // As we create the file in stateful, that means that if provision // is successful it will be overwritten, meaning that the fact it exists // beyond a provision run means it must have failed. // This file should be created on every OS provision start. ProvisionMarker = "/var/tmp/provision_failed" )
const (
KvmDevicePath = "/dev/kvm"
)
const (
MiniOSUnsupportedGUIDPartition = "09845860-705F-4BB5-B16C-8A8A099CAF52"
)
Variables ¶
var ActiveDlcMap = map[string]string{PartitionNumRootA: dlcSlotA, PartitionNumRootB: dlcSlotA}
var InactiveDlcMap = map[string]string{PartitionNumRootA: dlcSlotB, PartitionNumRootB: dlcSlotB}
Functions ¶
func BucketJoin ¶
BucketJoin is equivalent to Path.Join(), but for gs buckets. This is necessary as the BUF removes double-slashes, which mangles the URI. Returns the bucket and append as a formed bucket URI.
func CreateLogFile ¶
CreateLogFile creates a file and its parent directory for logging purpose.
func ExecuteStateMachine ¶
func ExecuteStateMachine(ctx context.Context, cs ServiceState, log *log.Logger) (api.InstallResponse_Status, *anypb.Any, error)
ExecuteStateMachine runs a specific state machine
func GetMiniOSPartitions ¶
func GetMiniOSPartitions() []string
GetMiniOSPartitions returns the partition numbers for miniOS
func ParseAndroidProvisionRequest ¶
func ParseAndroidProvisionRequest(path string) (*api.AndroidProvisionRequest, error)
ParseAndroidProvisionRequest parses AndroidProvisionRequest input request data from the input file.
func ParseCrosProvisionRequest ¶
func ParseCrosProvisionRequest(path string) (*api.CrosProvisionRequest, error)
ParseCrosProvisionRequest parses CrosProvisionRequest input request data from the input file.
func ParseInstallRequest ¶
func ParseInstallRequest(path string) (*api.InstallRequest, error)
ParseInstallRequest parses InstallRequest input request data from the input file.
func ParseProvisionStartupRequest ¶
func ParseProvisionStartupRequest(path string) (*api.ProvisionStartupRequest, error)
ParseProvisionStartupRequest parses ProvisionStartupRequest input request data from the input file.
func WaitLongRunningOp ¶
func WrapStringInAny ¶
Types ¶
type CommandInterface ¶
type CommandInterface interface { //Execute runs the command Execute(log *log.Logger) error // Revert reverts the command Revert() error // GetErrorMessage returns a crafted error message in case of failure GetErrorMessage() string // GetStatus returns the proto status response for the message GetStatus() api.InstallResponse_Status }
CommandInterface executes a specific step in a state. Note commands are
intended to interact with a ServiceInterface and as such will have side-effects.
type FirmwareManifest ¶
type FirmwareManifest map[string]FirmwareManifestData
type FirmwareManifestData ¶
type FirmwareManifestData struct { Host struct { Versions struct { Ro string `json:"ro"` Rw string `json:"rw"` } `json:"versions"` Keys struct { Root string `json:"root"` Recovery string `json:"recovery"` } `json:"keys"` Image string `json:"image"` } `json:"host"` Ec struct { Versions struct { Ro string `json:"ro"` Rw string `json:"rw"` } `json:"versions"` Image string `json:"image"` } `json:"ec"` SignatureId string `json:"signature_id"` }
type PartitionInfo ¶
type PartitionInfo struct { // The active + inactive kernel device partitions (e.g. /dev/nvme0n1p2). ActiveKernel string ActiveKernelNum string InactiveKernel string InactiveKernelNum string // The active + inactive root device partitions (e.g. /dev/nvme0n1p3). ActiveRoot string InactiveRoot string // The A + B miniOS device partitions. MiniOSA string MiniOSB string // The stateful partition path. Stateful string }
partitionsInfo holds active/inactive root + kernel partition information.
func GetPartitionInfo ¶
func GetPartitionInfo(root string, rootDisk string, rootPartNum string) PartitionInfo
GetPartitionInfo retrieves relevant kernel and root info for a specific root
type ServiceAdapter ¶
type ServiceAdapter struct {
// contains filtered or unexported fields
}
func NewServiceAdapter ¶
func NewServiceAdapter(dutClient api.DutServiceClient, noReboot bool) ServiceAdapter
func (ServiceAdapter) CreateDirectories ¶
func (s ServiceAdapter) CreateDirectories(ctx context.Context, dirs []string) error
Create directories is a thin wrapper around an mkdir command. Done here as it is expected to be reused often by many services.
func (ServiceAdapter) DeleteDirectory ¶
func (s ServiceAdapter) DeleteDirectory(ctx context.Context, dir string) error
DeleteDirectory is a thin wrapper around an rm command. Done here as it is expected to be reused often by many services.
func (ServiceAdapter) FetchFile ¶
func (s ServiceAdapter) FetchFile(ctx context.Context, path string) (io.ReadCloser, error)
FetchFile downloads a file from the DUT.
func (ServiceAdapter) ForceReconnectWithBackoff ¶
func (s ServiceAdapter) ForceReconnectWithBackoff(ctx context.Context) error
ForceReconnectWithBackoff is a thin wrapper around DUT service's ForceReconnectWithBackoff.
func (ServiceAdapter) PathExists ¶
PathExists determines if a path exists in a DUT
func (ServiceAdapter) PipeData ¶
PipeData uses the caching infrastructure to bring a file locally, allowing a user to pipe the result to any desired application.
type ServiceAdapterInterface ¶
type ServiceAdapterInterface interface { // RunCmd takes a command and argument and executes it remotely in the DUT, // returning the stdout as the string result and any execution error as the error. // The args are not quoted in any way, so beware of spaces and shell variables. RunCmd(ctx context.Context, cmd string, args []string) (string, error) // Restart restarts a DUT (allowing cros-dut to reconnect for connection caching). Restart(ctx context.Context) error // PathExists is a simple wrapper for RunCmd for the sake of simplicity. If // the path exists True is returned, else False. An error implies a // a communication failure. PathExists(ctx context.Context, path string) (bool, error) // PipeData uses the caching infrastructure to bring an image into the lab. // Contrary to CopyData, the data here is pipeable to whatever is fed into // pipeCommand, rather than directly placed locally. PipeData(ctx context.Context, sourceUrl string, pipeCommand string) error // CopyData uses the caching infrastructure to copy a remote image to // the local path specified by destPath. CopyData(ctx context.Context, sourceUrl string, destPath string) error // DeleteDirectory is a simple wrapper for RunCmd for the sake of simplicity. DeleteDirectory(ctx context.Context, dir string) error // CreateDirectory is a simple wrapper for RunCmd for the sake of simplicity. // All directories specified in the array will be created. // As this uses "-p" option, subdirs are created regardless of whether parents // exist or not. CreateDirectories(ctx context.Context, dirs []string) error // FetchFile downloads a file from the DUT. FetchFile(ctx context.Context, path string) (io.ReadCloser, error) // ForceReconnectWithBackoff waits for the DUT to come back up/reconnect. ForceReconnectWithBackoff(ctx context.Context) error }
ServiceAdapters are used to interface with a DUT All methods here are proxies to cros-dut (with some additions for simplicity)
type ServiceInterface ¶
type ServiceInterface interface { // GetFirstState returns the first state in this state machine GetFirstState() ServiceState // CleanupOnFailure "undoes" the service execution to the extent possible, // removing temporary files, and, if feasible, reverting the run commands. // CleanupOnFailure function will be called if any ServiceState returns an // error when running Execute(). // |states| will include all ServiceStates that were run; naturally, all of // them but last one would have succeeded to Execute(). // |executionErr| is the error returned by Execute() of the last (failed) // ServiceState. CleanupOnFailure(states []ServiceState, executionErr error) error }
ServiceInterface represents the state machine for this specific service installation. It holds installation metadata and provides helpers, including the generator of the first state for that installation.
type ServiceState ¶
type ServiceState interface { // Execute Runs the state Execute(ctx context.Context, log *log.Logger) (*anypb.Any, api.InstallResponse_Status, error) // Next gets the next state in the state machine Next() ServiceState // Name gets the fully qualified name of this state Name() string }
ServiceState is a single state representation.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
DLC constants and helpers
|
DLC constants and helpers |
Plain Old Go Object repo for machine metadata
|
Plain Old Go Object repo for machine metadata |
Executor defines a state initializer for each state.
|
Executor defines a state initializer for each state. |