@@ -390,20 +390,24 @@ func mask2len(mask string) int8 {
390390}
391391
392392func (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
0 commit comments