Documentation ¶
Index ¶
- type Device
- func (d *Device) ActivateCdqSubfunction() error
- func (d *Device) AssignAsPrimary() (*Device, error)
- func (d *Device) AssignCdqSecondaries(limit int) ([]*Device, error)
- func (d *Device) Cycle() error
- func (d *Device) Driver() (string, error)
- func (d *Device) Exists() (bool, error)
- func (d *Device) GetEthtoolFilters() []string
- func (d *Device) Ips() ([]string, error)
- func (d *Device) IsFullyAssigned() bool
- func (d *Device) IsPrimary() bool
- func (d *Device) IsSecondary() bool
- func (d *Device) Mac() (string, error)
- func (d *Device) Mode() string
- func (d *Device) Name() string
- func (d *Device) Pci() (string, error)
- func (d *Device) Primary() *Device
- func (d *Device) Public() *DeviceDetails
- func (d *Device) SetEthtoolFilter(ethtool []string)
- func (d *Device) SetFullyAssigned()
- func (d *Device) UnassignedSecondaries() int
- type DeviceDetails
- type FakeHandler
- type Handler
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
ActivateCdqSubfunction converts our device object in code into an actual CDQ subfunction on the host
func (*Device) AssignAsPrimary ¶ added in v0.0.2
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
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
Cycle cycles the device state, up and then down It uses the net handler CycleDevice function
func (*Device) Driver ¶ added in v0.0.2
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
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
GetEthtoolFilters returns a string array of ethtool filters from the device object
func (*Device) Ips ¶ added in v0.0.2
Ips are discovered through the netHandler Ips are not stored as they can change frequently
func (*Device) IsFullyAssigned ¶ added in v0.0.2
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
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
IsSecondary returns true if this is a secondary device It simply returns the opposite of IsPrimary
func (*Device) Mac ¶ added in v0.0.2
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) Pci ¶ added in v0.0.2
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
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
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
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 ¶
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.