mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-08-31 16:38:43 +00:00
Replace multus code with NPWG client library code
This commit is contained in:
committed by
Tomofumi Hayashi
parent
f4f2f65d1d
commit
9874c14e23
@@ -21,7 +21,6 @@ import (
|
||||
|
||||
"github.com/containernetworking/cni/libcni"
|
||||
"github.com/containernetworking/cni/pkg/skel"
|
||||
"github.com/containernetworking/cni/pkg/types"
|
||||
"github.com/containernetworking/cni/pkg/types/current"
|
||||
"github.com/containernetworking/cni/pkg/version"
|
||||
"github.com/intel/multus-cni/logging"
|
||||
@@ -199,43 +198,6 @@ func GetGatewayFromResult(result *current.Result) []net.IP {
|
||||
return gateways
|
||||
}
|
||||
|
||||
// LoadNetworkStatus create network status from CNI result
|
||||
func LoadNetworkStatus(r types.Result, netName string, defaultNet bool) (*NetworkStatus, error) {
|
||||
logging.Debugf("LoadNetworkStatus: %v, %s, %t", r, netName, defaultNet)
|
||||
netstatus := &NetworkStatus{}
|
||||
netstatus.Name = netName
|
||||
|
||||
// Convert whatever the IPAM result was into the current Result type
|
||||
result, err := current.NewResultFromResult(r)
|
||||
if err != nil {
|
||||
logging.Errorf("LoadNetworkStatus: error converting the type.Result to current.Result: %v", err)
|
||||
return netstatus, err
|
||||
}
|
||||
for _, ifs := range result.Interfaces {
|
||||
//Only pod interfaces can have sandbox information
|
||||
if ifs.Sandbox != "" {
|
||||
netstatus.Interface = ifs.Name
|
||||
netstatus.Mac = ifs.Mac
|
||||
}
|
||||
}
|
||||
|
||||
for _, ipconfig := range result.IPs {
|
||||
if ipconfig.Version == "4" && ipconfig.Address.IP.To4() != nil {
|
||||
netstatus.IPs = append(netstatus.IPs, ipconfig.Address.IP.String())
|
||||
}
|
||||
|
||||
if ipconfig.Version == "6" && ipconfig.Address.IP.To16() != nil {
|
||||
netstatus.IPs = append(netstatus.IPs, ipconfig.Address.IP.String())
|
||||
}
|
||||
}
|
||||
|
||||
netstatus.DNS = result.DNS
|
||||
netstatus.Gateway = GetGatewayFromResult(result)
|
||||
|
||||
return netstatus, nil
|
||||
|
||||
}
|
||||
|
||||
// LoadNetConf converts inputs (i.e. stdin) to NetConf
|
||||
func LoadNetConf(bytes []byte) (*NetConf, error) {
|
||||
netconf := &NetConf{}
|
||||
|
Reference in New Issue
Block a user