utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResyncPeriod                   = 5 * time.Minute
	DefaultConfigName              = "default"
	ConfigDaemonPath               = "./bindata/manifests/daemon"
	InjectorWebHookPath            = "./bindata/manifests/webhook"
	OperatorWebHookPath            = "./bindata/manifests/operator-webhook"
	ServiceCAConfigMapAnnotation   = "service.beta.openshift.io/inject-cabundle"
	InjectorWebHookName            = "network-resources-injector-config"
	OperatorWebHookName            = "sriov-operator-webhook-config"
	DeprecatedOperatorWebHookName  = "operator-webhook-config"
	PluginPath                     = "./bindata/manifests/plugins"
	DaemonPath                     = "./bindata/manifests/daemon"
	DefaultPolicyName              = "default"
	ConfigMapName                  = "device-plugin-config"
	DPConfigFileName               = "config.json"
	OVSHWOLMachineConfigNameSuffix = "ovs-hw-offload"

	LinkTypeEthernet   = "ether"
	LinkTypeInfiniband = "infiniband"
)
View Source
const (
	ClusterTypeOpenshift  = "openshift"
	ClusterTypeKubernetes = "kubernetes"
	VendorMellanox        = "15b3"
	DeviceBF2             = "a2d6"
)

Variables

View Source
var ClusterType string
View Source
var DpdkDrivers = []string{"igb_uio", "vfio-pci", "uio_pci_generic"}
View Source
var (
	// PlatformMap contains supported platforms for virtual VF
	PlatformMap = map[string]PlatformType{
		"openstack": VirtualOpenStack,
	}
)

Functions

func BindDefaultDriver

func BindDefaultDriver(pciAddr string) error

BindDefaultDriver bind driver for one device Bind the device given by "pciAddr" to the default driver

func BindDpdkDriver

func BindDpdkDriver(pciAddr, driver string) error

BindDpdkDriver bind dpdk driver for one device Bind the device given by "pciAddr" to the driver "driver"

func Chroot

func Chroot(path string) (func() error, error)

func DiscoverSriovDevices

func DiscoverSriovDevices(withUnsupported bool) ([]sriovnetworkv1.InterfaceExt, error)

func DiscoverSriovDevicesVirtual

func DiscoverSriovDevicesVirtual(devicesInfo OSPDevicesInfo) ([]sriovnetworkv1.InterfaceExt, error)

DiscoverSriovDevicesVirtual discovers VFs on a virtual platform

func GetNicSriovMode

func GetNicSriovMode(pciAddress string) (string, error)

func GetOpenstackData added in v1.2.0

func GetOpenstackData() (metaData *OSPMetaData, networkData *OSPNetworkData, err error)

GetOpenstackData gets the metadata and network_data

func GetPhysPortName

func GetPhysPortName(name string) (string, error)

func GetPhysSwitchID

func GetPhysSwitchID(name string) (string, error)

func IsKernelLockdownMode added in v1.1.0

func IsKernelLockdownMode(chroot bool) bool

IsKernelLockdownMode returns true when kernel lockdown mode is enabled

func IsSingleNodeCluster added in v1.2.0

func IsSingleNodeCluster(c client.Client) (bool, error)

func LoadKernelModule

func LoadKernelModule(name string, args ...string) error

func RebindVfToDefaultDriver added in v1.2.0

func RebindVfToDefaultDriver(vfAddr string) error

Workaround function to handle a case where the vf default driver is stuck and not able to create the vf kernel interface. This function unbind the VF from the default driver and try to bind it again bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2045087

func RunCommand added in v1.1.0

func RunCommand(command string, args ...string) (string, error)

RunCommand runs a command

func Shutdown added in v1.1.0

func Shutdown()

func SkipConfigVf added in v1.2.0

func SkipConfigVf(ifSpec sriovnetworkv1.Interface, ifStatus sriovnetworkv1.InterfaceExt) bool

SkipConfigVf Use systemd service to configure switchdev mode or BF-2 NICs in OpenShift

func SyncNodeState

func SyncNodeState(newState *sriovnetworkv1.SriovNetworkNodeState) error

SyncNodeState Attempt to update the node state to match the desired state

func SyncNodeStateVirtual

func SyncNodeStateVirtual(newState *sriovnetworkv1.SriovNetworkNodeState) error

SyncNodeStateVirtual attempt to update the node state to match the desired state

in virtual platforms

func Unbind

func Unbind(pciAddr string) error

Unbind unbind driver for one device

func WriteSwitchdevConfFile

func WriteSwitchdevConfFile(newState *sriovnetworkv1.SriovNetworkNodeState) (update bool, err error)

Types

type OSPDeviceInfo added in v1.2.0

type OSPDeviceInfo struct {
	MacAddress string
	NetworkID  string
}

type OSPDevicesInfo added in v1.2.0

type OSPDevicesInfo map[string]*OSPDeviceInfo

func CreateOpenstackDevicesInfo added in v1.2.0

func CreateOpenstackDevicesInfo(metaData *OSPMetaData, networkData *OSPNetworkData) (OSPDevicesInfo, error)

CreateOpenstackDevicesInfo create the openstack device info map

func CreateOpenstackDevicesInfoFromNodeStatus added in v1.2.0

func CreateOpenstackDevicesInfoFromNodeStatus(networkState *sriovnetworkv1.SriovNetworkNodeState) OSPDevicesInfo

type OSPMetaData

type OSPMetaData struct {
	UUID             string              `json:"uuid,omitempty"`
	AdminPass        string              `json:"admin_pass,omitempty"`
	Name             string              `json:"name,omitempty"`
	LaunchIndex      int                 `json:"launch_index,omitempty"`
	AvailabilityZone string              `json:"availability_zone,omitempty"`
	ProjectID        string              `json:"project_id,omitempty"`
	Devices          []OSPMetaDataDevice `json:"devices,omitempty"`
}

OSPMetaData -- Openstack meta_data.json format

type OSPMetaDataDevice

type OSPMetaDataDevice struct {
	Vlan      int      `json:"vlan,omitempty"`
	VfTrusted bool     `json:"vf_trusted,omitempty"`
	Type      string   `json:"type,omitempty"`
	Mac       string   `json:"mac,omitempty"`
	Bus       string   `json:"bus,omitempty"`
	Address   string   `json:"address,omitempty"`
	Tags      []string `json:"tags,omitempty"`
}

OSPMetaDataDevice -- Device structure within meta_data.json

type OSPNetwork

type OSPNetwork struct {
	ID        string `json:"id"`
	Type      string `json:"type"`
	Link      string `json:"link"`
	NetworkID string `json:"network_id"`
}

OSPNetwork OSP Network metadata

type OSPNetworkData

type OSPNetworkData struct {
	Links    []OSPNetworkLink `json:"links,omitempty"`
	Networks []OSPNetwork     `json:"networks,omitempty"`
}

OSPNetworkData OSP Network metadata

type OSPNetworkLink struct {
	ID          string `json:"id"`
	VifID       string `json:"vif_id,omitempty"`
	Type        string `json:"type"`
	Mtu         int    `json:"mtu,omitempty"`
	EthernetMac string `json:"ethernet_mac_address"`
}

OSPNetworkLink OSP Link metadata

type PlatformType

type PlatformType int

PlatformType ...

const (
	// Baremetal platform
	Baremetal PlatformType = iota
	// VirtualOpenStack ...
	VirtualOpenStack
)

func (PlatformType) String

func (e PlatformType) String() string

Jump to

Keyboard shortcuts

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