common

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package common includes common logic used across multiple router implementations.

Index

Constants

View Source
const (

	// AutotestWorkdirGlob is the path that grabs all autotest outputs.
	AutotestWorkdirGlob = "/tmp/autotest-*"
	// WorkingDir is the tast-test's working directory.
	WorkingDir = "/tmp/tast-test/"
)
View Source
const (

	// VethPrefix is the prefix for the veth interface.
	VethPrefix = "vethA"
	// VethPeerPrefix is the prefix for the peer's veth interface.
	VethPeerPrefix = "vethB"
	// BridgePrefix is the prefix for the bridge interface.
	BridgePrefix = "tastbr"
)
View Source
const RouterCloseContextDuration = 5 * time.Second

RouterCloseContextDuration is a shorter context.Context duration is used for running things before Router.Close to reserve time for it to run.

Variables

This section is empty.

Functions

func CollectLogs

func CollectLogs(ctx context.Context, r support.Router, logCollectors map[string]*log.Collector, logsToCollect []string, suffix string) error

CollectLogs downloads log files from router to $OutDir/debug/$r.Name with suffix appended to the filenames.

func HostFileContentsMatch

func HostFileContentsMatch(ctx context.Context, host *ssh.Conn, remoteFilePath, matchRegex string) (bool, error)

HostFileContentsMatch checks if the file at remoteFilePath on the remote host exists and that its contents match using the regex string matchRegex.

Returns true if the file exists and its contents matches. Returns false with a nil error if the file does not exist.

func HostFileExists

func HostFileExists(ctx context.Context, host *ssh.Conn, remoteFilePath string) (bool, error)

HostFileExists checks the host for the file at remoteFilePath and returns true if remoteFilePath exists and is a regular file.

func HostTestPath

func HostTestPath(ctx context.Context, host *ssh.Conn, testFlag, remotePath string) (bool, error)

HostTestPath runs "test <testFlag> <remoteFilePath>" on the host and returns true if the test passes and false if the test fails.

func StartLogCollectors

func StartLogCollectors(ctx context.Context, host *ssh.Conn, logsToCollect []string, tailFollowNameSupported bool) (map[string]*log.Collector, error)

StartLogCollectors starts log collectors with log.StartCollector.

func StopLogCollectors

func StopLogCollectors(ctx context.Context, logCollectors map[string]*log.Collector) error

StopLogCollectors closes all log collectors spawned.

Types

type IfaceManager

type IfaceManager struct {

	// Available is a map from the interface name to iw.NetDev for available interfaces.
	Available map[string]*iw.NetDev

	// Busy is a map from the interface name to iw.NetDev for busy interfaces.
	Busy map[string]*iw.NetDev
	// contains filtered or unexported fields
}

IfaceManager manages WiFi ifaces on a controller router and tracks their availability.

func NewRouterIfaceManager

func NewRouterIfaceManager(r support.Router, iwr *iw.Runner) *IfaceManager

NewRouterIfaceManager creates a new IfaceManager

func (*IfaceManager) Create

func (im *IfaceManager) Create(ctx context.Context, phyName string, phyID int, t iw.IfType) (*iw.NetDev, error)

Create creates an interface on phy of type t and returns the name of created interface.

func (*IfaceManager) IsPhyBusy

func (im *IfaceManager) IsPhyBusy(phyID int, t iw.IfType) bool

IsPhyBusy returns true if the phyID is occupied by a busy interface of type t.

func (*IfaceManager) IsPhyBusyAny

func (im *IfaceManager) IsPhyBusyAny(phyID int) bool

IsPhyBusyAny returns true if the phyID is occupied by a busy interface of any type.

func (*IfaceManager) Remove

func (im *IfaceManager) Remove(ctx context.Context, iface string) error

Remove removes the given iface with the iw command.

func (*IfaceManager) RemoveAll

func (im *IfaceManager) RemoveAll(ctx context.Context) error

RemoveAll removes all WiFi interfaces.

func (*IfaceManager) SetAvailable

func (im *IfaceManager) SetAvailable(iface string)

SetAvailable marks iface as available.

func (*IfaceManager) SetBusy

func (im *IfaceManager) SetBusy(iface string)

SetBusy marks iface as busy.

Directories

Path Synopsis
Package support identifies the different common features routers may support through interfaces that each router may or may not support.
Package support identifies the different common features routers may support through interfaces that each router may or may not support.

Jump to

Keyboard shortcuts

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