mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
fix(host): host-agent register skip upload vf nics
This commit is contained in:
@@ -1638,7 +1638,17 @@ func (h *SHostInfo) ensureNicsHostwires(hostInfo *api.HostDetails) error {
|
||||
}
|
||||
|
||||
func (h *SHostInfo) isVirtualFunction(nic string) bool {
|
||||
return fileutils2.Exists(path.Join("/sys/class/net", nic, "device", "physfn"))
|
||||
physPortName, err := fileutils2.FileGetContents(path.Join("/sys/class/net", nic, "phys_port_name"))
|
||||
if err != nil {
|
||||
log.Warningf("failed get nic %s phys_port_name: %s", nic, err)
|
||||
return false
|
||||
}
|
||||
if strings.Contains(physPortName, "vf") {
|
||||
log.Infof("nic %s is virtual function", nic)
|
||||
return true
|
||||
}
|
||||
log.Infof("nic %s is not virtual function", nic)
|
||||
return false
|
||||
}
|
||||
|
||||
func (h *SHostInfo) uploadNetworkInfo() error {
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
@@ -50,9 +51,14 @@ func Nics() ([]*types.SNicDevInfo, error) {
|
||||
} /*else if (fi.Mode() & os.ModeSymlink) == 0 {
|
||||
continue
|
||||
}*/
|
||||
if fileutils2.Exists(path.Join(netPath, "device", "infiniband")) {
|
||||
// skip infiniband nic
|
||||
continue
|
||||
nicType, err := fileutils2.FileGetContents(path.Join(netPath, "type"))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed get nic type")
|
||||
}
|
||||
if strings.TrimSpace(nicType) == "32" {
|
||||
// include/uapi/linux/if_arp.h
|
||||
// #define ARPHRD_INFINIBAND 32 /* InfiniBand */
|
||||
continue // skip infiniband nic
|
||||
}
|
||||
|
||||
speedStr := GetSysConfigQuiet(filepath.Join(netPath, "speed"))
|
||||
|
||||
Reference in New Issue
Block a user