From 7c73437c75bc55198c548c9d97a6f0acd6086442 Mon Sep 17 00:00:00 2001 From: Yury Kulazhenkov Date: Tue, 16 Jan 2024 09:55:49 +0200 Subject: [PATCH 1/3] Change layout of the pkg/host to simplify testing The commit includes following changes: * move interfaces and public types(types that used in interfaces) to a separate package * move implementation of the interfaces to internal pkgs to avoid unwanted imports by users * move StoreManager to a separate package These changes are required to be able to generate mocks for Interfaces in the host package which can be used to tests other interfaces in the host package. Signed-off-by: Yury Kulazhenkov --- pkg/helper/host.go | 9 +- pkg/helper/mock/mock_helper.go | 41 ++--- pkg/host/interface.go | 55 ------ pkg/host/internal/common.go | 19 +++ pkg/host/{ => internal/kernel}/kernel.go | 90 ++-------- pkg/host/{ => internal/kernel}/kernel_test.go | 7 +- pkg/host/{ => internal/kernel}/suite_test.go | 6 +- pkg/host/{ => internal/network}/network.go | 28 +-- pkg/host/{ => internal/service}/service.go | 89 +++------- pkg/host/{ => internal/sriov}/sriov.go | 53 ++---- pkg/host/{ => internal/udev}/udev.go | 17 +- pkg/host/manager.go | 46 +++++ pkg/host/mock/mock_store.go | 108 ------------ pkg/host/store/mock/mock_store.go | 108 ++++++++++++ pkg/host/{ => store}/store.go | 27 ++- pkg/host/types/interfaces.go | 160 ++++++++++++++++++ pkg/host/types/types.go | 43 +++++ pkg/plugins/k8s/k8s_plugin.go | 38 ++--- 18 files changed, 494 insertions(+), 450 deletions(-) delete mode 100644 pkg/host/interface.go create mode 100644 pkg/host/internal/common.go rename pkg/host/{ => internal/kernel}/kernel.go (85%) rename pkg/host/{ => internal/kernel}/kernel_test.go (98%) rename pkg/host/{ => internal/kernel}/suite_test.go (79%) rename pkg/host/{ => internal/network}/network.go (82%) rename pkg/host/{ => internal/service}/service.go (66%) rename pkg/host/{ => internal/sriov}/sriov.go (88%) rename pkg/host/{ => internal/udev}/udev.go (89%) create mode 100644 pkg/host/manager.go delete mode 100644 pkg/host/mock/mock_store.go create mode 100644 pkg/host/store/mock/mock_store.go rename pkg/host/{ => store}/store.go (85%) create mode 100644 pkg/host/types/interfaces.go create mode 100644 pkg/host/types/types.go diff --git a/pkg/helper/host.go b/pkg/helper/host.go index df3325762..5829d161a 100644 --- a/pkg/helper/host.go +++ b/pkg/helper/host.go @@ -4,6 +4,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/store" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" mlx "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox" ) @@ -12,21 +13,21 @@ import ( type HostHelpersInterface interface { utils.CmdInterface host.HostManagerInterface - host.StoreManagerInterface + store.ManagerInterface mlx.MellanoxInterface } type hostHelpers struct { utils.CmdInterface host.HostManagerInterface - host.StoreManagerInterface + store.ManagerInterface mlx.MellanoxInterface } // Use for unit tests func NewHostHelpers(utilsHelper utils.CmdInterface, hostManager host.HostManagerInterface, - storeManager host.StoreManagerInterface, + storeManager store.ManagerInterface, mlxHelper mlx.MellanoxInterface) HostHelpersInterface { return &hostHelpers{utilsHelper, hostManager, storeManager, mlxHelper} } @@ -35,7 +36,7 @@ func NewDefaultHostHelpers() (HostHelpersInterface, error) { utilsHelper := utils.New() mlxHelper := mlx.New(utilsHelper) hostManager := host.NewHostManager(utilsHelper) - storeManager, err := host.NewStoreManager() + storeManager, err := store.NewManager() if err != nil { log.Log.Error(err, "failed to create store manager") return nil, err diff --git a/pkg/helper/mock/mock_helper.go b/pkg/helper/mock/mock_helper.go index 75015a925..c00180cd3 100644 --- a/pkg/helper/mock/mock_helper.go +++ b/pkg/helper/mock/mock_helper.go @@ -11,7 +11,8 @@ import ( gomock "github.com/golang/mock/gomock" ghw "github.com/jaypipes/ghw" v1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" - host "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host" + store "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/store" + types "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" mlxutils "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox" netlink "github.com/vishvananda/netlink" ) @@ -82,17 +83,17 @@ func (mr *MockHostHelpersInterfaceMockRecorder) BindDpdkDriver(arg0, arg1 interf } // BindDriverByBusAndDevice mocks base method. -func (m *MockHostHelpersInterface) BindDriverByBusAndDevice(arg0, arg1, arg2 string) error { +func (m *MockHostHelpersInterface) BindDriverByBusAndDevice(bus, device, driver string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BindDriverByBusAndDevice", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "BindDriverByBusAndDevice", bus, device, driver) ret0, _ := ret[0].(error) return ret0 } // BindDriverByBusAndDevice indicates an expected call of BindDriverByBusAndDevice. -func (mr *MockHostHelpersInterfaceMockRecorder) BindDriverByBusAndDevice(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) BindDriverByBusAndDevice(bus, device, driver interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDriverByBusAndDevice", reflect.TypeOf((*MockHostHelpersInterface)(nil).BindDriverByBusAndDevice), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDriverByBusAndDevice", reflect.TypeOf((*MockHostHelpersInterface)(nil).BindDriverByBusAndDevice), bus, device, driver) } // Chroot mocks base method. @@ -125,7 +126,7 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ClearPCIAddressFolder() *gomock. } // CompareServices mocks base method. -func (m *MockHostHelpersInterface) CompareServices(serviceA, serviceB *host.Service) (bool, error) { +func (m *MockHostHelpersInterface) CompareServices(serviceA, serviceB *types.Service) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CompareServices", serviceA, serviceB) ret0, _ := ret[0].(bool) @@ -168,7 +169,7 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ConfigSriovDeviceVirtual(iface i } // ConfigSriovInterfaces mocks base method. -func (m *MockHostHelpersInterface) ConfigSriovInterfaces(arg0 host.StoreManagerInterface, arg1 []v1.Interface, arg2 []v1.InterfaceExt, arg3 map[string]bool) error { +func (m *MockHostHelpersInterface) ConfigSriovInterfaces(arg0 store.ManagerInterface, arg1 []v1.Interface, arg2 []v1.InterfaceExt, arg3 map[string]bool) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ConfigSriovInterfaces", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(error) @@ -182,7 +183,7 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ConfigSriovInterfaces(arg0, arg1 } // DiscoverSriovDevices mocks base method. -func (m *MockHostHelpersInterface) DiscoverSriovDevices(arg0 host.StoreManagerInterface) ([]v1.InterfaceExt, error) { +func (m *MockHostHelpersInterface) DiscoverSriovDevices(arg0 store.ManagerInterface) ([]v1.InterfaceExt, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DiscoverSriovDevices", arg0) ret0, _ := ret[0].([]v1.InterfaceExt) @@ -227,7 +228,7 @@ func (mr *MockHostHelpersInterfaceMockRecorder) EnableRDMAOnRHELMachine() *gomoc } // EnableService mocks base method. -func (m *MockHostHelpersInterface) EnableService(service *host.Service) error { +func (m *MockHostHelpersInterface) EnableService(service *types.Service) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "EnableService", service) ret0, _ := ret[0].(error) @@ -687,10 +688,10 @@ func (mr *MockHostHelpersInterfaceMockRecorder) RdmaIsLoaded() *gomock.Call { } // ReadScriptManifestFile mocks base method. -func (m *MockHostHelpersInterface) ReadScriptManifestFile(path string) (*host.ScriptManifestFile, error) { +func (m *MockHostHelpersInterface) ReadScriptManifestFile(path string) (*types.ScriptManifestFile, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ReadScriptManifestFile", path) - ret0, _ := ret[0].(*host.ScriptManifestFile) + ret0, _ := ret[0].(*types.ScriptManifestFile) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -702,10 +703,10 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ReadScriptManifestFile(path inte } // ReadService mocks base method. -func (m *MockHostHelpersInterface) ReadService(arg0 string) (*host.Service, error) { +func (m *MockHostHelpersInterface) ReadService(arg0 string) (*types.Service, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ReadService", arg0) - ret0, _ := ret[0].(*host.Service) + ret0, _ := ret[0].(*types.Service) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -717,10 +718,10 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ReadService(arg0 interface{}) *g } // ReadServiceInjectionManifestFile mocks base method. -func (m *MockHostHelpersInterface) ReadServiceInjectionManifestFile(path string) (*host.Service, error) { +func (m *MockHostHelpersInterface) ReadServiceInjectionManifestFile(path string) (*types.Service, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ReadServiceInjectionManifestFile", path) - ret0, _ := ret[0].(*host.Service) + ret0, _ := ret[0].(*types.Service) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -732,10 +733,10 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ReadServiceInjectionManifestFile } // ReadServiceManifestFile mocks base method. -func (m *MockHostHelpersInterface) ReadServiceManifestFile(path string) (*host.Service, error) { +func (m *MockHostHelpersInterface) ReadServiceManifestFile(path string) (*types.Service, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ReadServiceManifestFile", path) - ret0, _ := ret[0].(*host.Service) + ret0, _ := ret[0].(*types.Service) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -775,14 +776,14 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ReloadDriver(arg0 interface{}) * } // RemoveFromService mocks base method. -func (m *MockHostHelpersInterface) RemoveFromService(service *host.Service, options ...*unit.UnitOption) (*host.Service, error) { +func (m *MockHostHelpersInterface) RemoveFromService(service *types.Service, options ...*unit.UnitOption) (*types.Service, error) { m.ctrl.T.Helper() varargs := []interface{}{service} for _, a := range options { varargs = append(varargs, a) } ret := m.ctrl.Call(m, "RemoveFromService", varargs...) - ret0, _ := ret[0].(*host.Service) + ret0, _ := ret[0].(*types.Service) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -1037,7 +1038,7 @@ func (mr *MockHostHelpersInterfaceMockRecorder) UnbindDriverIfNeeded(arg0, arg1 } // UpdateSystemService mocks base method. -func (m *MockHostHelpersInterface) UpdateSystemService(serviceObj *host.Service) error { +func (m *MockHostHelpersInterface) UpdateSystemService(serviceObj *types.Service) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateSystemService", serviceObj) ret0, _ := ret[0].(error) diff --git a/pkg/host/interface.go b/pkg/host/interface.go deleted file mode 100644 index edccfd5c8..000000000 --- a/pkg/host/interface.go +++ /dev/null @@ -1,55 +0,0 @@ -package host - -import ( - "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" - "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" -) - -const ( - hostPathFromDaemon = consts.Host - redhatReleaseFile = "/etc/redhat-release" - rhelRDMAConditionFile = "/usr/libexec/rdma-init-kernel" - rhelRDMAServiceName = "rdma" - rhelPackageManager = "yum" - - ubuntuRDMAConditionFile = "/usr/sbin/rdma-ndd" - ubuntuRDMAServiceName = "rdma-ndd" - ubuntuPackageManager = "apt-get" - - genericOSReleaseFile = "/etc/os-release" -) - -// Contains all the host manipulation functions -type HostManagerInterface interface { - KernelInterface - NetworkInterface - ServiceInterface - UdevInterface - SriovInterface -} - -type hostManager struct { - utils.CmdInterface - KernelInterface - NetworkInterface - ServiceInterface - UdevInterface - SriovInterface -} - -func NewHostManager(utilsInterface utils.CmdInterface) HostManagerInterface { - k := newKernelInterface(utilsInterface) - n := newNetworkInterface(utilsInterface) - sv := newServiceInterface(utilsInterface) - u := newUdevInterface(utilsInterface) - sr := newSriovInterface(utilsInterface, k, n, u) - - return &hostManager{ - utilsInterface, - k, - n, - sv, - u, - sr, - } -} diff --git a/pkg/host/internal/common.go b/pkg/host/internal/common.go new file mode 100644 index 000000000..b32d2cd93 --- /dev/null +++ b/pkg/host/internal/common.go @@ -0,0 +1,19 @@ +package internal + +import ( + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" +) + +const ( + HostPathFromDaemon = consts.Host + RedhatReleaseFile = "/etc/redhat-release" + RhelRDMAConditionFile = "/usr/libexec/rdma-init-kernel" + RhelRDMAServiceName = "rdma" + RhelPackageManager = "yum" + + UbuntuRDMAConditionFile = "/usr/sbin/rdma-ndd" + UbuntuRDMAServiceName = "rdma-ndd" + UbuntuPackageManager = "apt-get" + + GenericOSReleaseFile = "/etc/os-release" +) diff --git a/pkg/host/kernel.go b/pkg/host/internal/kernel/kernel.go similarity index 85% rename from pkg/host/kernel.go rename to pkg/host/internal/kernel/kernel.go index 171807d95..3b3ab5fe6 100644 --- a/pkg/host/kernel.go +++ b/pkg/host/internal/kernel/kernel.go @@ -1,4 +1,4 @@ -package host +package kernel import ( "errors" @@ -11,77 +11,17 @@ import ( sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars" ) -type KernelInterface interface { - // TryEnableTun load the tun kernel module - TryEnableTun() - // TryEnableVhostNet load the vhost-net kernel module - TryEnableVhostNet() - // TryEnableRdma tries to enable RDMA on the machine base on the operating system - // if the package doesn't exist it will also will try to install it - // supported operating systems are RHEL RHCOS and ubuntu - TryEnableRdma() (bool, error) - // TriggerUdevEvent triggers a udev event - TriggerUdevEvent() error - // GetCurrentKernelArgs reads the /proc/cmdline to check the current kernel arguments - GetCurrentKernelArgs() (string, error) - // IsKernelArgsSet check is the requested kernel arguments are set - IsKernelArgsSet(string, string) bool - // Unbind unbinds a virtual function from is current driver - Unbind(string) error - // BindDpdkDriver binds the virtual function to a DPDK driver - BindDpdkDriver(string, string) error - // BindDefaultDriver binds the virtual function to is default driver - BindDefaultDriver(string) error - // BindDriverByBusAndDevice binds device to the provided driver - // bus - the bus path in the sysfs, e.g. "pci" or "vdpa" - // device - the name of the device on the bus, e.g. 0000:85:1e.5 for PCI or vpda1 for VDPA - // driver - the name of the driver, e.g. vfio-pci or vhost_vdpa. - BindDriverByBusAndDevice(bus, device, driver string) error - // HasDriver returns try if the virtual function is bind to a driver - HasDriver(string) (bool, string) - // RebindVfToDefaultDriver rebinds the virtual function to is default driver - RebindVfToDefaultDriver(string) error - // UnbindDriverIfNeeded unbinds the virtual function from a driver if needed - UnbindDriverIfNeeded(string, bool) error - // UnbindDriverByBusAndDevice unbind device identified by bus and device ID from the driver - // bus - the bus path in the sysfs, e.g. "pci" or "vdpa" - // device - the name of the device on the bus, e.g. 0000:85:1e.5 for PCI or vpda1 for VDPA - UnbindDriverByBusAndDevice(bus, device string) error - // LoadKernelModule loads a kernel module to the host - LoadKernelModule(name string, args ...string) error - // IsKernelModuleLoaded returns try if the requested kernel module is loaded - IsKernelModuleLoaded(string) (bool, error) - // ReloadDriver reloads a requested driver - ReloadDriver(string) error - // IsKernelLockdownMode returns true if the kernel is in lockdown mode - IsKernelLockdownMode() bool - // IsRHELSystem returns try if the system is a RHEL base - IsRHELSystem() (bool, error) - // IsUbuntuSystem returns try if the system is an ubuntu base - IsUbuntuSystem() (bool, error) - // IsCoreOS returns true if the system is a CoreOS or RHCOS base - IsCoreOS() (bool, error) - // RdmaIsLoaded returns try if RDMA kernel modules are loaded - RdmaIsLoaded() (bool, error) - // EnableRDMA enable RDMA on the system - EnableRDMA(string, string, string) (bool, error) - // InstallRDMA install RDMA packages on the system - InstallRDMA(string) error - // EnableRDMAOnRHELMachine enable RDMA on a RHEL base system - EnableRDMAOnRHELMachine() (bool, error) - // GetOSPrettyName returns OS name - GetOSPrettyName() (string, error) -} - type kernel struct { utilsHelper utils.CmdInterface } -func newKernelInterface(utilsHelper utils.CmdInterface) KernelInterface { +func New(utilsHelper utils.CmdInterface) types.KernelInterface { return &kernel{utilsHelper: utilsHelper} } @@ -384,7 +324,7 @@ func (k *kernel) EnableRDMAOnRHELMachine() (bool, error) { // RHEL log.Log.Info("EnableRDMAOnRHELMachine(): enabling RDMA on RHEL machine") - isRDMAEnable, err := k.EnableRDMA(rhelRDMAConditionFile, rhelRDMAServiceName, rhelPackageManager) + isRDMAEnable, err := k.EnableRDMA(internal.RhelRDMAConditionFile, internal.RhelRDMAServiceName, internal.RhelPackageManager) if err != nil { log.Log.Error(err, "EnableRDMAOnRHELMachine(): failed to enable RDMA on RHEL machine") return false, err @@ -413,7 +353,7 @@ func (k *kernel) EnableRDMAOnRHELMachine() (bool, error) { func (k *kernel) EnableRDMAOnUbuntuMachine() (bool, error) { log.Log.Info("EnableRDMAOnUbuntuMachine(): enabling RDMA on RHEL machine") - isRDMAEnable, err := k.EnableRDMA(ubuntuRDMAConditionFile, ubuntuRDMAServiceName, ubuntuPackageManager) + isRDMAEnable, err := k.EnableRDMA(internal.UbuntuRDMAConditionFile, internal.UbuntuRDMAServiceName, internal.UbuntuPackageManager) if err != nil { log.Log.Error(err, "EnableRDMAOnUbuntuMachine(): failed to enable RDMA on Ubuntu machine") return false, err @@ -442,9 +382,9 @@ func (k *kernel) EnableRDMAOnUbuntuMachine() (bool, error) { func (k *kernel) IsRHELSystem() (bool, error) { log.Log.Info("IsRHELSystem(): checking for RHEL machine") - path := redhatReleaseFile + path := internal.RedhatReleaseFile if !vars.UsingSystemdMode { - path = filepath.Join(hostPathFromDaemon, path) + path = filepath.Join(internal.HostPathFromDaemon, path) } if _, err := os.Stat(path); err != nil { if os.IsNotExist(err) { @@ -461,9 +401,9 @@ func (k *kernel) IsRHELSystem() (bool, error) { func (k *kernel) IsCoreOS() (bool, error) { log.Log.Info("IsCoreOS(): checking for CoreOS machine") - path := redhatReleaseFile + path := internal.RedhatReleaseFile if !vars.UsingSystemdMode { - path = filepath.Join(hostPathFromDaemon, path) + path = filepath.Join(internal.HostPathFromDaemon, path) } data, err := os.ReadFile(path) @@ -481,9 +421,9 @@ func (k *kernel) IsCoreOS() (bool, error) { func (k *kernel) IsUbuntuSystem() (bool, error) { log.Log.Info("IsUbuntuSystem(): checking for Ubuntu machine") - path := genericOSReleaseFile + path := internal.GenericOSReleaseFile if !vars.UsingSystemdMode { - path = filepath.Join(hostPathFromDaemon, path) + path = filepath.Join(internal.HostPathFromDaemon, path) } if _, err := os.Stat(path); err != nil { @@ -530,7 +470,7 @@ func (k *kernel) RdmaIsLoaded() (bool, error) { func (k *kernel) EnableRDMA(conditionFilePath, serviceName, packageManager string) (bool, error) { path := conditionFilePath if !vars.UsingSystemdMode { - path = filepath.Join(hostPathFromDaemon, path) + path = filepath.Join(internal.HostPathFromDaemon, path) } log.Log.Info("EnableRDMA(): checking for service file", "path", path) @@ -604,9 +544,9 @@ func (k *kernel) ReloadDriver(driverName string) error { } func (k *kernel) GetOSPrettyName() (string, error) { - path := genericOSReleaseFile + path := internal.GenericOSReleaseFile if !vars.UsingSystemdMode { - path = filepath.Join(hostPathFromDaemon, path) + path = filepath.Join(internal.HostPathFromDaemon, path) } log.Log.Info("GetOSPrettyName(): getting os name from os-release file") diff --git a/pkg/host/kernel_test.go b/pkg/host/internal/kernel/kernel_test.go similarity index 98% rename from pkg/host/kernel_test.go rename to pkg/host/internal/kernel/kernel_test.go index 687cda454..de6f22cec 100644 --- a/pkg/host/kernel_test.go +++ b/pkg/host/internal/kernel/kernel_test.go @@ -1,4 +1,4 @@ -package host +package kernel import ( "os" @@ -8,6 +8,7 @@ import ( . "github.com/onsi/gomega" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars" "github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/fakefilesystem" ) @@ -21,7 +22,7 @@ func assertFileContentsEquals(path, expectedContent string) { var _ = Describe("Kernel", func() { Context("Drivers", func() { var ( - k KernelInterface + k types.KernelInterface ) configureFS := func(f *fakefilesystem.FS) { var ( @@ -33,7 +34,7 @@ var _ = Describe("Kernel", func() { DeferCleanup(cleanFakeFs) } BeforeEach(func() { - k = newKernelInterface(nil) + k = New(nil) }) Context("Unbind, UnbindDriverByBusAndDevice", func() { It("unknown device", func() { diff --git a/pkg/host/suite_test.go b/pkg/host/internal/kernel/suite_test.go similarity index 79% rename from pkg/host/suite_test.go rename to pkg/host/internal/kernel/suite_test.go index 674437292..b36acb454 100644 --- a/pkg/host/suite_test.go +++ b/pkg/host/internal/kernel/suite_test.go @@ -1,4 +1,4 @@ -package host +package kernel import ( "testing" @@ -11,11 +11,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" ) -func TestHostManager(t *testing.T) { +func TestKernel(t *testing.T) { log.SetLogger(zap.New( zap.WriteTo(GinkgoWriter), zap.Level(zapcore.Level(-2)), zap.UseDevMode(true))) RegisterFailHandler(Fail) - RunSpecs(t, "Package Host Suite") + RunSpecs(t, "Package Kernel Suite") } diff --git a/pkg/host/network.go b/pkg/host/internal/network/network.go similarity index 82% rename from pkg/host/network.go rename to pkg/host/internal/network/network.go index dab12b354..4f97b2634 100644 --- a/pkg/host/network.go +++ b/pkg/host/internal/network/network.go @@ -1,4 +1,4 @@ -package host +package network import ( "fmt" @@ -14,38 +14,16 @@ import ( dputils "github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/utils" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars" ) -type NetworkInterface interface { - // TryToGetVirtualInterfaceName tries to find the virtio interface name base on pci address - // used for virtual environment where we pass SR-IOV virtual function into the system - // supported platform openstack - TryToGetVirtualInterfaceName(string) string - // TryGetInterfaceName tries to find the SR-IOV virtual interface name base on pci address - TryGetInterfaceName(string) string - // GetPhysSwitchID returns the physical switch ID for a specific pci address - GetPhysSwitchID(string) (string, error) - // GetPhysPortName returns the physical port name for a specific pci address - GetPhysPortName(string) (string, error) - // IsSwitchdev returns true of the pci address is on switchdev mode - IsSwitchdev(string) bool - // GetNetdevMTU returns the interface MTU for devices attached to kernel drivers - GetNetdevMTU(string) int - // SetNetdevMTU sets the MTU for a request interface - SetNetdevMTU(string, int) error - // GetNetDevMac returns the network interface mac address - GetNetDevMac(string) string - // GetNetDevLinkSpeed returns the network interface link speed - GetNetDevLinkSpeed(string) string -} - type network struct { utilsHelper utils.CmdInterface } -func newNetworkInterface(utilsHelper utils.CmdInterface) NetworkInterface { +func New(utilsHelper utils.CmdInterface) types.NetworkInterface { return &network{utilsHelper: utilsHelper} } diff --git a/pkg/host/service.go b/pkg/host/internal/service/service.go similarity index 66% rename from pkg/host/service.go rename to pkg/host/internal/service/service.go index 513542e66..4ecec5b5f 100644 --- a/pkg/host/service.go +++ b/pkg/host/internal/service/service.go @@ -1,4 +1,4 @@ -package host +package service import ( "fmt" @@ -13,58 +13,21 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" ) // TODO: handle this to support unit-tests const systemdDir = "/usr/lib/systemd/system/" -var ( - // Remove run condition form the service - ConditionOpt = &unit.UnitOption{ - Section: "Unit", - Name: "ConditionPathExists", - Value: "!/etc/ignition-machine-config-encapsulated.json", - } -) - -type ServiceInterface interface { - // IsServiceExist checks if the requested systemd service exist on the system - IsServiceExist(string) (bool, error) - // IsServiceEnabled checks if the requested systemd service is enabled on the system - IsServiceEnabled(string) (bool, error) - // ReadService reads a systemd servers and return it as a struct - ReadService(string) (*Service, error) - // EnableService enables a systemd server on the host - EnableService(service *Service) error - // ReadServiceManifestFile reads the systemd manifest for a specific service - ReadServiceManifestFile(path string) (*Service, error) - // RemoveFromService removes a systemd service from the host - RemoveFromService(service *Service, options ...*unit.UnitOption) (*Service, error) - // ReadScriptManifestFile reads the script manifest from a systemd service - ReadScriptManifestFile(path string) (*ScriptManifestFile, error) - // ReadServiceInjectionManifestFile reads the injection manifest file for the systemd service - ReadServiceInjectionManifestFile(path string) (*Service, error) - // CompareServices compare two servers and return true if they are equal - CompareServices(serviceA, serviceB *Service) (bool, error) - // UpdateSystemService updates a system service on the host - UpdateSystemService(serviceObj *Service) error -} - type service struct { utilsHelper utils.CmdInterface } -func newServiceInterface(utilsHelper utils.CmdInterface) ServiceInterface { +func New(utilsHelper utils.CmdInterface) types.ServiceInterface { return &service{utilsHelper: utilsHelper} } -type Service struct { - Name string - Path string - Content string -} - // ServiceInjectionManifestFile service injection manifest file structure type ServiceInjectionManifestFile struct { Name string @@ -73,20 +36,6 @@ type ServiceInjectionManifestFile struct { } } -// ServiceManifestFile service manifest file structure -type ServiceManifestFile struct { - Name string - Contents string -} - -// ScriptManifestFile script manifest file structure -type ScriptManifestFile struct { - Path string - Contents struct { - Inline string - } -} - // IsServiceExist check if service unit exist func (s *service) IsServiceExist(servicePath string) (bool, error) { _, err := os.Stat(path.Join(consts.Chroot, servicePath)) @@ -120,13 +69,13 @@ func (s *service) IsServiceEnabled(servicePath string) (bool, error) { } // ReadService read service from given path -func (s *service) ReadService(servicePath string) (*Service, error) { +func (s *service) ReadService(servicePath string) (*types.Service, error) { data, err := os.ReadFile(path.Join(consts.Chroot, servicePath)) if err != nil { return nil, err } - return &Service{ + return &types.Service{ Name: filepath.Base(servicePath), Path: servicePath, Content: string(data), @@ -134,7 +83,7 @@ func (s *service) ReadService(servicePath string) (*Service, error) { } // EnableService creates service file and enables it with systemctl enable -func (s *service) EnableService(service *Service) error { +func (s *service) EnableService(service *types.Service) error { // Write service file err := os.WriteFile(path.Join(consts.Chroot, service.Path), []byte(service.Content), 0644) if err != nil { @@ -154,7 +103,7 @@ func (s *service) EnableService(service *Service) error { } // CompareServices compare 2 service and return true if serviceA has all the fields of serviceB -func (s *service) CompareServices(serviceA, serviceB *Service) (bool, error) { +func (s *service) CompareServices(serviceA, serviceB *types.Service) (bool, error) { optsA, err := unit.Deserialize(strings.NewReader(serviceA.Content)) if err != nil { return false, err @@ -179,7 +128,7 @@ OUTER: } // RemoveFromService removes given fields from service -func (s *service) RemoveFromService(service *Service, options ...*unit.UnitOption) (*Service, error) { +func (s *service) RemoveFromService(service *types.Service, options ...*unit.UnitOption) (*types.Service, error) { opts, err := unit.Deserialize(strings.NewReader(service.Content)) if err != nil { return nil, err @@ -202,7 +151,7 @@ OUTER: return nil, err } - return &Service{ + return &types.Service{ Name: service.Name, Path: service.Path, Content: string(data), @@ -210,7 +159,7 @@ OUTER: } // ReadServiceInjectionManifestFile reads service injection file -func (s *service) ReadServiceInjectionManifestFile(path string) (*Service, error) { +func (s *service) ReadServiceInjectionManifestFile(path string) (*types.Service, error) { data, err := os.ReadFile(path) if err != nil { return nil, err @@ -221,7 +170,7 @@ func (s *service) ReadServiceInjectionManifestFile(path string) (*Service, error return nil, err } - return &Service{ + return &types.Service{ Name: serviceContent.Name, Path: systemdDir + serviceContent.Name, Content: serviceContent.Dropins[0].Contents, @@ -229,18 +178,18 @@ func (s *service) ReadServiceInjectionManifestFile(path string) (*Service, error } // ReadServiceManifestFile reads service file -func (s *service) ReadServiceManifestFile(path string) (*Service, error) { +func (s *service) ReadServiceManifestFile(path string) (*types.Service, error) { data, err := os.ReadFile(path) if err != nil { return nil, err } - var serviceFile *ServiceManifestFile + var serviceFile *types.ServiceManifestFile if err := yaml.Unmarshal(data, &serviceFile); err != nil { return nil, err } - return &Service{ + return &types.Service{ Name: serviceFile.Name, Path: "/etc/systemd/system/" + serviceFile.Name, Content: serviceFile.Contents, @@ -248,13 +197,13 @@ func (s *service) ReadServiceManifestFile(path string) (*Service, error) { } // ReadScriptManifestFile reads script file -func (s *service) ReadScriptManifestFile(path string) (*ScriptManifestFile, error) { +func (s *service) ReadScriptManifestFile(path string) (*types.ScriptManifestFile, error) { data, err := os.ReadFile(path) if err != nil { return nil, err } - var scriptFile *ScriptManifestFile + var scriptFile *types.ScriptManifestFile if err := yaml.Unmarshal(data, &scriptFile); err != nil { return nil, err } @@ -262,7 +211,7 @@ func (s *service) ReadScriptManifestFile(path string) (*ScriptManifestFile, erro return scriptFile, nil } -func (s *service) UpdateSystemService(serviceObj *Service) error { +func (s *service) UpdateSystemService(serviceObj *types.Service) error { systemService, err := s.ReadService(serviceObj.Path) if err != nil { return err @@ -284,7 +233,7 @@ func (s *service) UpdateSystemService(serviceObj *Service) error { } // appendToService appends given fields to service -func appendToService(service *Service, options ...*unit.UnitOption) (*Service, error) { +func appendToService(service *types.Service, options ...*unit.UnitOption) (*types.Service, error) { serviceOptions, err := unit.Deserialize(strings.NewReader(service.Content)) if err != nil { return nil, err @@ -305,7 +254,7 @@ OUTER: return nil, err } - return &Service{ + return &types.Service{ Name: service.Name, Path: service.Path, Content: string(data), diff --git a/pkg/host/sriov.go b/pkg/host/internal/sriov/sriov.go similarity index 88% rename from pkg/host/sriov.go rename to pkg/host/internal/sriov/sriov.go index 8a878854b..3baf6cbec 100644 --- a/pkg/host/sriov.go +++ b/pkg/host/internal/sriov/sriov.go @@ -1,4 +1,4 @@ -package host +package sriov import ( "errors" @@ -19,52 +19,24 @@ import ( sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/store" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars" mlx "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vendors/mellanox" ) -type SriovInterface interface { - // SetSriovNumVfs changes the number of virtual functions allocated for a specific - // physical function base on pci address - SetSriovNumVfs(string, int) error - // GetVfInfo returns the virtual function information is the operator struct from the host information - GetVfInfo(string, []*ghw.PCIDevice) sriovnetworkv1.VirtualFunction - // SetVfGUID sets the GUID for a virtual function - SetVfGUID(string, netlink.Link) error - // VFIsReady returns the interface virtual function if the device is ready - VFIsReady(string) (netlink.Link, error) - // SetVfAdminMac sets the virtual function administrative mac address via the physical function - SetVfAdminMac(string, netlink.Link, netlink.Link) error - // GetNicSriovMode returns the interface mode - // supported modes SR-IOV legacy and switchdev - GetNicSriovMode(string) (string, error) - // GetLinkType return the link type - // supported types are ethernet and infiniband - GetLinkType(sriovnetworkv1.InterfaceExt) string - // ResetSriovDevice resets the number of virtual function for the specific physical function to zero - ResetSriovDevice(sriovnetworkv1.InterfaceExt) error - // DiscoverSriovDevices returns a list of all the available SR-IOV capable network interfaces on the system - DiscoverSriovDevices(StoreManagerInterface) ([]sriovnetworkv1.InterfaceExt, error) - // ConfigSriovDevice configure the request SR-IOV device with the desired configuration - ConfigSriovDevice(iface *sriovnetworkv1.Interface, ifaceStatus *sriovnetworkv1.InterfaceExt) error - // ConfigSriovInterfaces configure multiple SR-IOV devices with the desired configuration - ConfigSriovInterfaces(StoreManagerInterface, []sriovnetworkv1.Interface, []sriovnetworkv1.InterfaceExt, map[string]bool) error - // ConfigSriovInterfaces configure virtual functions for virtual environments with the desired configuration - ConfigSriovDeviceVirtual(iface *sriovnetworkv1.Interface) error -} - type sriov struct { utilsHelper utils.CmdInterface - kernelHelper KernelInterface - networkHelper NetworkInterface - udevHelper UdevInterface + kernelHelper types.KernelInterface + networkHelper types.NetworkInterface + udevHelper types.UdevInterface } -func newSriovInterface(utilsHelper utils.CmdInterface, - kernelHelper KernelInterface, - networkHelper NetworkInterface, - udevHelper UdevInterface) SriovInterface { +func New(utilsHelper utils.CmdInterface, + kernelHelper types.KernelInterface, + networkHelper types.NetworkInterface, + udevHelper types.UdevInterface) types.SriovInterface { return &sriov{utilsHelper: utilsHelper, kernelHelper: kernelHelper, networkHelper: networkHelper, udevHelper: udevHelper} } @@ -199,7 +171,7 @@ func (s *sriov) SetVfAdminMac(vfAddr string, pfLink, vfLink netlink.Link) error return nil } -func (s *sriov) DiscoverSriovDevices(storeManager StoreManagerInterface) ([]sriovnetworkv1.InterfaceExt, error) { +func (s *sriov) DiscoverSriovDevices(storeManager store.ManagerInterface) ([]sriovnetworkv1.InterfaceExt, error) { log.Log.V(2).Info("DiscoverSriovDevices") pfList := []sriovnetworkv1.InterfaceExt{} @@ -465,7 +437,8 @@ func (s *sriov) ConfigSriovDevice(iface *sriovnetworkv1.Interface, ifaceStatus * return nil } -func (s *sriov) ConfigSriovInterfaces(storeManager StoreManagerInterface, interfaces []sriovnetworkv1.Interface, ifaceStatuses []sriovnetworkv1.InterfaceExt, pfsToConfig map[string]bool) error { +func (s *sriov) ConfigSriovInterfaces(storeManager store.ManagerInterface, + interfaces []sriovnetworkv1.Interface, ifaceStatuses []sriovnetworkv1.InterfaceExt, pfsToConfig map[string]bool) error { if s.kernelHelper.IsKernelLockdownMode() && mlx.HasMellanoxInterfacesInSpec(ifaceStatuses, interfaces) { log.Log.Error(nil, "cannot use mellanox devices when in kernel lockdown mode") return fmt.Errorf("cannot use mellanox devices when in kernel lockdown mode") diff --git a/pkg/host/udev.go b/pkg/host/internal/udev/udev.go similarity index 89% rename from pkg/host/udev.go rename to pkg/host/internal/udev/udev.go index 5f4daee58..dad88913e 100644 --- a/pkg/host/udev.go +++ b/pkg/host/internal/udev/udev.go @@ -1,4 +1,4 @@ -package host +package udev import ( "bytes" @@ -13,27 +13,16 @@ import ( sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars" ) -type UdevInterface interface { - // WriteSwitchdevConfFile writes the needed switchdev configuration files for HW offload support - WriteSwitchdevConfFile(*sriovnetworkv1.SriovNetworkNodeState, map[string]bool) (bool, error) - // PrepareNMUdevRule creates the needed udev rules to disable NetworkManager from - // our managed SR-IOV virtual functions - PrepareNMUdevRule([]string) error - // AddUdevRule adds a specific udev rule to the system - AddUdevRule(string) error - // RemoveUdevRule removes a udev rule from the system - RemoveUdevRule(string) error -} - type udev struct { utilsHelper utils.CmdInterface } -func newUdevInterface(utilsHelper utils.CmdInterface) UdevInterface { +func New(utilsHelper utils.CmdInterface) types.UdevInterface { return &udev{utilsHelper: utilsHelper} } diff --git a/pkg/host/manager.go b/pkg/host/manager.go new file mode 100644 index 000000000..3b0f790e9 --- /dev/null +++ b/pkg/host/manager.go @@ -0,0 +1,46 @@ +package host + +import ( + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/kernel" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/network" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/service" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/sriov" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/udev" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils" +) + +// Contains all the host manipulation functions +type HostManagerInterface interface { + types.KernelInterface + types.NetworkInterface + types.ServiceInterface + types.UdevInterface + types.SriovInterface +} + +type hostManager struct { + utils.CmdInterface + types.KernelInterface + types.NetworkInterface + types.ServiceInterface + types.UdevInterface + types.SriovInterface +} + +func NewHostManager(utilsInterface utils.CmdInterface) HostManagerInterface { + k := kernel.New(utilsInterface) + n := network.New(utilsInterface) + sv := service.New(utilsInterface) + u := udev.New(utilsInterface) + sr := sriov.New(utilsInterface, k, n, u) + + return &hostManager{ + utilsInterface, + k, + n, + sv, + u, + sr, + } +} diff --git a/pkg/host/mock/mock_store.go b/pkg/host/mock/mock_store.go deleted file mode 100644 index 54eae5850..000000000 --- a/pkg/host/mock/mock_store.go +++ /dev/null @@ -1,108 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: store.go - -// Package mock_host is a generated GoMock package. -package mock_host - -import ( - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - v1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" -) - -// MockStoreManagerInterface is a mock of StoreManagerInterface interface. -type MockStoreManagerInterface struct { - ctrl *gomock.Controller - recorder *MockStoreManagerInterfaceMockRecorder -} - -// MockStoreManagerInterfaceMockRecorder is the mock recorder for MockStoreManagerInterface. -type MockStoreManagerInterfaceMockRecorder struct { - mock *MockStoreManagerInterface -} - -// NewMockStoreManagerInterface creates a new mock instance. -func NewMockStoreManagerInterface(ctrl *gomock.Controller) *MockStoreManagerInterface { - mock := &MockStoreManagerInterface{ctrl: ctrl} - mock.recorder = &MockStoreManagerInterfaceMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockStoreManagerInterface) EXPECT() *MockStoreManagerInterfaceMockRecorder { - return m.recorder -} - -// ClearPCIAddressFolder mocks base method. -func (m *MockStoreManagerInterface) ClearPCIAddressFolder() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ClearPCIAddressFolder") - ret0, _ := ret[0].(error) - return ret0 -} - -// ClearPCIAddressFolder indicates an expected call of ClearPCIAddressFolder. -func (mr *MockStoreManagerInterfaceMockRecorder) ClearPCIAddressFolder() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearPCIAddressFolder", reflect.TypeOf((*MockStoreManagerInterface)(nil).ClearPCIAddressFolder)) -} - -// GetCheckPointNodeState mocks base method. -func (m *MockStoreManagerInterface) GetCheckPointNodeState() (*v1.SriovNetworkNodeState, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCheckPointNodeState") - ret0, _ := ret[0].(*v1.SriovNetworkNodeState) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCheckPointNodeState indicates an expected call of GetCheckPointNodeState. -func (mr *MockStoreManagerInterfaceMockRecorder) GetCheckPointNodeState() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCheckPointNodeState", reflect.TypeOf((*MockStoreManagerInterface)(nil).GetCheckPointNodeState)) -} - -// LoadPfsStatus mocks base method. -func (m *MockStoreManagerInterface) LoadPfsStatus(pciAddress string) (*v1.Interface, bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LoadPfsStatus", pciAddress) - ret0, _ := ret[0].(*v1.Interface) - ret1, _ := ret[1].(bool) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 -} - -// LoadPfsStatus indicates an expected call of LoadPfsStatus. -func (mr *MockStoreManagerInterfaceMockRecorder) LoadPfsStatus(pciAddress interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPfsStatus", reflect.TypeOf((*MockStoreManagerInterface)(nil).LoadPfsStatus), pciAddress) -} - -// SaveLastPfAppliedStatus mocks base method. -func (m *MockStoreManagerInterface) SaveLastPfAppliedStatus(PfInfo *v1.Interface) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SaveLastPfAppliedStatus", PfInfo) - ret0, _ := ret[0].(error) - return ret0 -} - -// SaveLastPfAppliedStatus indicates an expected call of SaveLastPfAppliedStatus. -func (mr *MockStoreManagerInterfaceMockRecorder) SaveLastPfAppliedStatus(PfInfo interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveLastPfAppliedStatus", reflect.TypeOf((*MockStoreManagerInterface)(nil).SaveLastPfAppliedStatus), PfInfo) -} - -// WriteCheckpointFile mocks base method. -func (m *MockStoreManagerInterface) WriteCheckpointFile(arg0 *v1.SriovNetworkNodeState) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WriteCheckpointFile", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// WriteCheckpointFile indicates an expected call of WriteCheckpointFile. -func (mr *MockStoreManagerInterfaceMockRecorder) WriteCheckpointFile(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteCheckpointFile", reflect.TypeOf((*MockStoreManagerInterface)(nil).WriteCheckpointFile), arg0) -} diff --git a/pkg/host/store/mock/mock_store.go b/pkg/host/store/mock/mock_store.go new file mode 100644 index 000000000..2e0071dfd --- /dev/null +++ b/pkg/host/store/mock/mock_store.go @@ -0,0 +1,108 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: store.go + +// Package mock_store is a generated GoMock package. +package mock_store + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + v1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" +) + +// MockManagerInterface is a mock of ManagerInterface interface. +type MockManagerInterface struct { + ctrl *gomock.Controller + recorder *MockManagerInterfaceMockRecorder +} + +// MockManagerInterfaceMockRecorder is the mock recorder for MockManagerInterface. +type MockManagerInterfaceMockRecorder struct { + mock *MockManagerInterface +} + +// NewMockManagerInterface creates a new mock instance. +func NewMockManagerInterface(ctrl *gomock.Controller) *MockManagerInterface { + mock := &MockManagerInterface{ctrl: ctrl} + mock.recorder = &MockManagerInterfaceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockManagerInterface) EXPECT() *MockManagerInterfaceMockRecorder { + return m.recorder +} + +// ClearPCIAddressFolder mocks base method. +func (m *MockManagerInterface) ClearPCIAddressFolder() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ClearPCIAddressFolder") + ret0, _ := ret[0].(error) + return ret0 +} + +// ClearPCIAddressFolder indicates an expected call of ClearPCIAddressFolder. +func (mr *MockManagerInterfaceMockRecorder) ClearPCIAddressFolder() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearPCIAddressFolder", reflect.TypeOf((*MockManagerInterface)(nil).ClearPCIAddressFolder)) +} + +// GetCheckPointNodeState mocks base method. +func (m *MockManagerInterface) GetCheckPointNodeState() (*v1.SriovNetworkNodeState, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCheckPointNodeState") + ret0, _ := ret[0].(*v1.SriovNetworkNodeState) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCheckPointNodeState indicates an expected call of GetCheckPointNodeState. +func (mr *MockManagerInterfaceMockRecorder) GetCheckPointNodeState() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCheckPointNodeState", reflect.TypeOf((*MockManagerInterface)(nil).GetCheckPointNodeState)) +} + +// LoadPfsStatus mocks base method. +func (m *MockManagerInterface) LoadPfsStatus(pciAddress string) (*v1.Interface, bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "LoadPfsStatus", pciAddress) + ret0, _ := ret[0].(*v1.Interface) + ret1, _ := ret[1].(bool) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// LoadPfsStatus indicates an expected call of LoadPfsStatus. +func (mr *MockManagerInterfaceMockRecorder) LoadPfsStatus(pciAddress interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadPfsStatus", reflect.TypeOf((*MockManagerInterface)(nil).LoadPfsStatus), pciAddress) +} + +// SaveLastPfAppliedStatus mocks base method. +func (m *MockManagerInterface) SaveLastPfAppliedStatus(PfInfo *v1.Interface) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SaveLastPfAppliedStatus", PfInfo) + ret0, _ := ret[0].(error) + return ret0 +} + +// SaveLastPfAppliedStatus indicates an expected call of SaveLastPfAppliedStatus. +func (mr *MockManagerInterfaceMockRecorder) SaveLastPfAppliedStatus(PfInfo interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveLastPfAppliedStatus", reflect.TypeOf((*MockManagerInterface)(nil).SaveLastPfAppliedStatus), PfInfo) +} + +// WriteCheckpointFile mocks base method. +func (m *MockManagerInterface) WriteCheckpointFile(arg0 *v1.SriovNetworkNodeState) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WriteCheckpointFile", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// WriteCheckpointFile indicates an expected call of WriteCheckpointFile. +func (mr *MockManagerInterfaceMockRecorder) WriteCheckpointFile(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteCheckpointFile", reflect.TypeOf((*MockManagerInterface)(nil).WriteCheckpointFile), arg0) +} diff --git a/pkg/host/store.go b/pkg/host/store/store.go similarity index 85% rename from pkg/host/store.go rename to pkg/host/store/store.go index 1bced8c9d..77e4bbd32 100644 --- a/pkg/host/store.go +++ b/pkg/host/store/store.go @@ -1,4 +1,4 @@ -package host +package store import ( "encoding/json" @@ -16,8 +16,8 @@ import ( // Contains all the file storing on the host // -//go:generate ../../bin/mockgen -destination mock/mock_store.go -source store.go -type StoreManagerInterface interface { +//go:generate ../../../bin/mockgen -destination mock/mock_store.go -source store.go +type ManagerInterface interface { ClearPCIAddressFolder() error SaveLastPfAppliedStatus(PfInfo *sriovnetworkv1.Interface) error LoadPfsStatus(pciAddress string) (*sriovnetworkv1.Interface, bool, error) @@ -26,17 +26,16 @@ type StoreManagerInterface interface { WriteCheckpointFile(*sriovnetworkv1.SriovNetworkNodeState) error } -type storeManager struct { -} +type manager struct{} -// NewStoreManager: create the initial folders needed to store the info about the PF -// and return a storeManager struct that implements the StoreManagerInterface interface -func NewStoreManager() (StoreManagerInterface, error) { +// NewManager: create the initial folders needed to store the info about the PF +// and return a manager struct that implements the ManagerInterface interface +func NewManager() (ManagerInterface, error) { if err := createOperatorConfigFolderIfNeeded(); err != nil { return nil, err } - return &storeManager{}, nil + return &manager{}, nil } // createOperatorConfigFolderIfNeeded: create the operator base folder on the host @@ -73,7 +72,7 @@ func createOperatorConfigFolderIfNeeded() error { } // ClearPCIAddressFolder: removes all the PFs storage information -func (s *storeManager) ClearPCIAddressFolder() error { +func (s *manager) ClearPCIAddressFolder() error { hostExtension := utils.GetHostExtension() PfAppliedConfigUse := filepath.Join(hostExtension, consts.PfAppliedConfig) _, err := os.Stat(PfAppliedConfigUse) @@ -99,7 +98,7 @@ func (s *storeManager) ClearPCIAddressFolder() error { // SaveLastPfAppliedStatus will save the PF object as a json into the /etc/sriov-operator/pci/ // this function must be called after running the chroot function -func (s *storeManager) SaveLastPfAppliedStatus(PfInfo *sriovnetworkv1.Interface) error { +func (s *manager) SaveLastPfAppliedStatus(PfInfo *sriovnetworkv1.Interface) error { data, err := json.Marshal(PfInfo) if err != nil { log.Log.Error(err, "failed to marshal PF status", "status", *PfInfo) @@ -114,7 +113,7 @@ func (s *storeManager) SaveLastPfAppliedStatus(PfInfo *sriovnetworkv1.Interface) // LoadPfsStatus convert the /etc/sriov-operator/pci/ json to pfstatus // returns false if the file doesn't exist. -func (s *storeManager) LoadPfsStatus(pciAddress string) (*sriovnetworkv1.Interface, bool, error) { +func (s *manager) LoadPfsStatus(pciAddress string) (*sriovnetworkv1.Interface, bool, error) { hostExtension := utils.GetHostExtension() pathFile := filepath.Join(hostExtension, consts.PfAppliedConfig, pciAddress) pfStatus := &sriovnetworkv1.Interface{} @@ -136,7 +135,7 @@ func (s *storeManager) LoadPfsStatus(pciAddress string) (*sriovnetworkv1.Interfa return pfStatus, true, nil } -func (s *storeManager) GetCheckPointNodeState() (*sriovnetworkv1.SriovNetworkNodeState, error) { +func (s *manager) GetCheckPointNodeState() (*sriovnetworkv1.SriovNetworkNodeState, error) { log.Log.Info("getCheckPointNodeState()") configdir := filepath.Join(vars.Destdir, consts.CheckpointFileName) file, err := os.OpenFile(configdir, os.O_RDONLY, 0644) @@ -154,7 +153,7 @@ func (s *storeManager) GetCheckPointNodeState() (*sriovnetworkv1.SriovNetworkNod return &sriovnetworkv1.InitialState, nil } -func (s *storeManager) WriteCheckpointFile(ns *sriovnetworkv1.SriovNetworkNodeState) error { +func (s *manager) WriteCheckpointFile(ns *sriovnetworkv1.SriovNetworkNodeState) error { configdir := filepath.Join(vars.Destdir, consts.CheckpointFileName) file, err := os.OpenFile(configdir, os.O_RDWR|os.O_CREATE, 0644) if err != nil { diff --git a/pkg/host/types/interfaces.go b/pkg/host/types/interfaces.go new file mode 100644 index 000000000..5a4b66ea8 --- /dev/null +++ b/pkg/host/types/interfaces.go @@ -0,0 +1,160 @@ +package types + +import ( + "github.com/coreos/go-systemd/v22/unit" + "github.com/jaypipes/ghw" + "github.com/vishvananda/netlink" + + sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" + "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/store" +) + +type KernelInterface interface { + // TryEnableTun load the tun kernel module + TryEnableTun() + // TryEnableVhostNet load the vhost-net kernel module + TryEnableVhostNet() + // TryEnableRdma tries to enable RDMA on the machine base on the operating system + // if the package doesn't exist it will also will try to install it + // supported operating systems are RHEL RHCOS and ubuntu + TryEnableRdma() (bool, error) + // TriggerUdevEvent triggers a udev event + TriggerUdevEvent() error + // GetCurrentKernelArgs reads the /proc/cmdline to check the current kernel arguments + GetCurrentKernelArgs() (string, error) + // IsKernelArgsSet check is the requested kernel arguments are set + IsKernelArgsSet(string, string) bool + // Unbind unbinds a virtual function from is current driver + Unbind(string) error + // BindDpdkDriver binds the virtual function to a DPDK driver + BindDpdkDriver(string, string) error + // BindDefaultDriver binds the virtual function to is default driver + BindDefaultDriver(string) error + // BindDriverByBusAndDevice binds device to the provided driver + // bus - the bus path in the sysfs, e.g. "pci" or "vdpa" + // device - the name of the device on the bus, e.g. 0000:85:1e.5 for PCI or vpda1 for VDPA + // driver - the name of the driver, e.g. vfio-pci or vhost_vdpa. + BindDriverByBusAndDevice(bus, device, driver string) error + // HasDriver returns try if the virtual function is bind to a driver + HasDriver(string) (bool, string) + // RebindVfToDefaultDriver rebinds the virtual function to is default driver + RebindVfToDefaultDriver(string) error + // UnbindDriverByBusAndDevice unbind device identified by bus and device ID from the driver + // bus - the bus path in the sysfs, e.g. "pci" or "vdpa" + // device - the name of the device on the bus, e.g. 0000:85:1e.5 for PCI or vpda1 for VDPA + UnbindDriverByBusAndDevice(bus, device string) error + // UnbindDriverIfNeeded unbinds the virtual function from a driver if needed + UnbindDriverIfNeeded(string, bool) error + // LoadKernelModule loads a kernel module to the host + LoadKernelModule(name string, args ...string) error + // IsKernelModuleLoaded returns try if the requested kernel module is loaded + IsKernelModuleLoaded(string) (bool, error) + // ReloadDriver reloads a requested driver + ReloadDriver(string) error + // IsKernelLockdownMode returns true if the kernel is in lockdown mode + IsKernelLockdownMode() bool + // IsRHELSystem returns try if the system is a RHEL base + IsRHELSystem() (bool, error) + // IsUbuntuSystem returns try if the system is an ubuntu base + IsUbuntuSystem() (bool, error) + // IsCoreOS returns true if the system is a CoreOS or RHCOS base + IsCoreOS() (bool, error) + // RdmaIsLoaded returns try if RDMA kernel modules are loaded + RdmaIsLoaded() (bool, error) + // EnableRDMA enable RDMA on the system + EnableRDMA(string, string, string) (bool, error) + // InstallRDMA install RDMA packages on the system + InstallRDMA(string) error + // EnableRDMAOnRHELMachine enable RDMA on a RHEL base system + EnableRDMAOnRHELMachine() (bool, error) + // GetOSPrettyName returns OS name + GetOSPrettyName() (string, error) +} + +type NetworkInterface interface { + // TryToGetVirtualInterfaceName tries to find the virtio interface name base on pci address + // used for virtual environment where we pass SR-IOV virtual function into the system + // supported platform openstack + TryToGetVirtualInterfaceName(string) string + // TryGetInterfaceName tries to find the SR-IOV virtual interface name base on pci address + TryGetInterfaceName(string) string + // GetPhysSwitchID returns the physical switch ID for a specific pci address + GetPhysSwitchID(string) (string, error) + // GetPhysPortName returns the physical port name for a specific pci address + GetPhysPortName(string) (string, error) + // IsSwitchdev returns true of the pci address is on switchdev mode + IsSwitchdev(string) bool + // GetNetdevMTU returns the interface MTU for devices attached to kernel drivers + GetNetdevMTU(string) int + // SetNetdevMTU sets the MTU for a request interface + SetNetdevMTU(string, int) error + // GetNetDevMac returns the network interface mac address + GetNetDevMac(string) string + // GetNetDevLinkSpeed returns the network interface link speed + GetNetDevLinkSpeed(string) string +} + +type ServiceInterface interface { + // IsServiceExist checks if the requested systemd service exist on the system + IsServiceExist(string) (bool, error) + // IsServiceEnabled checks if the requested systemd service is enabled on the system + IsServiceEnabled(string) (bool, error) + // ReadService reads a systemd servers and return it as a struct + ReadService(string) (*Service, error) + // EnableService enables a systemd server on the host + EnableService(service *Service) error + // ReadServiceManifestFile reads the systemd manifest for a specific service + ReadServiceManifestFile(path string) (*Service, error) + // RemoveFromService removes a systemd service from the host + RemoveFromService(service *Service, options ...*unit.UnitOption) (*Service, error) + // ReadScriptManifestFile reads the script manifest from a systemd service + ReadScriptManifestFile(path string) (*ScriptManifestFile, error) + // ReadServiceInjectionManifestFile reads the injection manifest file for the systemd service + ReadServiceInjectionManifestFile(path string) (*Service, error) + // CompareServices compare two servers and return true if they are equal + CompareServices(serviceA, serviceB *Service) (bool, error) + // UpdateSystemService updates a system service on the host + UpdateSystemService(serviceObj *Service) error +} + +type SriovInterface interface { + // SetSriovNumVfs changes the number of virtual functions allocated for a specific + // physical function base on pci address + SetSriovNumVfs(string, int) error + // GetVfInfo returns the virtual function information is the operator struct from the host information + GetVfInfo(string, []*ghw.PCIDevice) sriovnetworkv1.VirtualFunction + // SetVfGUID sets the GUID for a virtual function + SetVfGUID(string, netlink.Link) error + // VFIsReady returns the interface virtual function if the device is ready + VFIsReady(string) (netlink.Link, error) + // SetVfAdminMac sets the virtual function administrative mac address via the physical function + SetVfAdminMac(string, netlink.Link, netlink.Link) error + // GetNicSriovMode returns the interface mode + // supported modes SR-IOV legacy and switchdev + GetNicSriovMode(string) (string, error) + // GetLinkType return the link type + // supported types are ethernet and infiniband + GetLinkType(sriovnetworkv1.InterfaceExt) string + // ResetSriovDevice resets the number of virtual function for the specific physical function to zero + ResetSriovDevice(sriovnetworkv1.InterfaceExt) error + // DiscoverSriovDevices returns a list of all the available SR-IOV capable network interfaces on the system + DiscoverSriovDevices(store.ManagerInterface) ([]sriovnetworkv1.InterfaceExt, error) + // ConfigSriovDevice configure the request SR-IOV device with the desired configuration + ConfigSriovDevice(iface *sriovnetworkv1.Interface, ifaceStatus *sriovnetworkv1.InterfaceExt) error + // ConfigSriovInterfaces configure multiple SR-IOV devices with the desired configuration + ConfigSriovInterfaces(store.ManagerInterface, []sriovnetworkv1.Interface, []sriovnetworkv1.InterfaceExt, map[string]bool) error + // ConfigSriovInterfaces configure virtual functions for virtual environments with the desired configuration + ConfigSriovDeviceVirtual(iface *sriovnetworkv1.Interface) error +} + +type UdevInterface interface { + // WriteSwitchdevConfFile writes the needed switchdev configuration files for HW offload support + WriteSwitchdevConfFile(*sriovnetworkv1.SriovNetworkNodeState, map[string]bool) (bool, error) + // PrepareNMUdevRule creates the needed udev rules to disable NetworkManager from + // our managed SR-IOV virtual functions + PrepareNMUdevRule([]string) error + // AddUdevRule adds a specific udev rule to the system + AddUdevRule(string) error + // RemoveUdevRule removes a udev rule from the system + RemoveUdevRule(string) error +} diff --git a/pkg/host/types/types.go b/pkg/host/types/types.go new file mode 100644 index 000000000..935a34bfd --- /dev/null +++ b/pkg/host/types/types.go @@ -0,0 +1,43 @@ +package types + +import ( + "github.com/coreos/go-systemd/v22/unit" +) + +// Service contains info about systemd service +type Service struct { + Name string + Path string + Content string +} + +// ServiceInjectionManifestFile service injection manifest file structure +type ServiceInjectionManifestFile struct { + Name string + Dropins []struct { + Contents string + } +} + +// ServiceManifestFile service manifest file structure +type ServiceManifestFile struct { + Name string + Contents string +} + +// ScriptManifestFile script manifest file structure +type ScriptManifestFile struct { + Path string + Contents struct { + Inline string + } +} + +var ( + // Remove run condition form the service + ConditionOpt = &unit.UnitOption{ + Section: "Unit", + Name: "ConditionPathExists", + Value: "!/etc/ignition-machine-config-encapsulated.json", + } +) diff --git a/pkg/plugins/k8s/k8s_plugin.go b/pkg/plugins/k8s/k8s_plugin.go index 1bf70eab1..02b4e6336 100644 --- a/pkg/plugins/k8s/k8s_plugin.go +++ b/pkg/plugins/k8s/k8s_plugin.go @@ -11,7 +11,7 @@ import ( sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/helper" - "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host" + hostTypes "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" plugins "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins" "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/vars" ) @@ -21,14 +21,14 @@ var PluginName = "k8s_plugin" type K8sPlugin struct { PluginName string SpecVersion string - switchdevBeforeNMRunScript *host.ScriptManifestFile - switchdevAfterNMRunScript *host.ScriptManifestFile - switchdevUdevScript *host.ScriptManifestFile - switchdevBeforeNMService *host.Service - switchdevAfterNMService *host.Service - openVSwitchService *host.Service - networkManagerService *host.Service - sriovService *host.Service + switchdevBeforeNMRunScript *hostTypes.ScriptManifestFile + switchdevAfterNMRunScript *hostTypes.ScriptManifestFile + switchdevUdevScript *hostTypes.ScriptManifestFile + switchdevBeforeNMService *hostTypes.Service + switchdevAfterNMService *hostTypes.Service + openVSwitchService *hostTypes.Service + networkManagerService *hostTypes.Service + sriovService *hostTypes.Service updateTarget *k8sUpdateTarget hostHelper helper.HostHelpersInterface } @@ -40,7 +40,7 @@ type k8sUpdateTarget struct { switchdevAfterNMRunScript bool switchdevUdevScript bool sriovScript bool - systemServices []*host.Service + systemServices []*hostTypes.Service } func (u *k8sUpdateTarget) needUpdate() bool { @@ -58,7 +58,7 @@ func (u *k8sUpdateTarget) reset() { u.switchdevAfterNMRunScript = false u.switchdevUdevScript = false u.sriovScript = false - u.systemServices = []*host.Service{} + u.systemServices = []*hostTypes.Service{} } func (u *k8sUpdateTarget) String() string { @@ -193,11 +193,11 @@ func (p *K8sPlugin) readSwitchdevManifest() error { return err } - switchdevBeforeNMService, err = p.hostHelper.RemoveFromService(switchdevBeforeNMService, host.ConditionOpt) + switchdevBeforeNMService, err = p.hostHelper.RemoveFromService(switchdevBeforeNMService, hostTypes.ConditionOpt) if err != nil { return err } - switchdevAfterNMService, err = p.hostHelper.RemoveFromService(switchdevAfterNMService, host.ConditionOpt) + switchdevAfterNMService, err = p.hostHelper.RemoveFromService(switchdevAfterNMService, hostTypes.ConditionOpt) if err != nil { return err } @@ -331,11 +331,11 @@ func (p *K8sPlugin) sriovServiceStateUpdate() error { return nil } -func (p *K8sPlugin) getSwitchDevSystemServices() []*host.Service { - return []*host.Service{p.networkManagerService, p.openVSwitchService} +func (p *K8sPlugin) getSwitchDevSystemServices() []*hostTypes.Service { + return []*hostTypes.Service{p.networkManagerService, p.openVSwitchService} } -func (p *K8sPlugin) isSwitchdevScriptNeedUpdate(scriptObj *host.ScriptManifestFile) (needUpdate bool, err error) { +func (p *K8sPlugin) isSwitchdevScriptNeedUpdate(scriptObj *hostTypes.ScriptManifestFile) (needUpdate bool, err error) { data, err := os.ReadFile(path.Join(consts.Host, scriptObj.Path)) if err != nil { if !os.IsNotExist(err) { @@ -348,7 +348,7 @@ func (p *K8sPlugin) isSwitchdevScriptNeedUpdate(scriptObj *host.ScriptManifestFi return false, nil } -func (p *K8sPlugin) isSwitchdevServiceNeedUpdate(serviceObj *host.Service) (needUpdate bool, err error) { +func (p *K8sPlugin) isSwitchdevServiceNeedUpdate(serviceObj *hostTypes.Service) (needUpdate bool, err error) { swdService, err := p.hostHelper.ReadService(serviceObj.Path) if err != nil { if !os.IsNotExist(err) { @@ -365,7 +365,7 @@ func (p *K8sPlugin) isSwitchdevServiceNeedUpdate(serviceObj *host.Service) (need } } -func (p *K8sPlugin) isSystemServiceNeedUpdate(serviceObj *host.Service) bool { +func (p *K8sPlugin) isSystemServiceNeedUpdate(serviceObj *hostTypes.Service) bool { log.Log.Info("isSystemServiceNeedUpdate()") systemService, err := p.hostHelper.ReadService(serviceObj.Path) if err != nil { @@ -386,7 +386,7 @@ func (p *K8sPlugin) isSystemServiceNeedUpdate(serviceObj *host.Service) bool { } func (p *K8sPlugin) systemServicesStateUpdate() error { - var services []*host.Service + var services []*hostTypes.Service for _, systemService := range p.getSwitchDevSystemServices() { exist, err := p.hostHelper.IsServiceExist(systemService.Path) if err != nil { From 51c2e695361036be3eb79e324ff08ee7bd8fdb23 Mon Sep 17 00:00:00 2001 From: Yury Kulazhenkov Date: Wed, 17 Jan 2024 11:53:30 +0200 Subject: [PATCH 2/3] Use named args in interface definitions in host pkg Signed-off-by: Yury Kulazhenkov --- pkg/host/types/interfaces.go | 75 ++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/pkg/host/types/interfaces.go b/pkg/host/types/interfaces.go index 5a4b66ea8..d1613cd44 100644 --- a/pkg/host/types/interfaces.go +++ b/pkg/host/types/interfaces.go @@ -23,34 +23,34 @@ type KernelInterface interface { // GetCurrentKernelArgs reads the /proc/cmdline to check the current kernel arguments GetCurrentKernelArgs() (string, error) // IsKernelArgsSet check is the requested kernel arguments are set - IsKernelArgsSet(string, string) bool + IsKernelArgsSet(cmdLine, karg string) bool // Unbind unbinds a virtual function from is current driver - Unbind(string) error + Unbind(pciAddr string) error // BindDpdkDriver binds the virtual function to a DPDK driver - BindDpdkDriver(string, string) error + BindDpdkDriver(pciAddr, driver string) error // BindDefaultDriver binds the virtual function to is default driver - BindDefaultDriver(string) error + BindDefaultDriver(pciAddr string) error // BindDriverByBusAndDevice binds device to the provided driver // bus - the bus path in the sysfs, e.g. "pci" or "vdpa" // device - the name of the device on the bus, e.g. 0000:85:1e.5 for PCI or vpda1 for VDPA // driver - the name of the driver, e.g. vfio-pci or vhost_vdpa. BindDriverByBusAndDevice(bus, device, driver string) error // HasDriver returns try if the virtual function is bind to a driver - HasDriver(string) (bool, string) + HasDriver(pciAddr string) (bool, string) // RebindVfToDefaultDriver rebinds the virtual function to is default driver - RebindVfToDefaultDriver(string) error + RebindVfToDefaultDriver(pciAddr string) error // UnbindDriverByBusAndDevice unbind device identified by bus and device ID from the driver // bus - the bus path in the sysfs, e.g. "pci" or "vdpa" // device - the name of the device on the bus, e.g. 0000:85:1e.5 for PCI or vpda1 for VDPA UnbindDriverByBusAndDevice(bus, device string) error // UnbindDriverIfNeeded unbinds the virtual function from a driver if needed - UnbindDriverIfNeeded(string, bool) error + UnbindDriverIfNeeded(pciAddr string, isRdma bool) error // LoadKernelModule loads a kernel module to the host LoadKernelModule(name string, args ...string) error // IsKernelModuleLoaded returns try if the requested kernel module is loaded - IsKernelModuleLoaded(string) (bool, error) + IsKernelModuleLoaded(name string) (bool, error) // ReloadDriver reloads a requested driver - ReloadDriver(string) error + ReloadDriver(driver string) error // IsKernelLockdownMode returns true if the kernel is in lockdown mode IsKernelLockdownMode() bool // IsRHELSystem returns try if the system is a RHEL base @@ -62,9 +62,9 @@ type KernelInterface interface { // RdmaIsLoaded returns try if RDMA kernel modules are loaded RdmaIsLoaded() (bool, error) // EnableRDMA enable RDMA on the system - EnableRDMA(string, string, string) (bool, error) + EnableRDMA(conditionFilePath, serviceName, packageManager string) (bool, error) // InstallRDMA install RDMA packages on the system - InstallRDMA(string) error + InstallRDMA(packageManager string) error // EnableRDMAOnRHELMachine enable RDMA on a RHEL base system EnableRDMAOnRHELMachine() (bool, error) // GetOSPrettyName returns OS name @@ -75,32 +75,32 @@ type NetworkInterface interface { // TryToGetVirtualInterfaceName tries to find the virtio interface name base on pci address // used for virtual environment where we pass SR-IOV virtual function into the system // supported platform openstack - TryToGetVirtualInterfaceName(string) string + TryToGetVirtualInterfaceName(pciAddr string) string // TryGetInterfaceName tries to find the SR-IOV virtual interface name base on pci address - TryGetInterfaceName(string) string + TryGetInterfaceName(pciAddr string) string // GetPhysSwitchID returns the physical switch ID for a specific pci address - GetPhysSwitchID(string) (string, error) + GetPhysSwitchID(name string) (string, error) // GetPhysPortName returns the physical port name for a specific pci address - GetPhysPortName(string) (string, error) + GetPhysPortName(name string) (string, error) // IsSwitchdev returns true of the pci address is on switchdev mode - IsSwitchdev(string) bool + IsSwitchdev(name string) bool // GetNetdevMTU returns the interface MTU for devices attached to kernel drivers - GetNetdevMTU(string) int + GetNetdevMTU(pciAddr string) int // SetNetdevMTU sets the MTU for a request interface - SetNetdevMTU(string, int) error + SetNetdevMTU(pciAddr string, mtu int) error // GetNetDevMac returns the network interface mac address - GetNetDevMac(string) string + GetNetDevMac(name string) string // GetNetDevLinkSpeed returns the network interface link speed - GetNetDevLinkSpeed(string) string + GetNetDevLinkSpeed(name string) string } type ServiceInterface interface { // IsServiceExist checks if the requested systemd service exist on the system - IsServiceExist(string) (bool, error) + IsServiceExist(servicePath string) (bool, error) // IsServiceEnabled checks if the requested systemd service is enabled on the system - IsServiceEnabled(string) (bool, error) + IsServiceEnabled(servicePath string) (bool, error) // ReadService reads a systemd servers and return it as a struct - ReadService(string) (*Service, error) + ReadService(servicePath string) (*Service, error) // EnableService enables a systemd server on the host EnableService(service *Service) error // ReadServiceManifestFile reads the systemd manifest for a specific service @@ -120,41 +120,42 @@ type ServiceInterface interface { type SriovInterface interface { // SetSriovNumVfs changes the number of virtual functions allocated for a specific // physical function base on pci address - SetSriovNumVfs(string, int) error + SetSriovNumVfs(pciAddr string, numVfs int) error // GetVfInfo returns the virtual function information is the operator struct from the host information - GetVfInfo(string, []*ghw.PCIDevice) sriovnetworkv1.VirtualFunction + GetVfInfo(pciAddr string, devices []*ghw.PCIDevice) sriovnetworkv1.VirtualFunction // SetVfGUID sets the GUID for a virtual function - SetVfGUID(string, netlink.Link) error + SetVfGUID(vfAddr string, pfLink netlink.Link) error // VFIsReady returns the interface virtual function if the device is ready - VFIsReady(string) (netlink.Link, error) + VFIsReady(pciAddr string) (netlink.Link, error) // SetVfAdminMac sets the virtual function administrative mac address via the physical function - SetVfAdminMac(string, netlink.Link, netlink.Link) error + SetVfAdminMac(vfAddr string, pfLink netlink.Link, vfLink netlink.Link) error // GetNicSriovMode returns the interface mode // supported modes SR-IOV legacy and switchdev - GetNicSriovMode(string) (string, error) + GetNicSriovMode(pciAddr string) (string, error) // GetLinkType return the link type // supported types are ethernet and infiniband - GetLinkType(sriovnetworkv1.InterfaceExt) string + GetLinkType(ifaceStatus sriovnetworkv1.InterfaceExt) string // ResetSriovDevice resets the number of virtual function for the specific physical function to zero - ResetSriovDevice(sriovnetworkv1.InterfaceExt) error + ResetSriovDevice(ifaceStatus sriovnetworkv1.InterfaceExt) error // DiscoverSriovDevices returns a list of all the available SR-IOV capable network interfaces on the system - DiscoverSriovDevices(store.ManagerInterface) ([]sriovnetworkv1.InterfaceExt, error) + DiscoverSriovDevices(storeManager store.ManagerInterface) ([]sriovnetworkv1.InterfaceExt, error) // ConfigSriovDevice configure the request SR-IOV device with the desired configuration ConfigSriovDevice(iface *sriovnetworkv1.Interface, ifaceStatus *sriovnetworkv1.InterfaceExt) error // ConfigSriovInterfaces configure multiple SR-IOV devices with the desired configuration - ConfigSriovInterfaces(store.ManagerInterface, []sriovnetworkv1.Interface, []sriovnetworkv1.InterfaceExt, map[string]bool) error + ConfigSriovInterfaces(storeManager store.ManagerInterface, interfaces []sriovnetworkv1.Interface, + ifaceStatuses []sriovnetworkv1.InterfaceExt, pfsToConfig map[string]bool) error // ConfigSriovInterfaces configure virtual functions for virtual environments with the desired configuration ConfigSriovDeviceVirtual(iface *sriovnetworkv1.Interface) error } type UdevInterface interface { // WriteSwitchdevConfFile writes the needed switchdev configuration files for HW offload support - WriteSwitchdevConfFile(*sriovnetworkv1.SriovNetworkNodeState, map[string]bool) (bool, error) + WriteSwitchdevConfFile(newState *sriovnetworkv1.SriovNetworkNodeState, pfsToSkip map[string]bool) (bool, error) // PrepareNMUdevRule creates the needed udev rules to disable NetworkManager from // our managed SR-IOV virtual functions - PrepareNMUdevRule([]string) error + PrepareNMUdevRule(supportedVfIds []string) error // AddUdevRule adds a specific udev rule to the system - AddUdevRule(string) error + AddUdevRule(pfPciAddress string) error // RemoveUdevRule removes a udev rule from the system - RemoveUdevRule(string) error + RemoveUdevRule(pfPciAddress string) error } From bdb6d90fa3f6182deee201234584d2e7b82885cb Mon Sep 17 00:00:00 2001 From: Yury Kulazhenkov Date: Tue, 16 Jan 2024 09:59:41 +0200 Subject: [PATCH 3/3] Generate mock for host.HostManagerInterface interface Signed-off-by: Yury Kulazhenkov --- pkg/helper/mock/mock_helper.go | 296 +++++------ pkg/host/manager.go | 2 + pkg/host/mock/mock_host.go | 925 +++++++++++++++++++++++++++++++++ 3 files changed, 1075 insertions(+), 148 deletions(-) create mode 100644 pkg/host/mock/mock_host.go diff --git a/pkg/helper/mock/mock_helper.go b/pkg/helper/mock/mock_helper.go index c00180cd3..b96b0d4de 100644 --- a/pkg/helper/mock/mock_helper.go +++ b/pkg/helper/mock/mock_helper.go @@ -41,45 +41,45 @@ func (m *MockHostHelpersInterface) EXPECT() *MockHostHelpersInterfaceMockRecorde } // AddUdevRule mocks base method. -func (m *MockHostHelpersInterface) AddUdevRule(arg0 string) error { +func (m *MockHostHelpersInterface) AddUdevRule(pfPciAddress string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddUdevRule", arg0) + ret := m.ctrl.Call(m, "AddUdevRule", pfPciAddress) ret0, _ := ret[0].(error) return ret0 } // AddUdevRule indicates an expected call of AddUdevRule. -func (mr *MockHostHelpersInterfaceMockRecorder) AddUdevRule(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) AddUdevRule(pfPciAddress interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddUdevRule", reflect.TypeOf((*MockHostHelpersInterface)(nil).AddUdevRule), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddUdevRule", reflect.TypeOf((*MockHostHelpersInterface)(nil).AddUdevRule), pfPciAddress) } // BindDefaultDriver mocks base method. -func (m *MockHostHelpersInterface) BindDefaultDriver(arg0 string) error { +func (m *MockHostHelpersInterface) BindDefaultDriver(pciAddr string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BindDefaultDriver", arg0) + ret := m.ctrl.Call(m, "BindDefaultDriver", pciAddr) ret0, _ := ret[0].(error) return ret0 } // BindDefaultDriver indicates an expected call of BindDefaultDriver. -func (mr *MockHostHelpersInterfaceMockRecorder) BindDefaultDriver(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) BindDefaultDriver(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDefaultDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).BindDefaultDriver), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDefaultDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).BindDefaultDriver), pciAddr) } // BindDpdkDriver mocks base method. -func (m *MockHostHelpersInterface) BindDpdkDriver(arg0, arg1 string) error { +func (m *MockHostHelpersInterface) BindDpdkDriver(pciAddr, driver string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BindDpdkDriver", arg0, arg1) + ret := m.ctrl.Call(m, "BindDpdkDriver", pciAddr, driver) ret0, _ := ret[0].(error) return ret0 } // BindDpdkDriver indicates an expected call of BindDpdkDriver. -func (mr *MockHostHelpersInterfaceMockRecorder) BindDpdkDriver(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) BindDpdkDriver(pciAddr, driver interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDpdkDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).BindDpdkDriver), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDpdkDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).BindDpdkDriver), pciAddr, driver) } // BindDriverByBusAndDevice mocks base method. @@ -169,47 +169,47 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ConfigSriovDeviceVirtual(iface i } // ConfigSriovInterfaces mocks base method. -func (m *MockHostHelpersInterface) ConfigSriovInterfaces(arg0 store.ManagerInterface, arg1 []v1.Interface, arg2 []v1.InterfaceExt, arg3 map[string]bool) error { +func (m *MockHostHelpersInterface) ConfigSriovInterfaces(storeManager store.ManagerInterface, interfaces []v1.Interface, ifaceStatuses []v1.InterfaceExt, pfsToConfig map[string]bool) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ConfigSriovInterfaces", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "ConfigSriovInterfaces", storeManager, interfaces, ifaceStatuses, pfsToConfig) ret0, _ := ret[0].(error) return ret0 } // ConfigSriovInterfaces indicates an expected call of ConfigSriovInterfaces. -func (mr *MockHostHelpersInterfaceMockRecorder) ConfigSriovInterfaces(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) ConfigSriovInterfaces(storeManager, interfaces, ifaceStatuses, pfsToConfig interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConfigSriovInterfaces", reflect.TypeOf((*MockHostHelpersInterface)(nil).ConfigSriovInterfaces), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConfigSriovInterfaces", reflect.TypeOf((*MockHostHelpersInterface)(nil).ConfigSriovInterfaces), storeManager, interfaces, ifaceStatuses, pfsToConfig) } // DiscoverSriovDevices mocks base method. -func (m *MockHostHelpersInterface) DiscoverSriovDevices(arg0 store.ManagerInterface) ([]v1.InterfaceExt, error) { +func (m *MockHostHelpersInterface) DiscoverSriovDevices(storeManager store.ManagerInterface) ([]v1.InterfaceExt, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DiscoverSriovDevices", arg0) + ret := m.ctrl.Call(m, "DiscoverSriovDevices", storeManager) ret0, _ := ret[0].([]v1.InterfaceExt) ret1, _ := ret[1].(error) return ret0, ret1 } // DiscoverSriovDevices indicates an expected call of DiscoverSriovDevices. -func (mr *MockHostHelpersInterfaceMockRecorder) DiscoverSriovDevices(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) DiscoverSriovDevices(storeManager interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DiscoverSriovDevices", reflect.TypeOf((*MockHostHelpersInterface)(nil).DiscoverSriovDevices), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DiscoverSriovDevices", reflect.TypeOf((*MockHostHelpersInterface)(nil).DiscoverSriovDevices), storeManager) } // EnableRDMA mocks base method. -func (m *MockHostHelpersInterface) EnableRDMA(arg0, arg1, arg2 string) (bool, error) { +func (m *MockHostHelpersInterface) EnableRDMA(conditionFilePath, serviceName, packageManager string) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "EnableRDMA", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "EnableRDMA", conditionFilePath, serviceName, packageManager) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // EnableRDMA indicates an expected call of EnableRDMA. -func (mr *MockHostHelpersInterfaceMockRecorder) EnableRDMA(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) EnableRDMA(conditionFilePath, serviceName, packageManager interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnableRDMA", reflect.TypeOf((*MockHostHelpersInterface)(nil).EnableRDMA), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnableRDMA", reflect.TypeOf((*MockHostHelpersInterface)(nil).EnableRDMA), conditionFilePath, serviceName, packageManager) } // EnableRDMAOnRHELMachine mocks base method. @@ -272,17 +272,17 @@ func (mr *MockHostHelpersInterfaceMockRecorder) GetCurrentKernelArgs() *gomock.C } // GetLinkType mocks base method. -func (m *MockHostHelpersInterface) GetLinkType(arg0 v1.InterfaceExt) string { +func (m *MockHostHelpersInterface) GetLinkType(ifaceStatus v1.InterfaceExt) string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetLinkType", arg0) + ret := m.ctrl.Call(m, "GetLinkType", ifaceStatus) ret0, _ := ret[0].(string) return ret0 } // GetLinkType indicates an expected call of GetLinkType. -func (mr *MockHostHelpersInterfaceMockRecorder) GetLinkType(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) GetLinkType(ifaceStatus interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLinkType", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetLinkType), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLinkType", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetLinkType), ifaceStatus) } // GetMellanoxBlueFieldMode mocks base method. @@ -317,60 +317,60 @@ func (mr *MockHostHelpersInterfaceMockRecorder) GetMlxNicFwData(pciAddress inter } // GetNetDevLinkSpeed mocks base method. -func (m *MockHostHelpersInterface) GetNetDevLinkSpeed(arg0 string) string { +func (m *MockHostHelpersInterface) GetNetDevLinkSpeed(name string) string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNetDevLinkSpeed", arg0) + ret := m.ctrl.Call(m, "GetNetDevLinkSpeed", name) ret0, _ := ret[0].(string) return ret0 } // GetNetDevLinkSpeed indicates an expected call of GetNetDevLinkSpeed. -func (mr *MockHostHelpersInterfaceMockRecorder) GetNetDevLinkSpeed(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) GetNetDevLinkSpeed(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetDevLinkSpeed", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetNetDevLinkSpeed), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetDevLinkSpeed", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetNetDevLinkSpeed), name) } // GetNetDevMac mocks base method. -func (m *MockHostHelpersInterface) GetNetDevMac(arg0 string) string { +func (m *MockHostHelpersInterface) GetNetDevMac(name string) string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNetDevMac", arg0) + ret := m.ctrl.Call(m, "GetNetDevMac", name) ret0, _ := ret[0].(string) return ret0 } // GetNetDevMac indicates an expected call of GetNetDevMac. -func (mr *MockHostHelpersInterfaceMockRecorder) GetNetDevMac(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) GetNetDevMac(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetDevMac", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetNetDevMac), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetDevMac", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetNetDevMac), name) } // GetNetdevMTU mocks base method. -func (m *MockHostHelpersInterface) GetNetdevMTU(arg0 string) int { +func (m *MockHostHelpersInterface) GetNetdevMTU(pciAddr string) int { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNetdevMTU", arg0) + ret := m.ctrl.Call(m, "GetNetdevMTU", pciAddr) ret0, _ := ret[0].(int) return ret0 } // GetNetdevMTU indicates an expected call of GetNetdevMTU. -func (mr *MockHostHelpersInterfaceMockRecorder) GetNetdevMTU(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) GetNetdevMTU(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetdevMTU", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetNetdevMTU), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetdevMTU", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetNetdevMTU), pciAddr) } // GetNicSriovMode mocks base method. -func (m *MockHostHelpersInterface) GetNicSriovMode(arg0 string) (string, error) { +func (m *MockHostHelpersInterface) GetNicSriovMode(pciAddr string) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetNicSriovMode", arg0) + ret := m.ctrl.Call(m, "GetNicSriovMode", pciAddr) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } // GetNicSriovMode indicates an expected call of GetNicSriovMode. -func (mr *MockHostHelpersInterfaceMockRecorder) GetNicSriovMode(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) GetNicSriovMode(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNicSriovMode", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetNicSriovMode), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNicSriovMode", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetNicSriovMode), pciAddr) } // GetOSPrettyName mocks base method. @@ -389,76 +389,76 @@ func (mr *MockHostHelpersInterfaceMockRecorder) GetOSPrettyName() *gomock.Call { } // GetPhysPortName mocks base method. -func (m *MockHostHelpersInterface) GetPhysPortName(arg0 string) (string, error) { +func (m *MockHostHelpersInterface) GetPhysPortName(name string) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetPhysPortName", arg0) + ret := m.ctrl.Call(m, "GetPhysPortName", name) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } // GetPhysPortName indicates an expected call of GetPhysPortName. -func (mr *MockHostHelpersInterfaceMockRecorder) GetPhysPortName(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) GetPhysPortName(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPhysPortName", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetPhysPortName), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPhysPortName", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetPhysPortName), name) } // GetPhysSwitchID mocks base method. -func (m *MockHostHelpersInterface) GetPhysSwitchID(arg0 string) (string, error) { +func (m *MockHostHelpersInterface) GetPhysSwitchID(name string) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetPhysSwitchID", arg0) + ret := m.ctrl.Call(m, "GetPhysSwitchID", name) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } // GetPhysSwitchID indicates an expected call of GetPhysSwitchID. -func (mr *MockHostHelpersInterfaceMockRecorder) GetPhysSwitchID(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) GetPhysSwitchID(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPhysSwitchID", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetPhysSwitchID), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPhysSwitchID", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetPhysSwitchID), name) } // GetVfInfo mocks base method. -func (m *MockHostHelpersInterface) GetVfInfo(arg0 string, arg1 []*ghw.PCIDevice) v1.VirtualFunction { +func (m *MockHostHelpersInterface) GetVfInfo(pciAddr string, devices []*ghw.PCIDevice) v1.VirtualFunction { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVfInfo", arg0, arg1) + ret := m.ctrl.Call(m, "GetVfInfo", pciAddr, devices) ret0, _ := ret[0].(v1.VirtualFunction) return ret0 } // GetVfInfo indicates an expected call of GetVfInfo. -func (mr *MockHostHelpersInterfaceMockRecorder) GetVfInfo(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) GetVfInfo(pciAddr, devices interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVfInfo", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetVfInfo), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVfInfo", reflect.TypeOf((*MockHostHelpersInterface)(nil).GetVfInfo), pciAddr, devices) } // HasDriver mocks base method. -func (m *MockHostHelpersInterface) HasDriver(arg0 string) (bool, string) { +func (m *MockHostHelpersInterface) HasDriver(pciAddr string) (bool, string) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasDriver", arg0) + ret := m.ctrl.Call(m, "HasDriver", pciAddr) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(string) return ret0, ret1 } // HasDriver indicates an expected call of HasDriver. -func (mr *MockHostHelpersInterfaceMockRecorder) HasDriver(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) HasDriver(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).HasDriver), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).HasDriver), pciAddr) } // InstallRDMA mocks base method. -func (m *MockHostHelpersInterface) InstallRDMA(arg0 string) error { +func (m *MockHostHelpersInterface) InstallRDMA(packageManager string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "InstallRDMA", arg0) + ret := m.ctrl.Call(m, "InstallRDMA", packageManager) ret0, _ := ret[0].(error) return ret0 } // InstallRDMA indicates an expected call of InstallRDMA. -func (mr *MockHostHelpersInterfaceMockRecorder) InstallRDMA(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) InstallRDMA(packageManager interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstallRDMA", reflect.TypeOf((*MockHostHelpersInterface)(nil).InstallRDMA), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstallRDMA", reflect.TypeOf((*MockHostHelpersInterface)(nil).InstallRDMA), packageManager) } // IsCoreOS mocks base method. @@ -477,17 +477,17 @@ func (mr *MockHostHelpersInterfaceMockRecorder) IsCoreOS() *gomock.Call { } // IsKernelArgsSet mocks base method. -func (m *MockHostHelpersInterface) IsKernelArgsSet(arg0, arg1 string) bool { +func (m *MockHostHelpersInterface) IsKernelArgsSet(cmdLine, karg string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsKernelArgsSet", arg0, arg1) + ret := m.ctrl.Call(m, "IsKernelArgsSet", cmdLine, karg) ret0, _ := ret[0].(bool) return ret0 } // IsKernelArgsSet indicates an expected call of IsKernelArgsSet. -func (mr *MockHostHelpersInterfaceMockRecorder) IsKernelArgsSet(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) IsKernelArgsSet(cmdLine, karg interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsKernelArgsSet", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsKernelArgsSet), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsKernelArgsSet", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsKernelArgsSet), cmdLine, karg) } // IsKernelLockdownMode mocks base method. @@ -505,18 +505,18 @@ func (mr *MockHostHelpersInterfaceMockRecorder) IsKernelLockdownMode() *gomock.C } // IsKernelModuleLoaded mocks base method. -func (m *MockHostHelpersInterface) IsKernelModuleLoaded(arg0 string) (bool, error) { +func (m *MockHostHelpersInterface) IsKernelModuleLoaded(name string) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsKernelModuleLoaded", arg0) + ret := m.ctrl.Call(m, "IsKernelModuleLoaded", name) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // IsKernelModuleLoaded indicates an expected call of IsKernelModuleLoaded. -func (mr *MockHostHelpersInterfaceMockRecorder) IsKernelModuleLoaded(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) IsKernelModuleLoaded(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsKernelModuleLoaded", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsKernelModuleLoaded), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsKernelModuleLoaded", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsKernelModuleLoaded), name) } // IsRHELSystem mocks base method. @@ -535,47 +535,47 @@ func (mr *MockHostHelpersInterfaceMockRecorder) IsRHELSystem() *gomock.Call { } // IsServiceEnabled mocks base method. -func (m *MockHostHelpersInterface) IsServiceEnabled(arg0 string) (bool, error) { +func (m *MockHostHelpersInterface) IsServiceEnabled(servicePath string) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsServiceEnabled", arg0) + ret := m.ctrl.Call(m, "IsServiceEnabled", servicePath) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // IsServiceEnabled indicates an expected call of IsServiceEnabled. -func (mr *MockHostHelpersInterfaceMockRecorder) IsServiceEnabled(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) IsServiceEnabled(servicePath interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsServiceEnabled", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsServiceEnabled), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsServiceEnabled", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsServiceEnabled), servicePath) } // IsServiceExist mocks base method. -func (m *MockHostHelpersInterface) IsServiceExist(arg0 string) (bool, error) { +func (m *MockHostHelpersInterface) IsServiceExist(servicePath string) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsServiceExist", arg0) + ret := m.ctrl.Call(m, "IsServiceExist", servicePath) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // IsServiceExist indicates an expected call of IsServiceExist. -func (mr *MockHostHelpersInterfaceMockRecorder) IsServiceExist(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) IsServiceExist(servicePath interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsServiceExist", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsServiceExist), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsServiceExist", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsServiceExist), servicePath) } // IsSwitchdev mocks base method. -func (m *MockHostHelpersInterface) IsSwitchdev(arg0 string) bool { +func (m *MockHostHelpersInterface) IsSwitchdev(name string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsSwitchdev", arg0) + ret := m.ctrl.Call(m, "IsSwitchdev", name) ret0, _ := ret[0].(bool) return ret0 } // IsSwitchdev indicates an expected call of IsSwitchdev. -func (mr *MockHostHelpersInterfaceMockRecorder) IsSwitchdev(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) IsSwitchdev(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSwitchdev", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsSwitchdev), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSwitchdev", reflect.TypeOf((*MockHostHelpersInterface)(nil).IsSwitchdev), name) } // IsUbuntuSystem mocks base method. @@ -659,17 +659,17 @@ func (mr *MockHostHelpersInterfaceMockRecorder) MstConfigReadData(arg0 interface } // PrepareNMUdevRule mocks base method. -func (m *MockHostHelpersInterface) PrepareNMUdevRule(arg0 []string) error { +func (m *MockHostHelpersInterface) PrepareNMUdevRule(supportedVfIds []string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "PrepareNMUdevRule", arg0) + ret := m.ctrl.Call(m, "PrepareNMUdevRule", supportedVfIds) ret0, _ := ret[0].(error) return ret0 } // PrepareNMUdevRule indicates an expected call of PrepareNMUdevRule. -func (mr *MockHostHelpersInterfaceMockRecorder) PrepareNMUdevRule(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) PrepareNMUdevRule(supportedVfIds interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareNMUdevRule", reflect.TypeOf((*MockHostHelpersInterface)(nil).PrepareNMUdevRule), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareNMUdevRule", reflect.TypeOf((*MockHostHelpersInterface)(nil).PrepareNMUdevRule), supportedVfIds) } // RdmaIsLoaded mocks base method. @@ -703,18 +703,18 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ReadScriptManifestFile(path inte } // ReadService mocks base method. -func (m *MockHostHelpersInterface) ReadService(arg0 string) (*types.Service, error) { +func (m *MockHostHelpersInterface) ReadService(servicePath string) (*types.Service, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ReadService", arg0) + ret := m.ctrl.Call(m, "ReadService", servicePath) ret0, _ := ret[0].(*types.Service) ret1, _ := ret[1].(error) return ret0, ret1 } // ReadService indicates an expected call of ReadService. -func (mr *MockHostHelpersInterfaceMockRecorder) ReadService(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) ReadService(servicePath interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadService", reflect.TypeOf((*MockHostHelpersInterface)(nil).ReadService), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadService", reflect.TypeOf((*MockHostHelpersInterface)(nil).ReadService), servicePath) } // ReadServiceInjectionManifestFile mocks base method. @@ -748,31 +748,31 @@ func (mr *MockHostHelpersInterfaceMockRecorder) ReadServiceManifestFile(path int } // RebindVfToDefaultDriver mocks base method. -func (m *MockHostHelpersInterface) RebindVfToDefaultDriver(arg0 string) error { +func (m *MockHostHelpersInterface) RebindVfToDefaultDriver(pciAddr string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RebindVfToDefaultDriver", arg0) + ret := m.ctrl.Call(m, "RebindVfToDefaultDriver", pciAddr) ret0, _ := ret[0].(error) return ret0 } // RebindVfToDefaultDriver indicates an expected call of RebindVfToDefaultDriver. -func (mr *MockHostHelpersInterfaceMockRecorder) RebindVfToDefaultDriver(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) RebindVfToDefaultDriver(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RebindVfToDefaultDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).RebindVfToDefaultDriver), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RebindVfToDefaultDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).RebindVfToDefaultDriver), pciAddr) } // ReloadDriver mocks base method. -func (m *MockHostHelpersInterface) ReloadDriver(arg0 string) error { +func (m *MockHostHelpersInterface) ReloadDriver(driver string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ReloadDriver", arg0) + ret := m.ctrl.Call(m, "ReloadDriver", driver) ret0, _ := ret[0].(error) return ret0 } // ReloadDriver indicates an expected call of ReloadDriver. -func (mr *MockHostHelpersInterfaceMockRecorder) ReloadDriver(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) ReloadDriver(driver interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReloadDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).ReloadDriver), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReloadDriver", reflect.TypeOf((*MockHostHelpersInterface)(nil).ReloadDriver), driver) } // RemoveFromService mocks base method. @@ -796,31 +796,31 @@ func (mr *MockHostHelpersInterfaceMockRecorder) RemoveFromService(service interf } // RemoveUdevRule mocks base method. -func (m *MockHostHelpersInterface) RemoveUdevRule(arg0 string) error { +func (m *MockHostHelpersInterface) RemoveUdevRule(pfPciAddress string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveUdevRule", arg0) + ret := m.ctrl.Call(m, "RemoveUdevRule", pfPciAddress) ret0, _ := ret[0].(error) return ret0 } // RemoveUdevRule indicates an expected call of RemoveUdevRule. -func (mr *MockHostHelpersInterfaceMockRecorder) RemoveUdevRule(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) RemoveUdevRule(pfPciAddress interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveUdevRule", reflect.TypeOf((*MockHostHelpersInterface)(nil).RemoveUdevRule), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveUdevRule", reflect.TypeOf((*MockHostHelpersInterface)(nil).RemoveUdevRule), pfPciAddress) } // ResetSriovDevice mocks base method. -func (m *MockHostHelpersInterface) ResetSriovDevice(arg0 v1.InterfaceExt) error { +func (m *MockHostHelpersInterface) ResetSriovDevice(ifaceStatus v1.InterfaceExt) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ResetSriovDevice", arg0) + ret := m.ctrl.Call(m, "ResetSriovDevice", ifaceStatus) ret0, _ := ret[0].(error) return ret0 } // ResetSriovDevice indicates an expected call of ResetSriovDevice. -func (mr *MockHostHelpersInterfaceMockRecorder) ResetSriovDevice(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) ResetSriovDevice(ifaceStatus interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResetSriovDevice", reflect.TypeOf((*MockHostHelpersInterface)(nil).ResetSriovDevice), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResetSriovDevice", reflect.TypeOf((*MockHostHelpersInterface)(nil).ResetSriovDevice), ifaceStatus) } // RunCommand mocks base method. @@ -859,59 +859,59 @@ func (mr *MockHostHelpersInterfaceMockRecorder) SaveLastPfAppliedStatus(PfInfo i } // SetNetdevMTU mocks base method. -func (m *MockHostHelpersInterface) SetNetdevMTU(arg0 string, arg1 int) error { +func (m *MockHostHelpersInterface) SetNetdevMTU(pciAddr string, mtu int) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetNetdevMTU", arg0, arg1) + ret := m.ctrl.Call(m, "SetNetdevMTU", pciAddr, mtu) ret0, _ := ret[0].(error) return ret0 } // SetNetdevMTU indicates an expected call of SetNetdevMTU. -func (mr *MockHostHelpersInterfaceMockRecorder) SetNetdevMTU(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) SetNetdevMTU(pciAddr, mtu interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNetdevMTU", reflect.TypeOf((*MockHostHelpersInterface)(nil).SetNetdevMTU), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNetdevMTU", reflect.TypeOf((*MockHostHelpersInterface)(nil).SetNetdevMTU), pciAddr, mtu) } // SetSriovNumVfs mocks base method. -func (m *MockHostHelpersInterface) SetSriovNumVfs(arg0 string, arg1 int) error { +func (m *MockHostHelpersInterface) SetSriovNumVfs(pciAddr string, numVfs int) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetSriovNumVfs", arg0, arg1) + ret := m.ctrl.Call(m, "SetSriovNumVfs", pciAddr, numVfs) ret0, _ := ret[0].(error) return ret0 } // SetSriovNumVfs indicates an expected call of SetSriovNumVfs. -func (mr *MockHostHelpersInterfaceMockRecorder) SetSriovNumVfs(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) SetSriovNumVfs(pciAddr, numVfs interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSriovNumVfs", reflect.TypeOf((*MockHostHelpersInterface)(nil).SetSriovNumVfs), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSriovNumVfs", reflect.TypeOf((*MockHostHelpersInterface)(nil).SetSriovNumVfs), pciAddr, numVfs) } // SetVfAdminMac mocks base method. -func (m *MockHostHelpersInterface) SetVfAdminMac(arg0 string, arg1, arg2 netlink.Link) error { +func (m *MockHostHelpersInterface) SetVfAdminMac(vfAddr string, pfLink, vfLink netlink.Link) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetVfAdminMac", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "SetVfAdminMac", vfAddr, pfLink, vfLink) ret0, _ := ret[0].(error) return ret0 } // SetVfAdminMac indicates an expected call of SetVfAdminMac. -func (mr *MockHostHelpersInterfaceMockRecorder) SetVfAdminMac(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) SetVfAdminMac(vfAddr, pfLink, vfLink interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVfAdminMac", reflect.TypeOf((*MockHostHelpersInterface)(nil).SetVfAdminMac), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVfAdminMac", reflect.TypeOf((*MockHostHelpersInterface)(nil).SetVfAdminMac), vfAddr, pfLink, vfLink) } // SetVfGUID mocks base method. -func (m *MockHostHelpersInterface) SetVfGUID(arg0 string, arg1 netlink.Link) error { +func (m *MockHostHelpersInterface) SetVfGUID(vfAddr string, pfLink netlink.Link) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetVfGUID", arg0, arg1) + ret := m.ctrl.Call(m, "SetVfGUID", vfAddr, pfLink) ret0, _ := ret[0].(error) return ret0 } // SetVfGUID indicates an expected call of SetVfGUID. -func (mr *MockHostHelpersInterfaceMockRecorder) SetVfGUID(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) SetVfGUID(vfAddr, pfLink interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVfGUID", reflect.TypeOf((*MockHostHelpersInterface)(nil).SetVfGUID), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVfGUID", reflect.TypeOf((*MockHostHelpersInterface)(nil).SetVfGUID), vfAddr, pfLink) } // TriggerUdevEvent mocks base method. @@ -968,45 +968,45 @@ func (mr *MockHostHelpersInterfaceMockRecorder) TryEnableVhostNet() *gomock.Call } // TryGetInterfaceName mocks base method. -func (m *MockHostHelpersInterface) TryGetInterfaceName(arg0 string) string { +func (m *MockHostHelpersInterface) TryGetInterfaceName(pciAddr string) string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TryGetInterfaceName", arg0) + ret := m.ctrl.Call(m, "TryGetInterfaceName", pciAddr) ret0, _ := ret[0].(string) return ret0 } // TryGetInterfaceName indicates an expected call of TryGetInterfaceName. -func (mr *MockHostHelpersInterfaceMockRecorder) TryGetInterfaceName(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) TryGetInterfaceName(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryGetInterfaceName", reflect.TypeOf((*MockHostHelpersInterface)(nil).TryGetInterfaceName), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryGetInterfaceName", reflect.TypeOf((*MockHostHelpersInterface)(nil).TryGetInterfaceName), pciAddr) } // TryToGetVirtualInterfaceName mocks base method. -func (m *MockHostHelpersInterface) TryToGetVirtualInterfaceName(arg0 string) string { +func (m *MockHostHelpersInterface) TryToGetVirtualInterfaceName(pciAddr string) string { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TryToGetVirtualInterfaceName", arg0) + ret := m.ctrl.Call(m, "TryToGetVirtualInterfaceName", pciAddr) ret0, _ := ret[0].(string) return ret0 } // TryToGetVirtualInterfaceName indicates an expected call of TryToGetVirtualInterfaceName. -func (mr *MockHostHelpersInterfaceMockRecorder) TryToGetVirtualInterfaceName(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) TryToGetVirtualInterfaceName(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryToGetVirtualInterfaceName", reflect.TypeOf((*MockHostHelpersInterface)(nil).TryToGetVirtualInterfaceName), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryToGetVirtualInterfaceName", reflect.TypeOf((*MockHostHelpersInterface)(nil).TryToGetVirtualInterfaceName), pciAddr) } // Unbind mocks base method. -func (m *MockHostHelpersInterface) Unbind(arg0 string) error { +func (m *MockHostHelpersInterface) Unbind(pciAddr string) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Unbind", arg0) + ret := m.ctrl.Call(m, "Unbind", pciAddr) ret0, _ := ret[0].(error) return ret0 } // Unbind indicates an expected call of Unbind. -func (mr *MockHostHelpersInterfaceMockRecorder) Unbind(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) Unbind(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unbind", reflect.TypeOf((*MockHostHelpersInterface)(nil).Unbind), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unbind", reflect.TypeOf((*MockHostHelpersInterface)(nil).Unbind), pciAddr) } // UnbindDriverByBusAndDevice mocks base method. @@ -1024,17 +1024,17 @@ func (mr *MockHostHelpersInterfaceMockRecorder) UnbindDriverByBusAndDevice(bus, } // UnbindDriverIfNeeded mocks base method. -func (m *MockHostHelpersInterface) UnbindDriverIfNeeded(arg0 string, arg1 bool) error { +func (m *MockHostHelpersInterface) UnbindDriverIfNeeded(pciAddr string, isRdma bool) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UnbindDriverIfNeeded", arg0, arg1) + ret := m.ctrl.Call(m, "UnbindDriverIfNeeded", pciAddr, isRdma) ret0, _ := ret[0].(error) return ret0 } // UnbindDriverIfNeeded indicates an expected call of UnbindDriverIfNeeded. -func (mr *MockHostHelpersInterfaceMockRecorder) UnbindDriverIfNeeded(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) UnbindDriverIfNeeded(pciAddr, isRdma interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnbindDriverIfNeeded", reflect.TypeOf((*MockHostHelpersInterface)(nil).UnbindDriverIfNeeded), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnbindDriverIfNeeded", reflect.TypeOf((*MockHostHelpersInterface)(nil).UnbindDriverIfNeeded), pciAddr, isRdma) } // UpdateSystemService mocks base method. @@ -1052,18 +1052,18 @@ func (mr *MockHostHelpersInterfaceMockRecorder) UpdateSystemService(serviceObj i } // VFIsReady mocks base method. -func (m *MockHostHelpersInterface) VFIsReady(arg0 string) (netlink.Link, error) { +func (m *MockHostHelpersInterface) VFIsReady(pciAddr string) (netlink.Link, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VFIsReady", arg0) + ret := m.ctrl.Call(m, "VFIsReady", pciAddr) ret0, _ := ret[0].(netlink.Link) ret1, _ := ret[1].(error) return ret0, ret1 } // VFIsReady indicates an expected call of VFIsReady. -func (mr *MockHostHelpersInterfaceMockRecorder) VFIsReady(arg0 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) VFIsReady(pciAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VFIsReady", reflect.TypeOf((*MockHostHelpersInterface)(nil).VFIsReady), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VFIsReady", reflect.TypeOf((*MockHostHelpersInterface)(nil).VFIsReady), pciAddr) } // WriteCheckpointFile mocks base method. @@ -1081,16 +1081,16 @@ func (mr *MockHostHelpersInterfaceMockRecorder) WriteCheckpointFile(arg0 interfa } // WriteSwitchdevConfFile mocks base method. -func (m *MockHostHelpersInterface) WriteSwitchdevConfFile(arg0 *v1.SriovNetworkNodeState, arg1 map[string]bool) (bool, error) { +func (m *MockHostHelpersInterface) WriteSwitchdevConfFile(newState *v1.SriovNetworkNodeState, pfsToSkip map[string]bool) (bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "WriteSwitchdevConfFile", arg0, arg1) + ret := m.ctrl.Call(m, "WriteSwitchdevConfFile", newState, pfsToSkip) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 } // WriteSwitchdevConfFile indicates an expected call of WriteSwitchdevConfFile. -func (mr *MockHostHelpersInterfaceMockRecorder) WriteSwitchdevConfFile(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockHostHelpersInterfaceMockRecorder) WriteSwitchdevConfFile(newState, pfsToSkip interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteSwitchdevConfFile", reflect.TypeOf((*MockHostHelpersInterface)(nil).WriteSwitchdevConfFile), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteSwitchdevConfFile", reflect.TypeOf((*MockHostHelpersInterface)(nil).WriteSwitchdevConfFile), newState, pfsToSkip) } diff --git a/pkg/host/manager.go b/pkg/host/manager.go index 3b0f790e9..3983fa9b6 100644 --- a/pkg/host/manager.go +++ b/pkg/host/manager.go @@ -11,6 +11,8 @@ import ( ) // Contains all the host manipulation functions +// +//go:generate ../../bin/mockgen -destination mock/mock_host.go -source manager.go type HostManagerInterface interface { types.KernelInterface types.NetworkInterface diff --git a/pkg/host/mock/mock_host.go b/pkg/host/mock/mock_host.go new file mode 100644 index 000000000..7c52fd28b --- /dev/null +++ b/pkg/host/mock/mock_host.go @@ -0,0 +1,925 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: manager.go + +// Package mock_host is a generated GoMock package. +package mock_host + +import ( + reflect "reflect" + + unit "github.com/coreos/go-systemd/v22/unit" + gomock "github.com/golang/mock/gomock" + ghw "github.com/jaypipes/ghw" + v1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" + store "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/store" + types "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" + netlink "github.com/vishvananda/netlink" +) + +// MockHostManagerInterface is a mock of HostManagerInterface interface. +type MockHostManagerInterface struct { + ctrl *gomock.Controller + recorder *MockHostManagerInterfaceMockRecorder +} + +// MockHostManagerInterfaceMockRecorder is the mock recorder for MockHostManagerInterface. +type MockHostManagerInterfaceMockRecorder struct { + mock *MockHostManagerInterface +} + +// NewMockHostManagerInterface creates a new mock instance. +func NewMockHostManagerInterface(ctrl *gomock.Controller) *MockHostManagerInterface { + mock := &MockHostManagerInterface{ctrl: ctrl} + mock.recorder = &MockHostManagerInterfaceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockHostManagerInterface) EXPECT() *MockHostManagerInterfaceMockRecorder { + return m.recorder +} + +// AddUdevRule mocks base method. +func (m *MockHostManagerInterface) AddUdevRule(pfPciAddress string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddUdevRule", pfPciAddress) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddUdevRule indicates an expected call of AddUdevRule. +func (mr *MockHostManagerInterfaceMockRecorder) AddUdevRule(pfPciAddress interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddUdevRule", reflect.TypeOf((*MockHostManagerInterface)(nil).AddUdevRule), pfPciAddress) +} + +// BindDefaultDriver mocks base method. +func (m *MockHostManagerInterface) BindDefaultDriver(pciAddr string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BindDefaultDriver", pciAddr) + ret0, _ := ret[0].(error) + return ret0 +} + +// BindDefaultDriver indicates an expected call of BindDefaultDriver. +func (mr *MockHostManagerInterfaceMockRecorder) BindDefaultDriver(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDefaultDriver", reflect.TypeOf((*MockHostManagerInterface)(nil).BindDefaultDriver), pciAddr) +} + +// BindDpdkDriver mocks base method. +func (m *MockHostManagerInterface) BindDpdkDriver(pciAddr, driver string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BindDpdkDriver", pciAddr, driver) + ret0, _ := ret[0].(error) + return ret0 +} + +// BindDpdkDriver indicates an expected call of BindDpdkDriver. +func (mr *MockHostManagerInterfaceMockRecorder) BindDpdkDriver(pciAddr, driver interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDpdkDriver", reflect.TypeOf((*MockHostManagerInterface)(nil).BindDpdkDriver), pciAddr, driver) +} + +// BindDriverByBusAndDevice mocks base method. +func (m *MockHostManagerInterface) BindDriverByBusAndDevice(bus, device, driver string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BindDriverByBusAndDevice", bus, device, driver) + ret0, _ := ret[0].(error) + return ret0 +} + +// BindDriverByBusAndDevice indicates an expected call of BindDriverByBusAndDevice. +func (mr *MockHostManagerInterfaceMockRecorder) BindDriverByBusAndDevice(bus, device, driver interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindDriverByBusAndDevice", reflect.TypeOf((*MockHostManagerInterface)(nil).BindDriverByBusAndDevice), bus, device, driver) +} + +// CompareServices mocks base method. +func (m *MockHostManagerInterface) CompareServices(serviceA, serviceB *types.Service) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CompareServices", serviceA, serviceB) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CompareServices indicates an expected call of CompareServices. +func (mr *MockHostManagerInterfaceMockRecorder) CompareServices(serviceA, serviceB interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompareServices", reflect.TypeOf((*MockHostManagerInterface)(nil).CompareServices), serviceA, serviceB) +} + +// ConfigSriovDevice mocks base method. +func (m *MockHostManagerInterface) ConfigSriovDevice(iface *v1.Interface, ifaceStatus *v1.InterfaceExt) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConfigSriovDevice", iface, ifaceStatus) + ret0, _ := ret[0].(error) + return ret0 +} + +// ConfigSriovDevice indicates an expected call of ConfigSriovDevice. +func (mr *MockHostManagerInterfaceMockRecorder) ConfigSriovDevice(iface, ifaceStatus interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConfigSriovDevice", reflect.TypeOf((*MockHostManagerInterface)(nil).ConfigSriovDevice), iface, ifaceStatus) +} + +// ConfigSriovDeviceVirtual mocks base method. +func (m *MockHostManagerInterface) ConfigSriovDeviceVirtual(iface *v1.Interface) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConfigSriovDeviceVirtual", iface) + ret0, _ := ret[0].(error) + return ret0 +} + +// ConfigSriovDeviceVirtual indicates an expected call of ConfigSriovDeviceVirtual. +func (mr *MockHostManagerInterfaceMockRecorder) ConfigSriovDeviceVirtual(iface interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConfigSriovDeviceVirtual", reflect.TypeOf((*MockHostManagerInterface)(nil).ConfigSriovDeviceVirtual), iface) +} + +// ConfigSriovInterfaces mocks base method. +func (m *MockHostManagerInterface) ConfigSriovInterfaces(storeManager store.ManagerInterface, interfaces []v1.Interface, ifaceStatuses []v1.InterfaceExt, pfsToConfig map[string]bool) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ConfigSriovInterfaces", storeManager, interfaces, ifaceStatuses, pfsToConfig) + ret0, _ := ret[0].(error) + return ret0 +} + +// ConfigSriovInterfaces indicates an expected call of ConfigSriovInterfaces. +func (mr *MockHostManagerInterfaceMockRecorder) ConfigSriovInterfaces(storeManager, interfaces, ifaceStatuses, pfsToConfig interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConfigSriovInterfaces", reflect.TypeOf((*MockHostManagerInterface)(nil).ConfigSriovInterfaces), storeManager, interfaces, ifaceStatuses, pfsToConfig) +} + +// DiscoverSriovDevices mocks base method. +func (m *MockHostManagerInterface) DiscoverSriovDevices(storeManager store.ManagerInterface) ([]v1.InterfaceExt, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DiscoverSriovDevices", storeManager) + ret0, _ := ret[0].([]v1.InterfaceExt) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DiscoverSriovDevices indicates an expected call of DiscoverSriovDevices. +func (mr *MockHostManagerInterfaceMockRecorder) DiscoverSriovDevices(storeManager interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DiscoverSriovDevices", reflect.TypeOf((*MockHostManagerInterface)(nil).DiscoverSriovDevices), storeManager) +} + +// EnableRDMA mocks base method. +func (m *MockHostManagerInterface) EnableRDMA(conditionFilePath, serviceName, packageManager string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EnableRDMA", conditionFilePath, serviceName, packageManager) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// EnableRDMA indicates an expected call of EnableRDMA. +func (mr *MockHostManagerInterfaceMockRecorder) EnableRDMA(conditionFilePath, serviceName, packageManager interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnableRDMA", reflect.TypeOf((*MockHostManagerInterface)(nil).EnableRDMA), conditionFilePath, serviceName, packageManager) +} + +// EnableRDMAOnRHELMachine mocks base method. +func (m *MockHostManagerInterface) EnableRDMAOnRHELMachine() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EnableRDMAOnRHELMachine") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// EnableRDMAOnRHELMachine indicates an expected call of EnableRDMAOnRHELMachine. +func (mr *MockHostManagerInterfaceMockRecorder) EnableRDMAOnRHELMachine() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnableRDMAOnRHELMachine", reflect.TypeOf((*MockHostManagerInterface)(nil).EnableRDMAOnRHELMachine)) +} + +// EnableService mocks base method. +func (m *MockHostManagerInterface) EnableService(service *types.Service) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EnableService", service) + ret0, _ := ret[0].(error) + return ret0 +} + +// EnableService indicates an expected call of EnableService. +func (mr *MockHostManagerInterfaceMockRecorder) EnableService(service interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnableService", reflect.TypeOf((*MockHostManagerInterface)(nil).EnableService), service) +} + +// GetCurrentKernelArgs mocks base method. +func (m *MockHostManagerInterface) GetCurrentKernelArgs() (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCurrentKernelArgs") + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCurrentKernelArgs indicates an expected call of GetCurrentKernelArgs. +func (mr *MockHostManagerInterfaceMockRecorder) GetCurrentKernelArgs() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentKernelArgs", reflect.TypeOf((*MockHostManagerInterface)(nil).GetCurrentKernelArgs)) +} + +// GetLinkType mocks base method. +func (m *MockHostManagerInterface) GetLinkType(ifaceStatus v1.InterfaceExt) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLinkType", ifaceStatus) + ret0, _ := ret[0].(string) + return ret0 +} + +// GetLinkType indicates an expected call of GetLinkType. +func (mr *MockHostManagerInterfaceMockRecorder) GetLinkType(ifaceStatus interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLinkType", reflect.TypeOf((*MockHostManagerInterface)(nil).GetLinkType), ifaceStatus) +} + +// GetNetDevLinkSpeed mocks base method. +func (m *MockHostManagerInterface) GetNetDevLinkSpeed(name string) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetNetDevLinkSpeed", name) + ret0, _ := ret[0].(string) + return ret0 +} + +// GetNetDevLinkSpeed indicates an expected call of GetNetDevLinkSpeed. +func (mr *MockHostManagerInterfaceMockRecorder) GetNetDevLinkSpeed(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetDevLinkSpeed", reflect.TypeOf((*MockHostManagerInterface)(nil).GetNetDevLinkSpeed), name) +} + +// GetNetDevMac mocks base method. +func (m *MockHostManagerInterface) GetNetDevMac(name string) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetNetDevMac", name) + ret0, _ := ret[0].(string) + return ret0 +} + +// GetNetDevMac indicates an expected call of GetNetDevMac. +func (mr *MockHostManagerInterfaceMockRecorder) GetNetDevMac(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetDevMac", reflect.TypeOf((*MockHostManagerInterface)(nil).GetNetDevMac), name) +} + +// GetNetdevMTU mocks base method. +func (m *MockHostManagerInterface) GetNetdevMTU(pciAddr string) int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetNetdevMTU", pciAddr) + ret0, _ := ret[0].(int) + return ret0 +} + +// GetNetdevMTU indicates an expected call of GetNetdevMTU. +func (mr *MockHostManagerInterfaceMockRecorder) GetNetdevMTU(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNetdevMTU", reflect.TypeOf((*MockHostManagerInterface)(nil).GetNetdevMTU), pciAddr) +} + +// GetNicSriovMode mocks base method. +func (m *MockHostManagerInterface) GetNicSriovMode(pciAddr string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetNicSriovMode", pciAddr) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetNicSriovMode indicates an expected call of GetNicSriovMode. +func (mr *MockHostManagerInterfaceMockRecorder) GetNicSriovMode(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNicSriovMode", reflect.TypeOf((*MockHostManagerInterface)(nil).GetNicSriovMode), pciAddr) +} + +// GetOSPrettyName mocks base method. +func (m *MockHostManagerInterface) GetOSPrettyName() (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetOSPrettyName") + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetOSPrettyName indicates an expected call of GetOSPrettyName. +func (mr *MockHostManagerInterfaceMockRecorder) GetOSPrettyName() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOSPrettyName", reflect.TypeOf((*MockHostManagerInterface)(nil).GetOSPrettyName)) +} + +// GetPhysPortName mocks base method. +func (m *MockHostManagerInterface) GetPhysPortName(name string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPhysPortName", name) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPhysPortName indicates an expected call of GetPhysPortName. +func (mr *MockHostManagerInterfaceMockRecorder) GetPhysPortName(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPhysPortName", reflect.TypeOf((*MockHostManagerInterface)(nil).GetPhysPortName), name) +} + +// GetPhysSwitchID mocks base method. +func (m *MockHostManagerInterface) GetPhysSwitchID(name string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPhysSwitchID", name) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPhysSwitchID indicates an expected call of GetPhysSwitchID. +func (mr *MockHostManagerInterfaceMockRecorder) GetPhysSwitchID(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPhysSwitchID", reflect.TypeOf((*MockHostManagerInterface)(nil).GetPhysSwitchID), name) +} + +// GetVfInfo mocks base method. +func (m *MockHostManagerInterface) GetVfInfo(pciAddr string, devices []*ghw.PCIDevice) v1.VirtualFunction { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVfInfo", pciAddr, devices) + ret0, _ := ret[0].(v1.VirtualFunction) + return ret0 +} + +// GetVfInfo indicates an expected call of GetVfInfo. +func (mr *MockHostManagerInterfaceMockRecorder) GetVfInfo(pciAddr, devices interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVfInfo", reflect.TypeOf((*MockHostManagerInterface)(nil).GetVfInfo), pciAddr, devices) +} + +// HasDriver mocks base method. +func (m *MockHostManagerInterface) HasDriver(pciAddr string) (bool, string) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasDriver", pciAddr) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(string) + return ret0, ret1 +} + +// HasDriver indicates an expected call of HasDriver. +func (mr *MockHostManagerInterfaceMockRecorder) HasDriver(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasDriver", reflect.TypeOf((*MockHostManagerInterface)(nil).HasDriver), pciAddr) +} + +// InstallRDMA mocks base method. +func (m *MockHostManagerInterface) InstallRDMA(packageManager string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InstallRDMA", packageManager) + ret0, _ := ret[0].(error) + return ret0 +} + +// InstallRDMA indicates an expected call of InstallRDMA. +func (mr *MockHostManagerInterfaceMockRecorder) InstallRDMA(packageManager interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InstallRDMA", reflect.TypeOf((*MockHostManagerInterface)(nil).InstallRDMA), packageManager) +} + +// IsCoreOS mocks base method. +func (m *MockHostManagerInterface) IsCoreOS() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsCoreOS") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsCoreOS indicates an expected call of IsCoreOS. +func (mr *MockHostManagerInterfaceMockRecorder) IsCoreOS() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsCoreOS", reflect.TypeOf((*MockHostManagerInterface)(nil).IsCoreOS)) +} + +// IsKernelArgsSet mocks base method. +func (m *MockHostManagerInterface) IsKernelArgsSet(cmdLine, karg string) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsKernelArgsSet", cmdLine, karg) + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsKernelArgsSet indicates an expected call of IsKernelArgsSet. +func (mr *MockHostManagerInterfaceMockRecorder) IsKernelArgsSet(cmdLine, karg interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsKernelArgsSet", reflect.TypeOf((*MockHostManagerInterface)(nil).IsKernelArgsSet), cmdLine, karg) +} + +// IsKernelLockdownMode mocks base method. +func (m *MockHostManagerInterface) IsKernelLockdownMode() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsKernelLockdownMode") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsKernelLockdownMode indicates an expected call of IsKernelLockdownMode. +func (mr *MockHostManagerInterfaceMockRecorder) IsKernelLockdownMode() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsKernelLockdownMode", reflect.TypeOf((*MockHostManagerInterface)(nil).IsKernelLockdownMode)) +} + +// IsKernelModuleLoaded mocks base method. +func (m *MockHostManagerInterface) IsKernelModuleLoaded(name string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsKernelModuleLoaded", name) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsKernelModuleLoaded indicates an expected call of IsKernelModuleLoaded. +func (mr *MockHostManagerInterfaceMockRecorder) IsKernelModuleLoaded(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsKernelModuleLoaded", reflect.TypeOf((*MockHostManagerInterface)(nil).IsKernelModuleLoaded), name) +} + +// IsRHELSystem mocks base method. +func (m *MockHostManagerInterface) IsRHELSystem() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsRHELSystem") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsRHELSystem indicates an expected call of IsRHELSystem. +func (mr *MockHostManagerInterfaceMockRecorder) IsRHELSystem() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsRHELSystem", reflect.TypeOf((*MockHostManagerInterface)(nil).IsRHELSystem)) +} + +// IsServiceEnabled mocks base method. +func (m *MockHostManagerInterface) IsServiceEnabled(servicePath string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsServiceEnabled", servicePath) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsServiceEnabled indicates an expected call of IsServiceEnabled. +func (mr *MockHostManagerInterfaceMockRecorder) IsServiceEnabled(servicePath interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsServiceEnabled", reflect.TypeOf((*MockHostManagerInterface)(nil).IsServiceEnabled), servicePath) +} + +// IsServiceExist mocks base method. +func (m *MockHostManagerInterface) IsServiceExist(servicePath string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsServiceExist", servicePath) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsServiceExist indicates an expected call of IsServiceExist. +func (mr *MockHostManagerInterfaceMockRecorder) IsServiceExist(servicePath interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsServiceExist", reflect.TypeOf((*MockHostManagerInterface)(nil).IsServiceExist), servicePath) +} + +// IsSwitchdev mocks base method. +func (m *MockHostManagerInterface) IsSwitchdev(name string) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsSwitchdev", name) + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsSwitchdev indicates an expected call of IsSwitchdev. +func (mr *MockHostManagerInterfaceMockRecorder) IsSwitchdev(name interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSwitchdev", reflect.TypeOf((*MockHostManagerInterface)(nil).IsSwitchdev), name) +} + +// IsUbuntuSystem mocks base method. +func (m *MockHostManagerInterface) IsUbuntuSystem() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsUbuntuSystem") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsUbuntuSystem indicates an expected call of IsUbuntuSystem. +func (mr *MockHostManagerInterfaceMockRecorder) IsUbuntuSystem() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUbuntuSystem", reflect.TypeOf((*MockHostManagerInterface)(nil).IsUbuntuSystem)) +} + +// LoadKernelModule mocks base method. +func (m *MockHostManagerInterface) LoadKernelModule(name string, args ...string) error { + m.ctrl.T.Helper() + varargs := []interface{}{name} + for _, a := range args { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "LoadKernelModule", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// LoadKernelModule indicates an expected call of LoadKernelModule. +func (mr *MockHostManagerInterfaceMockRecorder) LoadKernelModule(name interface{}, args ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{name}, args...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadKernelModule", reflect.TypeOf((*MockHostManagerInterface)(nil).LoadKernelModule), varargs...) +} + +// PrepareNMUdevRule mocks base method. +func (m *MockHostManagerInterface) PrepareNMUdevRule(supportedVfIds []string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PrepareNMUdevRule", supportedVfIds) + ret0, _ := ret[0].(error) + return ret0 +} + +// PrepareNMUdevRule indicates an expected call of PrepareNMUdevRule. +func (mr *MockHostManagerInterfaceMockRecorder) PrepareNMUdevRule(supportedVfIds interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareNMUdevRule", reflect.TypeOf((*MockHostManagerInterface)(nil).PrepareNMUdevRule), supportedVfIds) +} + +// RdmaIsLoaded mocks base method. +func (m *MockHostManagerInterface) RdmaIsLoaded() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RdmaIsLoaded") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RdmaIsLoaded indicates an expected call of RdmaIsLoaded. +func (mr *MockHostManagerInterfaceMockRecorder) RdmaIsLoaded() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RdmaIsLoaded", reflect.TypeOf((*MockHostManagerInterface)(nil).RdmaIsLoaded)) +} + +// ReadScriptManifestFile mocks base method. +func (m *MockHostManagerInterface) ReadScriptManifestFile(path string) (*types.ScriptManifestFile, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadScriptManifestFile", path) + ret0, _ := ret[0].(*types.ScriptManifestFile) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReadScriptManifestFile indicates an expected call of ReadScriptManifestFile. +func (mr *MockHostManagerInterfaceMockRecorder) ReadScriptManifestFile(path interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadScriptManifestFile", reflect.TypeOf((*MockHostManagerInterface)(nil).ReadScriptManifestFile), path) +} + +// ReadService mocks base method. +func (m *MockHostManagerInterface) ReadService(servicePath string) (*types.Service, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadService", servicePath) + ret0, _ := ret[0].(*types.Service) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReadService indicates an expected call of ReadService. +func (mr *MockHostManagerInterfaceMockRecorder) ReadService(servicePath interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadService", reflect.TypeOf((*MockHostManagerInterface)(nil).ReadService), servicePath) +} + +// ReadServiceInjectionManifestFile mocks base method. +func (m *MockHostManagerInterface) ReadServiceInjectionManifestFile(path string) (*types.Service, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadServiceInjectionManifestFile", path) + ret0, _ := ret[0].(*types.Service) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReadServiceInjectionManifestFile indicates an expected call of ReadServiceInjectionManifestFile. +func (mr *MockHostManagerInterfaceMockRecorder) ReadServiceInjectionManifestFile(path interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadServiceInjectionManifestFile", reflect.TypeOf((*MockHostManagerInterface)(nil).ReadServiceInjectionManifestFile), path) +} + +// ReadServiceManifestFile mocks base method. +func (m *MockHostManagerInterface) ReadServiceManifestFile(path string) (*types.Service, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadServiceManifestFile", path) + ret0, _ := ret[0].(*types.Service) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReadServiceManifestFile indicates an expected call of ReadServiceManifestFile. +func (mr *MockHostManagerInterfaceMockRecorder) ReadServiceManifestFile(path interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadServiceManifestFile", reflect.TypeOf((*MockHostManagerInterface)(nil).ReadServiceManifestFile), path) +} + +// RebindVfToDefaultDriver mocks base method. +func (m *MockHostManagerInterface) RebindVfToDefaultDriver(pciAddr string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RebindVfToDefaultDriver", pciAddr) + ret0, _ := ret[0].(error) + return ret0 +} + +// RebindVfToDefaultDriver indicates an expected call of RebindVfToDefaultDriver. +func (mr *MockHostManagerInterfaceMockRecorder) RebindVfToDefaultDriver(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RebindVfToDefaultDriver", reflect.TypeOf((*MockHostManagerInterface)(nil).RebindVfToDefaultDriver), pciAddr) +} + +// ReloadDriver mocks base method. +func (m *MockHostManagerInterface) ReloadDriver(driver string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReloadDriver", driver) + ret0, _ := ret[0].(error) + return ret0 +} + +// ReloadDriver indicates an expected call of ReloadDriver. +func (mr *MockHostManagerInterfaceMockRecorder) ReloadDriver(driver interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReloadDriver", reflect.TypeOf((*MockHostManagerInterface)(nil).ReloadDriver), driver) +} + +// RemoveFromService mocks base method. +func (m *MockHostManagerInterface) RemoveFromService(service *types.Service, options ...*unit.UnitOption) (*types.Service, error) { + m.ctrl.T.Helper() + varargs := []interface{}{service} + for _, a := range options { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "RemoveFromService", varargs...) + ret0, _ := ret[0].(*types.Service) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RemoveFromService indicates an expected call of RemoveFromService. +func (mr *MockHostManagerInterfaceMockRecorder) RemoveFromService(service interface{}, options ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{service}, options...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveFromService", reflect.TypeOf((*MockHostManagerInterface)(nil).RemoveFromService), varargs...) +} + +// RemoveUdevRule mocks base method. +func (m *MockHostManagerInterface) RemoveUdevRule(pfPciAddress string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveUdevRule", pfPciAddress) + ret0, _ := ret[0].(error) + return ret0 +} + +// RemoveUdevRule indicates an expected call of RemoveUdevRule. +func (mr *MockHostManagerInterfaceMockRecorder) RemoveUdevRule(pfPciAddress interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveUdevRule", reflect.TypeOf((*MockHostManagerInterface)(nil).RemoveUdevRule), pfPciAddress) +} + +// ResetSriovDevice mocks base method. +func (m *MockHostManagerInterface) ResetSriovDevice(ifaceStatus v1.InterfaceExt) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ResetSriovDevice", ifaceStatus) + ret0, _ := ret[0].(error) + return ret0 +} + +// ResetSriovDevice indicates an expected call of ResetSriovDevice. +func (mr *MockHostManagerInterfaceMockRecorder) ResetSriovDevice(ifaceStatus interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResetSriovDevice", reflect.TypeOf((*MockHostManagerInterface)(nil).ResetSriovDevice), ifaceStatus) +} + +// SetNetdevMTU mocks base method. +func (m *MockHostManagerInterface) SetNetdevMTU(pciAddr string, mtu int) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetNetdevMTU", pciAddr, mtu) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetNetdevMTU indicates an expected call of SetNetdevMTU. +func (mr *MockHostManagerInterfaceMockRecorder) SetNetdevMTU(pciAddr, mtu interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNetdevMTU", reflect.TypeOf((*MockHostManagerInterface)(nil).SetNetdevMTU), pciAddr, mtu) +} + +// SetSriovNumVfs mocks base method. +func (m *MockHostManagerInterface) SetSriovNumVfs(pciAddr string, numVfs int) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetSriovNumVfs", pciAddr, numVfs) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetSriovNumVfs indicates an expected call of SetSriovNumVfs. +func (mr *MockHostManagerInterfaceMockRecorder) SetSriovNumVfs(pciAddr, numVfs interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSriovNumVfs", reflect.TypeOf((*MockHostManagerInterface)(nil).SetSriovNumVfs), pciAddr, numVfs) +} + +// SetVfAdminMac mocks base method. +func (m *MockHostManagerInterface) SetVfAdminMac(vfAddr string, pfLink, vfLink netlink.Link) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetVfAdminMac", vfAddr, pfLink, vfLink) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetVfAdminMac indicates an expected call of SetVfAdminMac. +func (mr *MockHostManagerInterfaceMockRecorder) SetVfAdminMac(vfAddr, pfLink, vfLink interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVfAdminMac", reflect.TypeOf((*MockHostManagerInterface)(nil).SetVfAdminMac), vfAddr, pfLink, vfLink) +} + +// SetVfGUID mocks base method. +func (m *MockHostManagerInterface) SetVfGUID(vfAddr string, pfLink netlink.Link) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetVfGUID", vfAddr, pfLink) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetVfGUID indicates an expected call of SetVfGUID. +func (mr *MockHostManagerInterfaceMockRecorder) SetVfGUID(vfAddr, pfLink interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetVfGUID", reflect.TypeOf((*MockHostManagerInterface)(nil).SetVfGUID), vfAddr, pfLink) +} + +// TriggerUdevEvent mocks base method. +func (m *MockHostManagerInterface) TriggerUdevEvent() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TriggerUdevEvent") + ret0, _ := ret[0].(error) + return ret0 +} + +// TriggerUdevEvent indicates an expected call of TriggerUdevEvent. +func (mr *MockHostManagerInterfaceMockRecorder) TriggerUdevEvent() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TriggerUdevEvent", reflect.TypeOf((*MockHostManagerInterface)(nil).TriggerUdevEvent)) +} + +// TryEnableRdma mocks base method. +func (m *MockHostManagerInterface) TryEnableRdma() (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TryEnableRdma") + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// TryEnableRdma indicates an expected call of TryEnableRdma. +func (mr *MockHostManagerInterfaceMockRecorder) TryEnableRdma() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryEnableRdma", reflect.TypeOf((*MockHostManagerInterface)(nil).TryEnableRdma)) +} + +// TryEnableTun mocks base method. +func (m *MockHostManagerInterface) TryEnableTun() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "TryEnableTun") +} + +// TryEnableTun indicates an expected call of TryEnableTun. +func (mr *MockHostManagerInterfaceMockRecorder) TryEnableTun() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryEnableTun", reflect.TypeOf((*MockHostManagerInterface)(nil).TryEnableTun)) +} + +// TryEnableVhostNet mocks base method. +func (m *MockHostManagerInterface) TryEnableVhostNet() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "TryEnableVhostNet") +} + +// TryEnableVhostNet indicates an expected call of TryEnableVhostNet. +func (mr *MockHostManagerInterfaceMockRecorder) TryEnableVhostNet() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryEnableVhostNet", reflect.TypeOf((*MockHostManagerInterface)(nil).TryEnableVhostNet)) +} + +// TryGetInterfaceName mocks base method. +func (m *MockHostManagerInterface) TryGetInterfaceName(pciAddr string) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TryGetInterfaceName", pciAddr) + ret0, _ := ret[0].(string) + return ret0 +} + +// TryGetInterfaceName indicates an expected call of TryGetInterfaceName. +func (mr *MockHostManagerInterfaceMockRecorder) TryGetInterfaceName(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryGetInterfaceName", reflect.TypeOf((*MockHostManagerInterface)(nil).TryGetInterfaceName), pciAddr) +} + +// TryToGetVirtualInterfaceName mocks base method. +func (m *MockHostManagerInterface) TryToGetVirtualInterfaceName(pciAddr string) string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "TryToGetVirtualInterfaceName", pciAddr) + ret0, _ := ret[0].(string) + return ret0 +} + +// TryToGetVirtualInterfaceName indicates an expected call of TryToGetVirtualInterfaceName. +func (mr *MockHostManagerInterfaceMockRecorder) TryToGetVirtualInterfaceName(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryToGetVirtualInterfaceName", reflect.TypeOf((*MockHostManagerInterface)(nil).TryToGetVirtualInterfaceName), pciAddr) +} + +// Unbind mocks base method. +func (m *MockHostManagerInterface) Unbind(pciAddr string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Unbind", pciAddr) + ret0, _ := ret[0].(error) + return ret0 +} + +// Unbind indicates an expected call of Unbind. +func (mr *MockHostManagerInterfaceMockRecorder) Unbind(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unbind", reflect.TypeOf((*MockHostManagerInterface)(nil).Unbind), pciAddr) +} + +// UnbindDriverByBusAndDevice mocks base method. +func (m *MockHostManagerInterface) UnbindDriverByBusAndDevice(bus, device string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UnbindDriverByBusAndDevice", bus, device) + ret0, _ := ret[0].(error) + return ret0 +} + +// UnbindDriverByBusAndDevice indicates an expected call of UnbindDriverByBusAndDevice. +func (mr *MockHostManagerInterfaceMockRecorder) UnbindDriverByBusAndDevice(bus, device interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnbindDriverByBusAndDevice", reflect.TypeOf((*MockHostManagerInterface)(nil).UnbindDriverByBusAndDevice), bus, device) +} + +// UnbindDriverIfNeeded mocks base method. +func (m *MockHostManagerInterface) UnbindDriverIfNeeded(pciAddr string, isRdma bool) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UnbindDriverIfNeeded", pciAddr, isRdma) + ret0, _ := ret[0].(error) + return ret0 +} + +// UnbindDriverIfNeeded indicates an expected call of UnbindDriverIfNeeded. +func (mr *MockHostManagerInterfaceMockRecorder) UnbindDriverIfNeeded(pciAddr, isRdma interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnbindDriverIfNeeded", reflect.TypeOf((*MockHostManagerInterface)(nil).UnbindDriverIfNeeded), pciAddr, isRdma) +} + +// UpdateSystemService mocks base method. +func (m *MockHostManagerInterface) UpdateSystemService(serviceObj *types.Service) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateSystemService", serviceObj) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateSystemService indicates an expected call of UpdateSystemService. +func (mr *MockHostManagerInterfaceMockRecorder) UpdateSystemService(serviceObj interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSystemService", reflect.TypeOf((*MockHostManagerInterface)(nil).UpdateSystemService), serviceObj) +} + +// VFIsReady mocks base method. +func (m *MockHostManagerInterface) VFIsReady(pciAddr string) (netlink.Link, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "VFIsReady", pciAddr) + ret0, _ := ret[0].(netlink.Link) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// VFIsReady indicates an expected call of VFIsReady. +func (mr *MockHostManagerInterfaceMockRecorder) VFIsReady(pciAddr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VFIsReady", reflect.TypeOf((*MockHostManagerInterface)(nil).VFIsReady), pciAddr) +} + +// WriteSwitchdevConfFile mocks base method. +func (m *MockHostManagerInterface) WriteSwitchdevConfFile(newState *v1.SriovNetworkNodeState, pfsToSkip map[string]bool) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WriteSwitchdevConfFile", newState, pfsToSkip) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WriteSwitchdevConfFile indicates an expected call of WriteSwitchdevConfFile. +func (mr *MockHostManagerInterfaceMockRecorder) WriteSwitchdevConfFile(newState, pfsToSkip interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteSwitchdevConfFile", reflect.TypeOf((*MockHostManagerInterface)(nil).WriteSwitchdevConfFile), newState, pfsToSkip) +}