syscmd

package
v0.0.0-...-737f52e Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package syscmd contains methods that run external commands on device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveToFile

func SaveToFile(folderPath, fileName, content string) error

SaveToFile saves the input string into a file in the file system. It creates the file and all parent folder if not exist.

Types

type CommandRunner

type CommandRunner struct {
	// ExecCommand runs the given command with arguments.
	// It returns the content of stdout or stderr, and error if command failed.
	ExecCommand func(wait bool, cmd string, args ...string) (string, error)
}

CommandRunner contains methods executing external commands.

func Runner

func Runner() *CommandRunner

Runner executes external commands in the real environment.

func (*CommandRunner) AddBridgeIntf

func (r *CommandRunner) AddBridgeIntf(bridgeName, intfName string) error

AddBridgeIntf adds an interface to a network bridge.

func (*CommandRunner) BringUpIntf

func (r *CommandRunner) BringUpIntf(intfName string) error

BringUpIntf brings up a certain network interface.

func (*CommandRunner) CreateBridge

func (r *CommandRunner) CreateBridge(bridgeName string) error

CreateBridge creates a network bridge with a certain name.

func (*CommandRunner) CreateVLAN

func (r *CommandRunner) CreateVLAN(intfName string, vlanID int) (string, error)

CreateVLAN creates vlan with a specific ID on target interface. It returns created interface name if succeeded, or error if failed.

func (*CommandRunner) DeleteBridge

func (r *CommandRunner) DeleteBridge(bridgeName string) error

DeleteBridge deletes a network bridge with a certain name.

func (*CommandRunner) DeleteVLAN

func (r *CommandRunner) DeleteVLAN(intfName string, vlanID int) error

DeleteVLAN deletes the vlan with a specific ID on target interface.

func (*CommandRunner) DeviceIPv4

func (r *CommandRunner) DeviceIPv4() (string, error)

DeviceIPv4 fetches the first IPv4 address of the device.

func (*CommandRunner) GetAPStates

func (r *CommandRunner) GetAPStates() (string, error)

GetAPStates get ap states on target

func (*CommandRunner) IntfMAC

func (r *CommandRunner) IntfMAC(intfName string) (string, error)

IntfMAC returns the MAC address of a certain interface.

func (*CommandRunner) RestartIntf

func (r *CommandRunner) RestartIntf(intfName string) error

RestartIntf restarts a specific network interface.

func (*CommandRunner) SendDHCPRequest

func (r *CommandRunner) SendDHCPRequest(intfName, hostname string) error

SendDHCPRequest sends a DHCP request for a certain network interface with the hostname in parameter.

func (*CommandRunner) StartHostapd

func (r *CommandRunner) StartHostapd(configFilePath string) error

StartHostapd starts a hostapd process link to the given WLAN interface.

func (*CommandRunner) StopAllHostapd

func (r *CommandRunner) StopAllHostapd() error

StopAllHostapd kills all running hostapd processes.

func (*CommandRunner) TurnDownIntf

func (r *CommandRunner) TurnDownIntf(intfName string) error

TurnDownIntf turns down a certain network interface.

func (*CommandRunner) UpdateIntfMAC

func (r *CommandRunner) UpdateIntfMAC(intfName, updatedMAC string) error

UpdateIntfMAC changes the MAC address of a certain interface to the inputed one.

func (*CommandRunner) VLANOnIntf

func (r *CommandRunner) VLANOnIntf(intfName string) ([]int, error)

VLANOnIntf returns IDs of all VLAN on the given interface.

func (*CommandRunner) WipeOutIntfIP

func (r *CommandRunner) WipeOutIntfIP(intfName string) error

WipeOutIntfIP cleans up the IP address on a certain network interface.

Jump to

Keyboard shortcuts

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