Skip to content

Commit 20810c7

Browse files
authored
Merge pull request #1232 from ioito/hotfix/qx-host-access-ip
fix(esxi): host access ip sync
2 parents 3bc982f + 6859e52 commit 20810c7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pkg/multicloud/esxi/host.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,20 +390,24 @@ func mask2len(mask string) int8 {
390390
}
391391

392392
func (host *SHost) isVnicAdmin(nic types.HostVirtualNic) bool {
393+
return host.isIpAdmin(nic.Spec.Ip.IpAddress)
394+
}
395+
396+
func (host *SHost) isIpAdmin(ip string) bool {
393397
if len(host.masterIp) > 0 {
394-
if host.masterIp == nic.Spec.Ip.IpAddress {
398+
if host.masterIp == ip {
395399
return true
396400
} else {
397401
return false
398402
}
399403
}
400-
exist, err := host.manager.IsHostIpExists(nic.Spec.Ip.IpAddress)
404+
exist, err := host.manager.IsHostIpExists(ip)
401405
if err != nil {
402-
log.Errorf("IsHostIpExists %s fail %s", nic.Spec.Ip.IpAddress, err)
406+
log.Errorf("IsHostIpExists %s fail %s", ip, err)
403407
return false
404408
}
405409
if exist {
406-
host.masterIp = nic.Spec.Ip.IpAddress
410+
host.masterIp = ip
407411
return true
408412
}
409413
return false
@@ -444,15 +448,11 @@ func (host *SHost) fetchNicInfo(debug bool) []sHostNicInfo {
444448
}
445449

446450
for _, nic := range vnics {
447-
gateway := ""
448-
if nic.Spec.IpRouteSpec != nil && nic.Spec.IpRouteSpec.IpRouteConfig.GetHostIpRouteConfig() != nil {
449-
gateway = nic.Spec.IpRouteSpec.IpRouteConfig.GetHostIpRouteConfig().DefaultGateway
450-
}
451451
// log.Debugf("vnic %d: %s %#v", i, jsonutils.Marshal(nic), nic)
452452
mac := netutils.FormatMacAddr(nic.Spec.Mac)
453453
pnic := findHostNicByMac(nicInfoList, mac)
454454
if pnic != nil {
455-
if len(pnic.IpAddr) > 0 && len(gateway) == 0 {
455+
if len(pnic.IpAddr) > 0 && host.isIpAdmin(pnic.IpAddr) {
456456
continue
457457
}
458458
// findMaster = true

pkg/multicloud/esxi/mobase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (self *SManagedObject) fetchPath() []string {
8383
func (self *SManagedObject) GetPath() []string {
8484
if self.path == nil {
8585
self.path = self.fetchPath()
86-
log.Errorf("fetch path: %s", self.path)
86+
log.Debugf("fetch path: %s", self.path)
8787
}
8888
return self.path
8989
}

0 commit comments

Comments
 (0)