networking

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device added in v0.0.2

type Device struct {
	// contains filtered or unexported fields
}

Device object represents networking devices, primary and secondary

func CreateTestDevice added in v0.0.2

func CreateTestDevice(name string, mode string, driver string, pci string, macAddress string,
	netHandler Handler) *Device

CreateTestDevice returns a device object and is intended for unit testing purposes only This function should not be used outside of testing Devices should always be created via a net handler

func (*Device) ActivateCdqSubfunction added in v0.0.2

func (d *Device) ActivateCdqSubfunction() error

ActivateCdqSubfunction converts our device object in code into an actual CDQ subfunction on the host

func (*Device) AssignAsPrimary added in v0.0.2

func (d *Device) AssignAsPrimary() (*Device, error)

AssignAsPrimary means this device is assigned to a pool as a primary device The device is put into primary mode and is set fully assigned, ensuring it will not be assigned again

func (*Device) AssignCdqSecondaries added in v0.0.2

func (d *Device) AssignCdqSecondaries(limit int) ([]*Device, error)

AssignCdqSecondaries takes an integer and, if available, returns that number of CDQ subfunctions (secondary devs) The primary device is put into CDQ mode. If the primary does not have yet have secondaries, they are now created The function loops through the primary device's subfunctions and assigns any unassigned subfunctions. An array of these newly assigned subfunctions is then returned.

func (*Device) Cycle added in v0.0.2

func (d *Device) Cycle() error

Cycle cycles the device state, up and then down It uses the net handler CycleDevice function

func (*Device) Driver added in v0.0.2

func (d *Device) Driver() (string, error)

Driver will check Device object for its driver and return the result If driver is not stored it will be discovered through the netHandler Driver is then stored for subsequent calls

func (*Device) Exists added in v0.0.2

func (d *Device) Exists() (bool, error)

Exists returns true if the device exists on the host (if the device has been created) It uses the netHandler NetDevExists function. This "exists" status is not stored, as secondary devices tend to be created and deleted frequently. We always check.

func (*Device) GetEthtoolFilters added in v0.0.2

func (d *Device) GetEthtoolFilters() []string

GetEthtoolFilters returns a string array of ethtool filters from the device object

func (*Device) Ips added in v0.0.2

func (d *Device) Ips() ([]string, error)

Ips are discovered through the netHandler Ips are not stored as they can change frequently

func (*Device) IsFullyAssigned added in v0.0.2

func (d *Device) IsFullyAssigned() bool

IsFullyAssigned returns the assignment status of the device A fully assigned device will return true and should not be assigned to subsequent pools

func (*Device) IsPrimary added in v0.0.2

func (d *Device) IsPrimary() bool

IsPrimary returns true if this is a primary device Primary devices point to themselves in the primary field of the device object

func (*Device) IsSecondary added in v0.0.2

func (d *Device) IsSecondary() bool

IsSecondary returns true if this is a secondary device It simply returns the opposite of IsPrimary

func (*Device) Mac added in v0.0.2

func (d *Device) Mac() (string, error)

Mac will check Device object for its mac and return the result If mac is not stored it will be discovered through the netHandler Mac is then stored for subsequent calls For secondary devices, which tend to be created and deleted regularly, we always recheck the mac.

func (*Device) Mode added in v0.0.2

func (d *Device) Mode() string

Mode returns the mode of the device

func (*Device) Name added in v0.0.2

func (d *Device) Name() string

Name returns the name of the device

func (*Device) Pci added in v0.0.2

func (d *Device) Pci() (string, error)

Pci will check Device object for its pci and return the result If pci is not stored it will be discovered through the netHandler Pci is then stored for subsequent calls

func (*Device) Primary added in v0.0.2

func (d *Device) Primary() *Device

Primary returns a pointer to this device's primary device Primary devices will return a pointer to themselves

func (*Device) Public added in v0.0.2

func (d *Device) Public() *DeviceDetails

Public returns a representation of Device, but with public fields To be used in debug logging and writing the device to a JSON file.

func (*Device) SetEthtoolFilter added in v0.0.2

func (d *Device) SetEthtoolFilter(ethtool []string)

SetEthtoolFilter assigns ethtool filters to the ethtoolFilters field in the device object.

func (*Device) SetFullyAssigned added in v0.0.2

func (d *Device) SetFullyAssigned()

SetFullyAssigned is used to specify that the device is fully assigned All primary mode devices should be automatically fully assigned or in other modes a device is considered fully assigned when all secondaries are assigned.

func (*Device) UnassignedSecondaries added in v0.0.2

func (d *Device) UnassignedSecondaries() int

UnassignedSecondaries returns the number of unassigned secondary devices available on this primary

type DeviceDetails added in v0.0.2

type DeviceDetails struct {
	Name           string
	Mode           string
	Driver         string
	Pci            string
	MacAddress     string
	FullyAssigned  bool
	EthtoolFilters []string
	Primary        *DeviceDetails
}

DeviceDetails is a representation of Device above, but with public fields This object has no functionality, methods or uses other than debug logging and writing the device to a JSON file.

type FakeHandler

type FakeHandler interface {
	Handler
	SetHostDevices(interfaceNames map[string][]string)
}

FakeHandler interface extends the Handler interface to provide additional testing methods.

func NewFakeHandler

func NewFakeHandler() FakeHandler

NewFakeHandler returns an implementation of the FakeHandler interface.

type Handler

type Handler interface {
	GetHostDevices() (map[string]*Device, error)
	GetDeviceDriver(interfaceName string) (string, error)
	GetDevicePci(interfaceName string) (string, error)
	GetIPAddresses(interfaceName string) ([]string, error)
	GetMacAddress(device string) (string, error)
	GetDeviceByMAC(mac string) (string, error)
	GetDeviceByPCI(pci string) (string, error)
	CycleDevice(interfaceName string) error
	NetDevExists(device string) (bool, error)
	GetDeviceFromFile(deviceName string, filepath string) (*Device, error)
	WriteDeviceFile(device *Device, filepath string) error
	CreateCdqSubfunction(parentPci string, pfnum string, sfnum string) error     // see subfunction package
	DeleteCdqSubfunction(portIndex string) error                                 // see subfunction package
	IsCdqSubfunction(name string) (bool, error)                                  // see subfunction package
	NumAvailableCdqSubfunctions(interfaceName string) (int, error)               // see subfunction package
	GetCdqPortIndex(netdev string) (string, error)                               // see subfucntions package
	GetCdqPfnum(netdev string) (string, error)                                   // see subfucntions package
	SetEthtool(ethtoolCmd []string, interfaceName string, ipResult string) error // see ethtool.go
	DeleteEthtool(interfaceName string) error                                    // see ethtool.go
	IsPhysicalPort(name string) (bool, error)
}

Handler is the CNI and device plugins interface to the host networking. The interface exists for testing purposes, allowing unit tests to test against a fake API.

func NewHandler

func NewHandler() Handler

NewHandler returns an implementation of the Handler interface.

Jump to

Keyboard shortcuts

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