Add deviceID support in runtimeConfig

Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
This commit is contained in:
Billy McFall 2020-10-28 08:51:01 -04:00
parent 665c43a2cd
commit fd3f485e63
2 changed files with 18 additions and 0 deletions

View File

@ -122,6 +122,13 @@ func LoadDelegateNetConf(bytes []byte, net *NetworkSelectionElement, deviceID st
if net.InfinibandGUIDRequest != "" { if net.InfinibandGUIDRequest != "" {
delegateConf.InfinibandGUIDRequest = 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 delegateConf.Bytes = bytes
@ -154,6 +161,9 @@ func mergeCNIRuntimeConfig(runtimeConfig *RuntimeConfig, delegate *DelegateNetCo
if delegate.InfinibandGUIDRequest != "" { if delegate.InfinibandGUIDRequest != "" {
runtimeConfig.InfinibandGUID = delegate.InfinibandGUIDRequest runtimeConfig.InfinibandGUID = delegate.InfinibandGUIDRequest
} }
if delegate.DeviceID != "" {
runtimeConfig.DeviceID = delegate.DeviceID
}
} }
return runtimeConfig return runtimeConfig
@ -202,6 +212,9 @@ func CreateCNIRuntimeConf(args *skel.CmdArgs, k8sArgs *K8sArgs, ifName string, r
if len(delegateRc.InfinibandGUID) != 0 { if len(delegateRc.InfinibandGUID) != 0 {
capabilityArgs["infinibandGUID"] = delegateRc.InfinibandGUID capabilityArgs["infinibandGUID"] = delegateRc.InfinibandGUID
} }
if delegateRc.DeviceID != "" {
capabilityArgs["deviceID"] = delegateRc.DeviceID
}
rt.CapabilityArgs = capabilityArgs rt.CapabilityArgs = capabilityArgs
} }
return rt return rt

View File

@ -62,6 +62,7 @@ type RuntimeConfig struct {
IPs []string `json:"ips,omitempty"` IPs []string `json:"ips,omitempty"`
Mac string `json:"mac,omitempty"` Mac string `json:"mac,omitempty"`
InfinibandGUID string `json:"infinibandGUID,omitempty"` InfinibandGUID string `json:"infinibandGUID,omitempty"`
DeviceID string `json:"deviceID,omitempty"`
} }
// PortMapEntry for CNI PortMapEntry // PortMapEntry for CNI PortMapEntry
@ -108,6 +109,8 @@ type DelegateNetConf struct {
MasterPlugin bool `json:"-"` MasterPlugin bool `json:"-"`
// Conflist plugin is only used internal housekeeping // Conflist plugin is only used internal housekeeping
ConfListPlugin bool `json:"-"` ConfListPlugin bool `json:"-"`
// DeviceID is only used internal housekeeping
DeviceID string `json:"deviceID,omitempty"`
// Raw JSON // Raw JSON
Bytes []byte Bytes []byte
@ -143,6 +146,8 @@ type NetworkSelectionElement struct {
// BandwidthRequest contains an optional requested bandwidth for // BandwidthRequest contains an optional requested bandwidth for
// the network // the network
BandwidthRequest *BandwidthEntry `json:"bandwidth,omitempty"` 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 contains additional CNI arguments for the network interface
CNIArgs *map[string]interface{} `json:"cni-args"` CNIArgs *map[string]interface{} `json:"cni-args"`
// GatewayRequest contains default route IP address for the pod // GatewayRequest contains default route IP address for the pod