CLOUDSTACK-5916: associateIpAddress leaves an IP in allocating state

This commit is contained in:
Saksham Srivastava 2014-01-21 13:36:05 +05:30 committed by Murali Reddy
parent 20fd2769a9
commit 85d0f8f93a

View File

@ -3865,10 +3865,16 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
Network network = _networksDao.findById(networkId);
if (network == null) {
// release the acquired IP addrress before throwing the exception
// else it will always be in allocating state
releaseIpAddress(ipId);
throw new InvalidParameterValueException("Invalid network id is given");
}
if (network.getVpcId() != null) {
// release the acquired IP addrress before throwing the exception
// else it will always be in allocating state
releaseIpAddress(ipId);
throw new InvalidParameterValueException("Can't assign ip to the network directly when network belongs" + " to VPC.Specify vpcId to associate ip address to VPC");
}
return _ipAddrMgr.associateIPToGuestNetwork(ipId, networkId, true);