diff --git a/types/conf.go b/types/conf.go index 2ab83b999..495a47836 100644 --- a/types/conf.go +++ b/types/conf.go @@ -122,6 +122,13 @@ func LoadDelegateNetConf(bytes []byte, net *NetworkSelectionElement, deviceID st if net.InfinibandGUIDRequest != "" { delegateConf.InfinibandGUIDRequest = net.InfinibandGUIDRequest } + if net.DeviceID != "" { + if deviceID != "" { + logging.Debugf("Warning: Both RuntimeConfig and ResourceMap provide deviceID. Ignoring RuntimeConfig") + } else { + delegateConf.DeviceID = net.DeviceID + } + } } delegateConf.Bytes = bytes @@ -154,6 +161,9 @@ func mergeCNIRuntimeConfig(runtimeConfig *RuntimeConfig, delegate *DelegateNetCo if delegate.InfinibandGUIDRequest != "" { runtimeConfig.InfinibandGUID = delegate.InfinibandGUIDRequest } + if delegate.DeviceID != "" { + runtimeConfig.DeviceID = delegate.DeviceID + } } return runtimeConfig @@ -202,6 +212,9 @@ func CreateCNIRuntimeConf(args *skel.CmdArgs, k8sArgs *K8sArgs, ifName string, r if len(delegateRc.InfinibandGUID) != 0 { capabilityArgs["infinibandGUID"] = delegateRc.InfinibandGUID } + if delegateRc.DeviceID != "" { + capabilityArgs["deviceID"] = delegateRc.DeviceID + } rt.CapabilityArgs = capabilityArgs } return rt diff --git a/types/types.go b/types/types.go index 450b81f61..3a7b4cb67 100644 --- a/types/types.go +++ b/types/types.go @@ -62,6 +62,7 @@ type RuntimeConfig struct { IPs []string `json:"ips,omitempty"` Mac string `json:"mac,omitempty"` InfinibandGUID string `json:"infinibandGUID,omitempty"` + DeviceID string `json:"deviceID,omitempty"` } // PortMapEntry for CNI PortMapEntry @@ -108,6 +109,8 @@ type DelegateNetConf struct { MasterPlugin bool `json:"-"` // Conflist plugin is only used internal housekeeping ConfListPlugin bool `json:"-"` + // DeviceID is only used internal housekeeping + DeviceID string `json:"deviceID,omitempty"` // Raw JSON Bytes []byte @@ -143,6 +146,8 @@ type NetworkSelectionElement struct { // BandwidthRequest contains an optional requested bandwidth for // the network BandwidthRequest *BandwidthEntry `json:"bandwidth,omitempty"` + // DeviceID contains an optional requested deviceID the network + DeviceID string `json:"deviceID,omitempty"` // CNIArgs contains additional CNI arguments for the network interface CNIArgs *map[string]interface{} `json:"cni-args"` // GatewayRequest contains default route IP address for the pod