• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

k8snetworkplumbingwg / sriov-network-operator / 3751025296

pending completion
3751025296

Pull #365

github

GitHub
Merge 421284b55 into 788d76f7e
Pull Request #365: Implementation for new systemd configuration method

958 of 958 new or added lines in 18 files covered. (100.0%)

1971 of 8330 relevant lines covered (23.66%)

0.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pkg/daemon/plugin.go
1
package daemon
2

3
import (
4
        "fmt"
5

6
        "github.com/golang/glog"
7

8
        sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
9
        plugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins"
10
        genericplugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins/generic"
11
        intelplugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins/intel"
12
        k8splugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins/k8s"
13
        mellanoxplugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins/mellanox"
14
        virtualplugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins/virtual"
15
        "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
16
)
17

18
var VendorPluginMap = map[string]func() (plugin.VendorPlugin, error){
19
        "8086": intelplugin.NewIntelPlugin,
20
        "15b3": mellanoxplugin.NewMellanoxPlugin,
21
}
22

23
var (
24
        GenericPlugin     = genericplugin.NewGenericPlugin
25
        GenericPluginName = genericplugin.PluginName
26
        VirtualPlugin     = virtualplugin.NewVirtualPlugin
27
        VirtualPluginName = virtualplugin.PluginName
28
        K8sPlugin         = k8splugin.NewK8sPlugin
29
)
30

31
func enablePlugins(platform utils.PlatformType, useSystemdService bool, ns *sriovnetworkv1.SriovNetworkNodeState) (map[string]plugin.VendorPlugin, error) {
×
32
        glog.Infof("enableVendorPlugins(): enabling plugins")
×
33
        enabledPlugins := map[string]plugin.VendorPlugin{}
×
34

×
35
        if platform == utils.VirtualOpenStack {
×
36
                virtualPlugin, err := VirtualPlugin(false)
×
37
                if err != nil {
×
38
                        glog.Errorf("enableVendorPlugins(): failed to load the virtual plugin error: %v", err)
×
39
                        return nil, err
×
40
                }
×
41
                enabledPlugins[virtualPlugin.Name()] = virtualPlugin
×
42
        } else {
×
43
                enabledVendorPlugins, err := registerVendorPlugins(ns)
×
44
                if err != nil {
×
45
                        return nil, err
×
46
                }
×
47
                enabledPlugins = enabledVendorPlugins
×
48

×
49
                if utils.ClusterType != utils.ClusterTypeOpenshift {
×
50
                        k8sPlugin, err := K8sPlugin(useSystemdService)
×
51
                        if err != nil {
×
52
                                glog.Errorf("enableVendorPlugins(): failed to load the k8s plugin error: %v", err)
×
53
                                return nil, err
×
54
                        }
×
55
                        enabledPlugins[k8sPlugin.Name()] = k8sPlugin
×
56
                }
57
                genericPlugin, err := GenericPlugin(false)
×
58
                if err != nil {
×
59
                        glog.Errorf("enableVendorPlugins(): failed to load the generic plugin error: %v", err)
×
60
                        return nil, err
×
61
                }
×
62
                enabledPlugins[genericPlugin.Name()] = genericPlugin
×
63
        }
64

65
        pluginList := make([]string, 0, len(enabledPlugins))
×
66
        for pluginName := range enabledPlugins {
×
67
                pluginList = append(pluginList, pluginName)
×
68
        }
×
69
        glog.Infof("enableVendorPlugins(): enabled plugins %s", pluginList)
×
70
        return enabledPlugins, nil
×
71
}
72

73
func registerVendorPlugins(ns *sriovnetworkv1.SriovNetworkNodeState) (map[string]plugin.VendorPlugin, error) {
×
74
        vendorPlugins := map[string]plugin.VendorPlugin{}
×
75

×
76
        for _, iface := range ns.Status.Interfaces {
×
77
                if val, ok := VendorPluginMap[iface.Vendor]; ok {
×
78
                        plug, err := val()
×
79
                        if err != nil {
×
80
                                glog.Errorf("registerVendorPlugins(): failed to load the %s plugin error: %v", plug.Name(), err)
×
81
                                return vendorPlugins, fmt.Errorf("registerVendorPlugins(): failed to load the %s plugin error: %v", plug.Name(), err)
×
82
                        }
×
83
                        vendorPlugins[plug.Name()] = plug
×
84
                }
85
        }
86

87
        return vendorPlugins, nil
×
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc