File tree 1 file changed +10
-7
lines changed
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -41,19 +41,22 @@ func GetMasterInterface() string {
41
41
return UHostMasterInterface
42
42
}
43
43
44
- var targetInterface string
45
- if strings .HasPrefix (meta .InstanceId , "upm" ) {
46
- targetInterface = UPHostMasterInterface
44
+ var targetMac string
45
+ // 裸金属根据mac地址匹配网卡
46
+ if strings .HasPrefix (meta .InstanceId , "upm" ) && len (meta .UPHost .NetworkInterfaces ) > 0 {
47
+ mac := meta .UPHost .NetworkInterfaces [0 ].Mac
48
+ targetMac = strings .ToLower (mac )
47
49
} else {
48
- targetInterface = UHostMasterInterface
50
+ // 云主机直接返回eth0
51
+ return UHostMasterInterface
49
52
}
50
53
51
54
for _ , iface := range list {
52
- if iface .Name == targetInterface {
53
- return targetInterface
55
+ if iface .HardwareAddr . String () == targetMac {
56
+ return iface . Name
54
57
}
55
58
}
56
- return targetInterface
59
+ return UPHostMasterInterface
57
60
}
58
61
59
62
// Get node master network interface ip and mac address
You can’t perform that action at this time.
0 commit comments