utils

package
v0.0.0-...-a586aca Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectPluginWatchMode

func DetectPluginWatchMode(sockDir string) bool

DetectPluginWatchMode returns true if plugins registry directory exist

func GetDDPProfiles

func GetDDPProfiles(dev string) (string, error)

GetDDPProfiles returns running DDP profile name if available

func GetDevNode

func GetDevNode(pciAddr string) int

GetDevNode returns the numa node of a PCI device, -1 if none is specified or error.

func GetDriverName

func GetDriverName(pciAddr string) (string, error)

GetDriverName returns current driver attached to a pci device from its pci address

func GetLinkAttrs

func GetLinkAttrs(ifName string) (*nl.LinkAttrs, error)

GetLinkAttrs returns a net device's link attributes.

func GetNetNames

func GetNetNames(pciAddr string) ([]string, error)

GetNetNames returns host net interface names as string for a PCI device from its pci address

func GetPciAddrFromVFID

func GetPciAddrFromVFID(pf string, vf int) (pciAddr string, err error)

GetPciAddrFromVFID returns PCI address for VF ID

func GetPfAddr

func GetPfAddr(pciAddr string) (string, error)

GetPfAddr returns SRIOV PF pci address if a device is VF given its pci address. If device it not VF then this will return its own address as PF

func GetPfName

func GetPfName(pciAddr string) (string, error)

GetPfName returns SRIOV PF name for the given VF If device is not VF then it will return its own ifname if exist else empty string

func GetSriovVFcapacity

func GetSriovVFcapacity(pf string) int

GetSriovVFcapacity returns SRIOV VF capacity

func GetUIODeviceFile

func GetUIODeviceFile(dev string) (devFile string, err error)

GetUIODeviceFile returns a vfio device files for vfio-pci bound PCI device's PCI address

func GetVFID

func GetVFID(pciAddr string) (vfID int, err error)

GetVFID returns VF ID index (within specific PF) based on PCI address

func GetVFIODeviceFile

func GetVFIODeviceFile(dev string) (devFileHost, devFileContainer string, err error)

GetVFIODeviceFile returns a vfio device files for vfio-pci bound PCI device's PCI address

func GetVFList

func GetVFList(pf string) (vfList []string, err error)

GetVFList returns a List containing PCI addr for all VF discovered in a given PF

func GetVFconfigured

func GetVFconfigured(pf string) int

GetVFconfigured returns number of VF configured for a PF

func IsNetlinkStatusUp

func IsNetlinkStatusUp(dev string) bool

IsNetlinkStatusUp returns 'false' if 'operstate' is not "up" for a Linux network device. This function will only return 'false' if the 'operstate' file of the device is readable and holds value anything other than "up". Or else we assume link is up.

func IsSriovPF

func IsSriovPF(pciAddr string) bool

IsSriovPF check if a pci device SRIOV capable given its pci address

func IsSriovVF

func IsSriovVF(pciAddr string) bool

IsSriovVF check if a pci device has link to a PF

func SriovConfigured

func SriovConfigured(addr string) bool

SriovConfigured returns true if sriov_numvfs reads > 0 else false

func UseFakeLinks() func()

UseFakeLinks causes GetLinkByName to retrieve fake netlink Link object return value intended to be used in unit-tests as deffered method to restore GetLinkByName to be the actual netlink implementation.

func ValidPciAddr

func ValidPciAddr(addr string) (string, error)

ValidPciAddr validates PciAddr given as string with host system

func ValidResourceName

func ValidResourceName(name string) bool

ValidResourceName returns true if it contains permitted characters otherwise false

Types

type DDPInfo

type DDPInfo struct {
	DDPInventory DDPInventory `json:"DDPInventory"`
}

DDPInfo is the toplevel container of DDPInventory

type DDPInventory

type DDPInventory struct {
	Device     string     `json:"device"`
	Address    string     `json:"address"`
	Name       string     `json:"name"`
	Display    string     `json:"display"`
	DDPpackage DDPpackage `json:"DDPpackage"`
}

DDPInventory holds a device's DDP information

type DDPpackage

type DDPpackage struct {
	TrackID string `json:"track_id"`
	Version string `json:"version"`
	Name    string `json:"name"`
}

DDPpackage holds information about DDP profile itself

type FakeFilesystem

type FakeFilesystem struct {
	RootDir  string
	Dirs     []string
	Files    map[string][]byte
	Symlinks map[string]string
}

FakeFilesystem allows to setup isolated fake files structure used for the tests.

func (*FakeFilesystem) Use

func (fs *FakeFilesystem) Use() func()

Use function creates entire files structure and returns a function to tear it down. Example usage: defer fs.Use()()

Jump to

Keyboard shortcuts

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