guest

package
v0.0.0-...-2ab8be3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const GB = Gb * 8
View Source
const Gb = Mb * 1000
View Source
const MB = Mb * 8
View Source
const Mb = 1000
View Source
const TB = Tb * 8
View Source
const Tb = Gb * 1000

Variables

This section is empty.

Functions

func ParseBandwidth

func ParseBandwidth(valueKb float64) string

func TestNetQos

func TestNetQos(clientGuest Guest, serverGuest Guest, pps bool, localIperf3File string) (float64, float64, error)

使用 iperf3 工具测试网络BPS/PPS

参数为客户端和服务端实例的连接地址, 格式: "连接地址@实例 UUID". e.g.

192.168.192.168@a6ee919a-4026-4f0b-8d7e-404950a91eb3

Types

type Bandwidth

type Bandwidth struct {
	Value float64
	Unit  string
}

func (Bandwidth) HumanBandwidth

func (bandwidth Bandwidth) HumanBandwidth() string

func (Bandwidth) String

func (bandwidth Bandwidth) String() string

func (Bandwidth) ToKbits

func (bandwidth Bandwidth) ToKbits() float64

type ExecResult

type ExecResult struct {
	Pid     int
	OutData string
	ErrData string
	Failed  bool
}

type Guest

type Guest struct {
	Connection string
	Domain     string
	ByUUID     bool
	QGATimeout int
	// contains filtered or unexported fields
}

func ParseGuest

func ParseGuest(guestConnector string) (*Guest, error)

func (Guest) Cat

func (guest Guest) Cat(args ...string) ExecResult

func (*Guest) Connect

func (guest *Guest) Connect() error

func (Guest) CopyFile

func (guest Guest) CopyFile(localFile string, remotePath string) (string, error)

func (Guest) Exec

func (guest Guest) Exec(command string, wait bool) ExecResult

func (Guest) FileWrite

func (guest Guest) FileWrite(filePath string, content string) error

func (Guest) GetIpaddrs

func (guest Guest) GetIpaddrs() []string

func (*Guest) GetName

func (g *Guest) GetName() string

func (Guest) HasCommand

func (guest Guest) HasCommand(command string) bool

func (Guest) IsSame

func (g Guest) IsSame(other Guest) bool

func (Guest) Kill

func (guest Guest) Kill(single int, pids []int) ExecResult

func (Guest) RpmInstall

func (guest Guest) RpmInstall(packagePath string) error

func (Guest) RunIperf3

func (guest Guest) RunIperf3(args ...string) ExecResult

Return pid

func (Guest) RunIperfClient

func (guest Guest) RunIperfClient(clientIp string, serverIp string, logfile string, options string) ExecResult

func (Guest) RunIperfClientUdp

func (guest Guest) RunIperfClientUdp(clientIp string, serverIp string, logfile string, options string) ExecResult

func (Guest) RunIperfServer

func (guest Guest) RunIperfServer(serverIp string, logfile string, options string) ExecResult

func (Guest) String

func (g Guest) String() string

type GuestConnection

type GuestConnection struct {
	Connection string
	Domain     string
}

type GuestExecArguments

type GuestExecArguments struct {
	CaptureOutput bool     `json:"capture-output"`
	Path          string   `json:"path"`
	Arg           []string `json:"arg"`
}

type GuestExecStatusArguments

type GuestExecStatusArguments struct {
	Pid int `json:"pid"`
}

type GuestFileCloseArguments

type GuestFileCloseArguments struct {
	Handle int `json:"handle"`
}

type GuestFileOpenArguments

type GuestFileOpenArguments struct {
	Path string `json:"path"`
	Mode string `json:"mode"`
}

type GuestFileWriteArguments

type GuestFileWriteArguments struct {
	Handle int    `json:"handle"`
	Bufb64 string `json:"buf-b64"`
}

type IperfReport

type IperfReport struct {
	Source string
	Dest   string
	Data   string
}

func NewIperfReport

func NewIperfReport(source string, dest string, data string) *IperfReport

func (IperfReport) GetBpsSum

func (r IperfReport) GetBpsSum() (*Bandwidth, *Bandwidth)

func (IperfReport) GetPpsSum

func (r IperfReport) GetPpsSum() (*PPS, *PPS)

type IperfReports

type IperfReports struct {
	Reports      []IperfReport
	SendTotal    Bandwidth
	ReceiveTotal Bandwidth
}

func NewIperfReports

func NewIperfReports() *IperfReports

func (*IperfReports) Add

func (reports *IperfReports) Add(source string, dest string, data string)

func (IperfReports) PrintBps

func (reports IperfReports) PrintBps()

func (IperfReports) PrintPps

func (reports IperfReports) PrintPps()

type Job

type Job struct {
	SourceIp string
	DestIp   string
	Pid      int
	Logfile  string
	Output   string
	Sender   Bandwidth
	Receiver Bandwidth
}

type PPS

type PPS struct {
	Lost  int
	Value int
}

func (PPS) GetLostPercent

func (pps PPS) GetLostPercent() float64

func (*PPS) Sum

func (pps *PPS) Sum(other PPS)

type QGACExecStatus

type QGACExecStatus struct {
	Execute   string                   `json:"execute"`
	Arguments GuestExecStatusArguments `json:"arguments"`
}

type QemuAgentCommand

type QemuAgentCommand struct {
	Execute   string             `json:"execute"`
	Arguments GuestExecArguments `json:"arguments"`
}

type QgaExecResult

type QgaExecResult struct {
	Return QgaExecReturn `json:"return"`
}

type QgaExecReturn

type QgaExecReturn struct {
	Pid int `json:"pid"`
}

type QgaExecStatusResult

type QgaExecStatusResult struct {
	Return QgaExecStatusReturn `json:"return"`
}

type QgaExecStatusReturn

type QgaExecStatusReturn struct {
	Exited  bool   `json:"exited"`
	OutData string `json:"out-data"`
	ErrData string `json:"err-data"`
}

type QgaFileOpenReturn

type QgaFileOpenReturn struct {
	Return int `json:"return"`
}

type QgaGFileClose

type QgaGFileClose struct {
	Execute   string                  `json:"execute"`
	Arguments GuestFileCloseArguments `json:"arguments"`
}

type QgaGFileOpen

type QgaGFileOpen struct {
	Execute   string                 `json:"execute"`
	Arguments GuestFileOpenArguments `json:"arguments"`
}

type QgaGFileWrite

type QgaGFileWrite struct {
	Execute   string                  `json:"execute"`
	Arguments GuestFileWriteArguments `json:"arguments"`
}

type QgaWriteOpenReturn

type QgaWriteOpenReturn struct {
	Return QgaWriteOpenReturnArguments `json:"return"`
}

type QgaWriteOpenReturnArguments

type QgaWriteOpenReturnArguments struct {
	Count int  `json:"count"`
	Eof   bool `json:"eof"`
}

Jump to

Keyboard shortcuts

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