From 8d8a0ebe109ae6e9896caee945e29fd8ac778d2c Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Fri, 19 Apr 2013 23:16:47 +0530 Subject: [PATCH] CLOUDSTACK-2105. While releasing an IP range from an acount if any of the Public IPs in the range is a source nat ip then the IP is not disassociated. During the check CS also checks if the network the IP is associted with is not null. This results in an NPE for an account that has VPC s because the public IP of a VPC domain router is common to all VPC tiers and not associated with a network Remove the check to find the network associted with a source nat IP for both ReleasePublicIpRange and DeleteVlanPublicIpRange --- .../cloud/configuration/ConfigurationManagerImpl.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index d142ca6254d..b5734a290ce 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -2673,9 +2673,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati " as ip " + ip + " belonging to the range is used for static nat purposes. Cleanup the rules first"); } - if (ip.isSourceNat() && _networkModel.getNetwork(ip.getAssociatedWithNetworkId()) != null) { - throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId + - " as ip " + ip + " belonging to the range is a source nat ip for the network id=" + ip.getSourceNetworkId() + + if (ip.isSourceNat()) { + throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId + + " as ip " + ip + " belonging to the range is a source nat ip for the network id=" + ip.getSourceNetworkId() + ". IP range with the source nat ip address can be removed either as a part of Network, or account removal"); } @@ -2829,8 +2829,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati List ips = _publicIpAddressDao.listByVlanId(vlanDbId); for (IPAddressVO ip : ips) { // Disassociate allocated IP's that are not in use - if ( !ip.isOneToOneNat() && !(ip.isSourceNat() && _networkModel.getNetwork(ip.getAssociatedWithNetworkId()) != null) && - !(_firewallDao.countRulesByIpId(ip.getId()) > 0) ) { + if ( !ip.isOneToOneNat() && !ip.isSourceNat() && !(_firewallDao.countRulesByIpId(ip.getId()) > 0) ) { if (s_logger.isDebugEnabled()) { s_logger.debug("Releasing Public IP addresses" + ip +" of vlan " + vlanDbId + " as part of Public IP" + " range release to the system pool");