mirror of https://github.com/apache/cloudstack.git
bug 11513: always wrap marking IP address with Releasing state and actual IP deallocation in Transaction
Reviewed-by:edison@citrix.com
This commit is contained in:
parent
8abb85f9e8
commit
76781d9b21
|
|
@ -51,6 +51,8 @@ import com.cloud.offerings.dao.NetworkOfferingDao;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
|
|
@ -208,7 +210,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
return network;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @DB
|
||||
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("direct network deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
|
||||
|
|
@ -216,8 +218,11 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
|
||||
IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
|
||||
if (ip != null) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
_networkMgr.markIpAsUnavailable(ip.getId());
|
||||
_ipAddressDao.unassignIpAddress(ip.getId());
|
||||
txn.commit();
|
||||
}
|
||||
nic.deallocate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ import com.cloud.network.dao.IPAddressDao;
|
|||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
|
@ -122,7 +124,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
|||
return nic;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @DB
|
||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
|
||||
|
|
@ -137,10 +139,15 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
|||
if (ipVO != null) {
|
||||
List<PodVlanMapVO> mapVO = _podVlanDao.listPodVlanMapsByVlan(ipVO.getVlanId());
|
||||
if (mapVO.get(0).getPodId() != dest.getPod().getId()) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
//release the old ip here
|
||||
_networkMgr.markIpAsUnavailable(ipVO.getId());
|
||||
_ipAddressDao.unassignIpAddress(ipVO.getId());
|
||||
|
||||
txn.commit();
|
||||
|
||||
nic.setIp4Address(null);
|
||||
getNewIp = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ import com.cloud.offerings.dao.NetworkOfferingDao;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.Nic.ReservationStrategy;
|
||||
import com.cloud.vm.NicProfile;
|
||||
|
|
@ -179,7 +181,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
return network;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @DB
|
||||
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("public network deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIp4Address());
|
||||
|
|
@ -187,8 +189,14 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||
|
||||
IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIp4Address());
|
||||
if (ip != null && nic.getReservationStrategy() != ReservationStrategy.Managed) {
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
_networkMgr.markIpAsUnavailable(ip.getId());
|
||||
_ipAddressDao.unassignIpAddress(ip.getId());
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
nic.deallocate();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue