mirror of https://github.com/apache/cloudstack.git
Can't release/disable static nat for IP when the IP is elastic
This commit is contained in:
parent
4f46c3b160
commit
a9e4af0866
|
|
@ -170,7 +170,6 @@ import com.cloud.user.User;
|
|||
import com.cloud.user.UserContext;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserStatisticsDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
|
|
@ -1929,15 +1928,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (_accountVlanMapDao.findAccountVlanMap(ipVO.getAllocatedToAccountId(), ipVO.getVlanId()) != null) {
|
||||
throw new InvalidParameterValueException("Ip address id=" + ipAddressId + " belongs to Account wide IP pool and cannot be disassociated");
|
||||
}
|
||||
|
||||
//don't allow releasing elastic ip address
|
||||
if (ipVO.getElastic()) {
|
||||
throw new InvalidParameterValueException("Can't release elastic IP address " + ipVO);
|
||||
}
|
||||
|
||||
boolean success = releasePublicIpAddress(ipAddressId, userId, caller);
|
||||
if (success) {
|
||||
Long vmId = ipVO.getAssociatedWithVmId();
|
||||
UserVm vm = null;
|
||||
if (vmId != null) {
|
||||
vm = _userVmDao.findById(vmId);
|
||||
return _rulesMgr.enableElasticIpAndStaticNatForVm(vm, true);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
s_logger.warn("Failed to release public ip address id=" + ipAddressId);
|
||||
|
|
|
|||
|
|
@ -1022,22 +1022,13 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
Account caller = ctx.getCaller();
|
||||
IPAddressVO ipAddress = _ipAddressDao.findById(ipId);
|
||||
checkIpAndUserVm(ipAddress, null, caller);
|
||||
|
||||
Long vmId = ipAddress.getAssociatedWithVmId();
|
||||
|
||||
if (ipAddress.getElastic()) {
|
||||
throw new InvalidParameterValueException("Can't release elastic IP address " + ipAddress);
|
||||
}
|
||||
|
||||
boolean success = disableStaticNat(ipId, caller, ctx.getCallerUserId(), false);
|
||||
if (success && vmId != null) {
|
||||
s_logger.debug("Allocating ip and enabling static nat for vm id=" + vmId + " as a part of disassociateIp command");
|
||||
UserVm vm = _vmDao.findById(vmId);
|
||||
success = enableElasticIpAndStaticNatForVm(vm, true);
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to allocate ip and enable static nat for vm id=" + vmId + " as a part of disassociateIp command");
|
||||
} else {
|
||||
s_logger.debug("Successfully allocated ip and enabled static nat for vm id=" + vmId + " as a part of disassociateIp command");
|
||||
}
|
||||
}
|
||||
return disableStaticNat(ipId, caller, ctx.getCallerUserId(), false);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override @DB
|
||||
|
|
|
|||
Loading…
Reference in New Issue