mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
Automatic merge from release/2.1.0 -> release/2.2.0
* commit 'a2c1aaeac47037d9d39cccd4a70ed5875a3914d8': 避免有重复ip时覆盖部分guest ip
This commit is contained in:
@@ -338,10 +338,10 @@ func (manager *SGuestnetworkManager) DeleteGuestNics(ctx context.Context, guest
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *SGuestnetworkManager) getGuestNicByIP(ip string) (*SGuestnetwork, error) {
|
||||
func (manager *SGuestnetworkManager) getGuestNicByIP(ip string, networkId string) (*SGuestnetwork, error) {
|
||||
gn := SGuestnetwork{}
|
||||
q := manager.Query()
|
||||
q = q.Equals("ip_addr", ip)
|
||||
q = q.Equals("ip_addr", ip).Equals("network_id", networkId)
|
||||
err := q.First(&gn)
|
||||
if err != nil {
|
||||
if err != sql.ErrNoRows {
|
||||
@@ -578,4 +578,4 @@ func (manager *SGuestnetworkManager) getRecentlyReleasedIPAddresses(networkId st
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1660,7 +1660,7 @@ func (self *SGuest) SyncVMNics(ctx context.Context, userCred mcclient.TokenCrede
|
||||
continue // cannot determine which network it attached to
|
||||
}
|
||||
// check if the IP has been occupied, if yes, release the IP
|
||||
gn, err := GuestnetworkManager.getGuestNicByIP(add.nic.GetIP())
|
||||
gn, err := GuestnetworkManager.getGuestNicByIP(add.nic.GetIP(), add.net.Id)
|
||||
if err != nil {
|
||||
result.AddError(err)
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user