testhelpers

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOutputPortToMirror

func AddOutputPortToMirror(portUUID, mirrorName string) (string, error)

AddOutputPortToMirror adds portUUID as 'output_port' to a specific mirror via 'ovs-vsctl'

func AddSelectPortToMirror

func AddSelectPortToMirror(portUUID, mirrorName string, ingress, egress bool) (bool, error)

AddSelectPortToMirror adds portUUID to a specific mirror via 'ovs-vsctl' as 'select_*' based on ingress and egress values. ingress == true => adds portUUID as 'select_src_port' egress == true => adds portUUID as 'select_dst_port'

func CheckEmptyMirrorsExistence

func CheckEmptyMirrorsExistence(mirrorNames []string, exists bool)

CheckEmptyMirrorsExistence checks if all mirrors exist or not, based on 'exists' value.

func CheckPortsInMirrors

func CheckPortsInMirrors(mirrors []types.Mirror, hasExternalOwner bool, ovsPortOwner string, results ...cnitypes.Result) bool

CheckPortsInMirrors extracts ports from results and check if every mirror contains those port UUIDs. Since it's not possibile to have mirrors without both ingress and egress, it's enough finding the port in either ingress or egress. It also verify the mirror owner using 'external_ids' attribute. You can skip this check with hasExternalOwner=true.

func ContainsElement

func ContainsElement(list []string, el string) bool

ContainsElement returns true if a list of strings contains a string element

func CreateEmptyMirrors

func CreateEmptyMirrors(bridgeName string, mirrorNames []string, ovsPortOwner string)

CreateEmptyMirrors creates multiple mirrors in a bridge with an optional owner in external_ids. If ovsPortOwner is an empty string, it will leave external_ids empty.

func GetMirrorAttribute

func GetMirrorAttribute(mirrorName, attributeName string) (string, error)

GetMirrorAttribute gets a mirror attribute

func GetMirrorDstPorts

func GetMirrorDstPorts(mirrorName string) ([]string, error)

GetMirrorDstPorts gets 'select_dst_port' of a mirror as a string slice

func GetMirrorOutputPorts

func GetMirrorOutputPorts(mirrorName string) ([]string, error)

GetMirrorOutputPorts gets 'output_port' of a mirror as a string slice

func GetMirrorPorts

func GetMirrorPorts(mirrorName string, attributeName SelectPort) ([]string, error)

GetMirrorPorts gets either 'select_src_port' or 'select_dst_port of a mirror

func GetMirrorSrcPorts

func GetMirrorSrcPorts(mirrorName string) ([]string, error)

GetMirrorSrcPorts gets 'select_src_port' of a mirror as a string slice

func GetPortUUIDByName

func GetPortUUIDByName(name string) (string, error)

GetPortUUIDByName gets a portUUID by its name

func GetPortUUIDFromResult

func GetPortUUIDFromResult(r cnitypes.Result) string

GetPortUUIDFromResult gets portUUID from a cnitypes.Result object

func IsMirrorExists

func IsMirrorExists(name string) (bool, error)

IsMirrorExists checks if a mirror exists by its name

func OnlyContainsOrEmpty

func OnlyContainsOrEmpty(list []string, el string) bool

OnlyContainsOrEmpty checks if a list of strings contains only 'el' element or is empty

func ToJSONString

func ToJSONString(input interface{}) (string, error)

ToJSONString coverts input into a JSON string

Types

type MirrorNet040

type MirrorNet040 struct {
	CNIVersion    string                 `json:"cniVersion"`
	Name          string                 `json:"name"`
	Type          string                 `json:"type"`
	Bridge        string                 `json:"bridge"`
	Mirrors       []*types.Mirror        `json:"mirrors"`
	RawPrevResult map[string]interface{} `json:"prevResult,omitempty"`
	PrevResult    types040.Result        `json:"-"`
}

MirrorNet040 struct that represent the network configuration for CNI spec 0.4.0

type MirrorNetCurrent

type MirrorNetCurrent struct {
	CNIVersion    string                 `json:"cniVersion"`
	Name          string                 `json:"name"`
	Type          string                 `json:"type"`
	Bridge        string                 `json:"bridge"`
	Mirrors       []*types.Mirror        `json:"mirrors"`
	RawPrevResult map[string]interface{} `json:"prevResult,omitempty"`
	PrevResult    current.Result         `json:"-"`
}

MirrorNetCurrent struct that represent the network configuration for CNI spec 1.0.0

type SelectPort

type SelectPort string

SelectPort type that represent the kind of select_*_port

const (
	// SelectSrcPort const with value "select_src_port"
	// (ports on which arriving packets are selected for mirroring)
	SelectSrcPort SelectPort = "select_src_port"
	// SelectDstPort const with value "select_dst_port"
	// (ports on which departing packets are selected for mirroring)
	SelectDstPort SelectPort = "select_dst_port"
)

Jump to

Keyboard shortcuts

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