github.com/k8snetworkplumbingwg/sriov-network-operator@v1.2.1-0.20240408194816-2d2e5a45d453/pkg/host/manager.go (about)

     1  package host
     2  
     3  import (
     4  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/kernel"
     5  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/lib/dputils"
     6  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/lib/ethtool"
     7  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/lib/netlink"
     8  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/network"
     9  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/service"
    10  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/sriov"
    11  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/udev"
    12  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/vdpa"
    13  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types"
    14  	"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
    15  )
    16  
    17  // Contains all the host manipulation functions
    18  //
    19  //go:generate ../../bin/mockgen -destination mock/mock_host.go -source manager.go
    20  type HostManagerInterface interface {
    21  	types.KernelInterface
    22  	types.NetworkInterface
    23  	types.ServiceInterface
    24  	types.UdevInterface
    25  	types.SriovInterface
    26  	types.VdpaInterface
    27  }
    28  
    29  type hostManager struct {
    30  	utils.CmdInterface
    31  	types.KernelInterface
    32  	types.NetworkInterface
    33  	types.ServiceInterface
    34  	types.UdevInterface
    35  	types.SriovInterface
    36  	types.VdpaInterface
    37  }
    38  
    39  func NewHostManager(utilsInterface utils.CmdInterface) HostManagerInterface {
    40  	dpUtils := dputils.New()
    41  	netlinkLib := netlink.New()
    42  	ethtoolLib := ethtool.New()
    43  	k := kernel.New(utilsInterface)
    44  	n := network.New(utilsInterface, dpUtils, netlinkLib, ethtoolLib)
    45  	sv := service.New(utilsInterface)
    46  	u := udev.New(utilsInterface)
    47  	v := vdpa.New(k, netlinkLib)
    48  	sr := sriov.New(utilsInterface, k, n, u, v, netlinkLib, dpUtils)
    49  
    50  	return &hostManager{
    51  		utilsInterface,
    52  		k,
    53  		n,
    54  		sv,
    55  		u,
    56  		sr,
    57  		v,
    58  	}
    59  }