Documentation
¶
Overview ¶
Package controller defines a common router controller class and implementations of this class per router type.
Index ¶
- Constants
- func CleanWifiRouterFeatures(features []labapi.WifiRouterFeature) []labapi.WifiRouterFeature
- func CollectOverallTestbedWifiRouterFeatures(routers []*tlw.WifiRouterHost) []labapi.WifiRouterFeature
- func IdentifyRouterDeviceType(ctx context.Context, sshAccess ssh.Access, resource string) (labapi.WifiRouterDeviceType, error)
- func SortWifiRouterFeaturesByName(features []labapi.WifiRouterFeature)
- type AsusWrtRouterController
- func (c *AsusWrtRouterController) DeviceType() labapi.WifiRouterDeviceType
- func (c *AsusWrtRouterController) Features() ([]labapi.WifiRouterFeature, error)
- func (c *AsusWrtRouterController) FetchAsusModel(ctx context.Context) error
- func (c *AsusWrtRouterController) Model() (string, error)
- func (c *AsusWrtRouterController) Reboot(ctx context.Context) error
- func (c *AsusWrtRouterController) Runner() components.Runner
- func (c *AsusWrtRouterController) WifiRouterHost() *tlw.WifiRouterHost
- type CacheAccess
- type ChromeOSGaleRouterController
- func (c *ChromeOSGaleRouterController) DeviceType() labapi.WifiRouterDeviceType
- func (c *ChromeOSGaleRouterController) Features() ([]labapi.WifiRouterFeature, error)
- func (c *ChromeOSGaleRouterController) Model() (string, error)
- func (c *ChromeOSGaleRouterController) Reboot(ctx context.Context) error
- func (c *ChromeOSGaleRouterController) Runner() components.Runner
- func (c *ChromeOSGaleRouterController) WifiRouterHost() *tlw.WifiRouterHost
- type OpenWrtRouterController
- func (c *OpenWrtRouterController) AssertHasExpectedImage() error
- func (c *OpenWrtRouterController) DeviceType() labapi.WifiRouterDeviceType
- func (c *OpenWrtRouterController) Features() ([]labapi.WifiRouterFeature, error)
- func (c *OpenWrtRouterController) FetchDeviceBuildInfo(ctx context.Context) error
- func (c *OpenWrtRouterController) FetchGlobalImageConfig(ctx context.Context) error
- func (c *OpenWrtRouterController) IdentifyExpectedImage(ctx context.Context, dutHostname, dutChromeOSReleaseVersion string) error
- func (c *OpenWrtRouterController) Model() (string, error)
- func (c *OpenWrtRouterController) Reboot(ctx context.Context) error
- func (c *OpenWrtRouterController) Runner() components.Runner
- func (c *OpenWrtRouterController) UpdateToExpectedImage(ctx context.Context) error
- func (c *OpenWrtRouterController) WifiRouterHost() *tlw.WifiRouterHost
- type RouterController
- type UbuntuRouterController
- func (c *UbuntuRouterController) DeviceType() labapi.WifiRouterDeviceType
- func (c *UbuntuRouterController) Features() ([]labapi.WifiRouterFeature, error)
- func (c *UbuntuRouterController) FetchNetworkControllerName(ctx context.Context) error
- func (c *UbuntuRouterController) FetchSystemProductName(ctx context.Context) error
- func (c *UbuntuRouterController) Model() (string, error)
- func (c *UbuntuRouterController) Reboot(ctx context.Context) error
- func (c *UbuntuRouterController) Runner() components.Runner
- func (c *UbuntuRouterController) WifiRouterHost() *tlw.WifiRouterHost
Constants ¶
const (
// RouterModelGale is the model name used for ChromeOS Gale routers.
RouterModelGale = "gale"
)
Variables ¶
This section is empty.
Functions ¶
func CleanWifiRouterFeatures ¶
func CleanWifiRouterFeatures(features []labapi.WifiRouterFeature) []labapi.WifiRouterFeature
CleanWifiRouterFeatures removes duplicate router features, sorts them by name, and replaces invalid router features with labapi.WifiRouterFeature_WIFI_ROUTER_FEATURE_INVALID.
func CollectOverallTestbedWifiRouterFeatures ¶
func CollectOverallTestbedWifiRouterFeatures(routers []*tlw.WifiRouterHost) []labapi.WifiRouterFeature
CollectOverallTestbedWifiRouterFeatures returns a single list of router features supported by all routers in the testbed.
If any router does not have features or has an unknown feature, a list with just one unknown feature is returned since it is not possible to know what features all routers support. It is expected that all routers support at least one valid feature.
If any router has an invalid feature, the returned list will have one invalid feature included to denote this for maintenance purposes.
If there are no common features across all routers, a list with just one invalid feature is returned to denote this for maintenance purposes.
func IdentifyRouterDeviceType ¶
func IdentifyRouterDeviceType(ctx context.Context, sshAccess ssh.Access, resource string) (labapi.WifiRouterDeviceType, error)
IdentifyRouterDeviceType probes the router host over ssh to determine its device type.
func SortWifiRouterFeaturesByName ¶
func SortWifiRouterFeaturesByName(features []labapi.WifiRouterFeature)
SortWifiRouterFeaturesByName sorts the list of features by their proto enum names. Unknown value names sorted by value at the end of the list.
Types ¶
type AsusWrtRouterController ¶
type AsusWrtRouterController struct {
// contains filtered or unexported fields
}
AsusWrtRouterController is the RouterController implementation for AsusWrt router devices.
func (*AsusWrtRouterController) DeviceType ¶
func (c *AsusWrtRouterController) DeviceType() labapi.WifiRouterDeviceType
DeviceType returns the labapi.WifiRouterDeviceType of the router.
func (*AsusWrtRouterController) Features ¶
func (c *AsusWrtRouterController) Features() ([]labapi.WifiRouterFeature, error)
Features returns the router features that this router supports.
AsusWrt routers have a static mapping of known features for each supported Asus model. This mapping is maintained by the controller and is not retrieved from the device itself.
func (*AsusWrtRouterController) FetchAsusModel ¶
func (c *AsusWrtRouterController) FetchAsusModel(ctx context.Context) error
FetchAsusModel retrieves the ASUS model from the device and stores it in the state.
func (*AsusWrtRouterController) Model ¶
func (c *AsusWrtRouterController) Model() (string, error)
Model returns a unique name for the router model.
For AsusWrt routers, this is a combination of the DeviceType and the Asus model name retrieved from the router.
func (*AsusWrtRouterController) Reboot ¶
func (c *AsusWrtRouterController) Reboot(ctx context.Context) error
Reboot will reboot the router and wait for it to come back up. A non-nil error indicates that the router was rebooted and is ssh-able again.
func (*AsusWrtRouterController) Runner ¶
func (c *AsusWrtRouterController) Runner() components.Runner
Runner returns a components.Runner for running ssh commands on the router.
func (*AsusWrtRouterController) WifiRouterHost ¶
func (c *AsusWrtRouterController) WifiRouterHost() *tlw.WifiRouterHost
WifiRouterHost returns the corresponding tlw.WifiRouterHost instance for this router. Changes to this instance are persisted across execs.
type CacheAccess ¶
type CacheAccess interface { // GetCacheUrl provides URL to download requested path to file. // URL will use to download image to USB-drive and provisioning. GetCacheUrl(ctx context.Context, dutName, filePath string) (string, error) }
CacheAccess is a subset of tlw.Access that just has the ability to access the cache server.
type ChromeOSGaleRouterController ¶
type ChromeOSGaleRouterController struct {
// contains filtered or unexported fields
}
ChromeOSGaleRouterController is the RouterController implementation for ChromeOS Gale router devices.
func (*ChromeOSGaleRouterController) DeviceType ¶
func (c *ChromeOSGaleRouterController) DeviceType() labapi.WifiRouterDeviceType
DeviceType returns the labapi.WifiRouterDeviceType of the router.
func (*ChromeOSGaleRouterController) Features ¶
func (c *ChromeOSGaleRouterController) Features() ([]labapi.WifiRouterFeature, error)
Features returns the router features that this router supports.
ChromeOS Gale routers have a static list of known features. This list is maintained by the controller and is not retrieved from the device itself.
func (*ChromeOSGaleRouterController) Model ¶
func (c *ChromeOSGaleRouterController) Model() (string, error)
Model returns a unique name for the router model.
All ChromeOS Gale routers have the same model name, since only one model is supported.
func (*ChromeOSGaleRouterController) Reboot ¶
func (c *ChromeOSGaleRouterController) Reboot(ctx context.Context) error
Reboot will reboot the router and wait for it to come back up. A non-nil error indicates that the router was rebooted and is ssh-able again.
func (*ChromeOSGaleRouterController) Runner ¶
func (c *ChromeOSGaleRouterController) Runner() components.Runner
Runner returns a components.Runner for running ssh commands on the router.
func (*ChromeOSGaleRouterController) WifiRouterHost ¶
func (c *ChromeOSGaleRouterController) WifiRouterHost() *tlw.WifiRouterHost
WifiRouterHost returns the corresponding tlw.WifiRouterHost instance for this router. Changes to this instance are persisted across execs.
type OpenWrtRouterController ¶
type OpenWrtRouterController struct {
// contains filtered or unexported fields
}
OpenWrtRouterController is the RouterController implementation for OpenWrt router devices.
This is intended to support any router device with a custom ChromeOS OpenWrt OS test image installed on it. These custom images, built with the cros_openwrt_image_builder CLI tool, include a build info file that is read for image and device identification.
func (*OpenWrtRouterController) AssertHasExpectedImage ¶
func (c *OpenWrtRouterController) AssertHasExpectedImage() error
AssertHasExpectedImage asserts that router has the expected image installed on it.
This function may only be called after the expected image has been identified with IdentifyExpectedImage.
func (*OpenWrtRouterController) DeviceType ¶
func (c *OpenWrtRouterController) DeviceType() labapi.WifiRouterDeviceType
DeviceType returns the labapi.WifiRouterDeviceType of the router.
func (*OpenWrtRouterController) Features ¶
func (c *OpenWrtRouterController) Features() ([]labapi.WifiRouterFeature, error)
Features returns the router features that this router supports.
For OpenWrt routers, features are retrieved from the build info file placed on the router by the custom ChromeOS OpenWrt image builder.
func (*OpenWrtRouterController) FetchDeviceBuildInfo ¶
func (c *OpenWrtRouterController) FetchDeviceBuildInfo(ctx context.Context) error
FetchDeviceBuildInfo retrieves the build info from the router and stores it in the controller state.
func (*OpenWrtRouterController) FetchGlobalImageConfig ¶
func (c *OpenWrtRouterController) FetchGlobalImageConfig(ctx context.Context) error
FetchGlobalImageConfig retrieves the global image config from GCS for this router and stores it in the controller state.
func (*OpenWrtRouterController) IdentifyExpectedImage ¶
func (c *OpenWrtRouterController) IdentifyExpectedImage(ctx context.Context, dutHostname, dutChromeOSReleaseVersion string) error
IdentifyExpectedImage will select an appropriate OpenWrt OS image from the available images in the config based on its model and the provided dutHostname and dutChromeOSReleaseVersion. The selected image's UUID is stored for later reference. A non-nil error is returned if an image was not selected.
Each supported OpenWrt device has its own set of images, as defined by the corresponding labapi.OpenWrtWifiRouterDeviceConfig. See the proto definition for more details on how this config defines which image should be used.
func (*OpenWrtRouterController) Model ¶
func (c *OpenWrtRouterController) Model() (string, error)
Model returns a unique name for the router model.
For OpenWrt routers, this is a combination of the DeviceType and the device name retrieved from the router. The device name is retrieved from the build info file placed on the router by the ChromeOS OpenWrt image builder
OpenWrt device names are a combination of the router manufacturer and model, and in most cases the names we use are the same (sanitized) names set by the OpenWrt community.
func (*OpenWrtRouterController) Reboot ¶
func (c *OpenWrtRouterController) Reboot(ctx context.Context) error
Reboot will reboot the router and wait for it to come back up. A non-nil error indicates that the router was rebooted and is ssh-able again.
func (*OpenWrtRouterController) Runner ¶
func (c *OpenWrtRouterController) Runner() components.Runner
Runner returns a components.Runner for running ssh commands on the router.
func (*OpenWrtRouterController) UpdateToExpectedImage ¶
func (c *OpenWrtRouterController) UpdateToExpectedImage(ctx context.Context) error
UpdateToExpectedImage uses the `sysupgrade` command on the router to update the image installed on the router with the expected image. This can take a few minutes, as it does not return until the new image is installed and the router has come back up. Once it is back up, the build info file is retrieved from the device again and the ImageUUID is checked to ensure that the image that was installed is the expected ImageUUID.
The image binary file used is retrieved from archives stored in GCS, which are uploaded manually by developers using the cros_openwrt_image_builder CLI utility. The infra cache server downloads the archive from GCS (if it is not cached), then the router downloads the archive from the cache server, extracts the image binary from the archive locally, then runs `sysupgrade`.
This function may only be called after the expected image has been identified with IdentifyExpectedImage.
func (*OpenWrtRouterController) WifiRouterHost ¶
func (c *OpenWrtRouterController) WifiRouterHost() *tlw.WifiRouterHost
WifiRouterHost returns the corresponding tlw.WifiRouterHost instance for this router. Changes to this instance are persisted across execs.
type RouterController ¶
type RouterController interface { // WifiRouterHost returns the corresponding tlw.WifiRouterHost instance for // this router. Changes to this instance are persisted across execs. WifiRouterHost() *tlw.WifiRouterHost // DeviceType returns the labapi.WifiRouterDeviceType of the router. DeviceType() labapi.WifiRouterDeviceType // Runner returns a components.Runner for running ssh commands on the router. Runner() components.Runner // Model returns a unique name for the router model. Model() (string, error) // Features returns the router features that this router supports. Features() ([]labapi.WifiRouterFeature, error) // Reboot will reboot the router and wait for it to come back up. A non-nil // error indicates that the router was rebooted and is ssh-able again. Reboot(ctx context.Context) error }
RouterController is the common interface that all router controllers must implement so that router execs that are not dependent upon the device type may rely just on RouterController for usage and NewRouterDeviceController for implementation selection.
func NewRouterDeviceController ¶
func NewRouterDeviceController(ctx context.Context, sshAccess ssh.Access, cacheAccess CacheAccess, hostResource, dutName string, wifiRouter *tlw.WifiRouterHost) (RouterController, error)
NewRouterDeviceController creates a new router controller instance for the specified router host. The controller implementation used is dependent upon the wifiRouter.DeviceType, so this must be populated.
type UbuntuRouterController ¶
type UbuntuRouterController struct {
// contains filtered or unexported fields
}
UbuntuRouterController is the RouterController implementation for Ubuntu-based router devices.
func (*UbuntuRouterController) DeviceType ¶
func (c *UbuntuRouterController) DeviceType() labapi.WifiRouterDeviceType
DeviceType returns the labapi.WifiRouterDeviceType of the router.
func (*UbuntuRouterController) Features ¶
func (c *UbuntuRouterController) Features() ([]labapi.WifiRouterFeature, error)
Features returns the router features that this router supports.
ChromeOS Gale routers have a static list of known features. This list is maintained by the controller and is not retrieved from the device itself.
func (*UbuntuRouterController) FetchNetworkControllerName ¶
func (c *UbuntuRouterController) FetchNetworkControllerName(ctx context.Context) error
FetchNetworkControllerName retrieves the name of the PCI network controller on the device and stores it (or a translated version of it) in the state for later reference in model name creation.
func (*UbuntuRouterController) FetchSystemProductName ¶
func (c *UbuntuRouterController) FetchSystemProductName(ctx context.Context) error
FetchSystemProductName retrieves the system product name of the Ubuntu device from its DMI table and stores it in the state for later reference in model name creation.
func (*UbuntuRouterController) Model ¶
func (c *UbuntuRouterController) Model() (string, error)
Model returns a unique name for the router model.
For Ubuntu-based routers, model names are a combination of DeviceType, the system product name, and their network controller name.
func (*UbuntuRouterController) Reboot ¶
func (c *UbuntuRouterController) Reboot(ctx context.Context) error
Reboot will reboot the router and wait for it to come back up. A non-nil error indicates that the router was rebooted and is ssh-able again.
func (*UbuntuRouterController) Runner ¶
func (c *UbuntuRouterController) Runner() components.Runner
Runner returns a components.Runner for running ssh commands on the router.
func (*UbuntuRouterController) WifiRouterHost ¶
func (c *UbuntuRouterController) WifiRouterHost() *tlw.WifiRouterHost
WifiRouterHost returns the corresponding tlw.WifiRouterHost instance for this router. Changes to this instance are persisted across execs.