forked from github/multus-cni
Add infinibandGUID runtime config to delegate netconf
This commit extend the various network conf methods to translate `infiniband-guid` network attachment configuration to `infinibandGUID` CNI runtime config. - Update relevant methods in types package - Update unit tests
This commit is contained in:
committed by
Tomofumi Hayashi
parent
46be700cb5
commit
2796202d8c
@@ -211,6 +211,12 @@ func parsePodNetworkAnnotation(podNetworks, defaultNamespace string) ([]*types.N
|
||||
return nil, logging.Errorf("parsePodNetworkAnnotation: failed to mac: %v", err)
|
||||
}
|
||||
}
|
||||
if n.InfinibandGUIDRequest != "" {
|
||||
// validate GUID address
|
||||
if _, err := net.ParseMAC(n.InfinibandGUIDRequest); err != nil {
|
||||
return nil, logging.Errorf("parsePodNetworkAnnotation: failed to validate infiniband GUID: %v", err)
|
||||
}
|
||||
}
|
||||
if n.IPRequest != nil {
|
||||
for _, ip := range n.IPRequest {
|
||||
// validate IP address
|
||||
|
@@ -119,6 +119,9 @@ func LoadDelegateNetConf(bytes []byte, net *NetworkSelectionElement, deviceID st
|
||||
if net.GatewayRequest != nil {
|
||||
delegateConf.GatewayRequest = append(delegateConf.GatewayRequest, net.GatewayRequest...)
|
||||
}
|
||||
if net.InfinibandGUIDRequest != "" {
|
||||
delegateConf.InfinibandGUIDRequest = net.InfinibandGUIDRequest
|
||||
}
|
||||
}
|
||||
|
||||
delegateConf.Bytes = bytes
|
||||
@@ -148,6 +151,9 @@ func MergeCNIRuntimeConfig(runtimeConfig *RuntimeConfig, delegate *DelegateNetCo
|
||||
if delegate.MacRequest != "" {
|
||||
runtimeConfig.Mac = delegate.MacRequest
|
||||
}
|
||||
if delegate.InfinibandGUIDRequest != "" {
|
||||
runtimeConfig.InfinibandGUID = delegate.InfinibandGUIDRequest
|
||||
}
|
||||
}
|
||||
|
||||
return runtimeConfig
|
||||
@@ -187,6 +193,9 @@ func CreateCNIRuntimeConf(args *skel.CmdArgs, k8sArgs *K8sArgs, ifName string, r
|
||||
if len(rc.Mac) != 0 {
|
||||
capabilityArgs["mac"] = rc.Mac
|
||||
}
|
||||
if len(rc.InfinibandGUID) != 0 {
|
||||
capabilityArgs["infinibandGUID"] = rc.InfinibandGUID
|
||||
}
|
||||
rt.CapabilityArgs = capabilityArgs
|
||||
}
|
||||
return rt
|
||||
|
@@ -662,6 +662,7 @@ var _ = Describe("config operations", func() {
|
||||
Name: "testname",
|
||||
InterfaceRequest: "testIF1",
|
||||
MacRequest: "c2:11:22:33:44:66",
|
||||
InfinibandGUIDRequest: "24:8a:07:03:00:8d:ae:2e",
|
||||
IPRequest: []string{"10.0.0.1/24"},
|
||||
BandwidthRequest: bandwidthEntry1,
|
||||
PortMappingsRequest: []*PortMapEntry{portMapEntry1},
|
||||
@@ -671,6 +672,7 @@ var _ = Describe("config operations", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(delegateConf.IfnameRequest).To(Equal(networkSelection.InterfaceRequest))
|
||||
Expect(delegateConf.MacRequest).To(Equal(networkSelection.MacRequest))
|
||||
Expect(delegateConf.InfinibandGUIDRequest).To(Equal(networkSelection.InfinibandGUIDRequest))
|
||||
Expect(delegateConf.IPRequest).To(Equal(networkSelection.IPRequest))
|
||||
Expect(delegateConf.BandwidthRequest).To(Equal(networkSelection.BandwidthRequest))
|
||||
Expect(delegateConf.PortMappingsRequest).To(Equal(networkSelection.PortMappingsRequest))
|
||||
@@ -707,6 +709,7 @@ var _ = Describe("config operations", func() {
|
||||
Name: "testname",
|
||||
InterfaceRequest: "testIF1",
|
||||
MacRequest: "c2:11:22:33:44:66",
|
||||
InfinibandGUIDRequest: "24:8a:07:03:00:8d:ae:2e",
|
||||
IPRequest: []string{"10.0.0.1/24"},
|
||||
BandwidthRequest: bandwidthEntry1,
|
||||
PortMappingsRequest: []*PortMapEntry{portMapEntry1},
|
||||
@@ -717,6 +720,7 @@ var _ = Describe("config operations", func() {
|
||||
runtimeConf := MergeCNIRuntimeConfig(&RuntimeConfig{}, delegate)
|
||||
Expect(runtimeConf.PortMaps).To(BeNil())
|
||||
Expect(runtimeConf.Bandwidth).To(BeNil())
|
||||
Expect(runtimeConf.InfinibandGUID).To(Equal(""))
|
||||
})
|
||||
|
||||
It("test MergeCNIRuntimeConfig with delegate plugin", func() {
|
||||
@@ -742,6 +746,7 @@ var _ = Describe("config operations", func() {
|
||||
Name: "testname",
|
||||
InterfaceRequest: "testIF1",
|
||||
MacRequest: "c2:11:22:33:44:66",
|
||||
InfinibandGUIDRequest: "24:8a:07:03:00:8d:ae:2e",
|
||||
IPRequest: []string{"10.0.0.1/24"},
|
||||
BandwidthRequest: bandwidthEntry1,
|
||||
PortMappingsRequest: []*PortMapEntry{portMapEntry1},
|
||||
@@ -755,5 +760,6 @@ var _ = Describe("config operations", func() {
|
||||
Expect(runtimeConf.Bandwidth).To(Equal(bandwidthEntry1))
|
||||
Expect(len(runtimeConf.IPs)).To(BeEquivalentTo(1))
|
||||
Expect(runtimeConf.Mac).To(Equal("c2:11:22:33:44:66"))
|
||||
Expect(runtimeConf.InfinibandGUID).To(Equal("24:8a:07:03:00:8d:ae:2e"))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user