mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Bug-Id: CS-27335: public_ip type resource count for an account is not decremented upon IP range deletion
Reviewed-By: Kishan/Bharat Signed-off-by: Maneesha.P <maneesha.papireddygari@citrix.com>
This commit is contained in:
parent
3df847dfbb
commit
865623fd1e
@ -3312,6 +3312,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||||||
// Check if the VLAN has any allocated public IPs
|
// Check if the VLAN has any allocated public IPs
|
||||||
final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
|
final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
|
||||||
if (isAccountSpecific) {
|
if (isAccountSpecific) {
|
||||||
|
int resourceCountToBeDecrement = 0;
|
||||||
try {
|
try {
|
||||||
vlanRange = _vlanDao.acquireInLockTable(vlanDbId, 30);
|
vlanRange = _vlanDao.acquireInLockTable(vlanDbId, 30);
|
||||||
if (vlanRange == null) {
|
if (vlanRange == null) {
|
||||||
@ -3338,19 +3339,23 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||||||
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId + " as ip " + ip
|
throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId + " as ip " + ip
|
||||||
+ " belonging to the range has firewall rules applied. Cleanup the rules first");
|
+ " belonging to the range has firewall rules applied. Cleanup the rules first");
|
||||||
}
|
}
|
||||||
if(ip.getAllocatedTime() != null) {// This means IP is allocated
|
if (ip.getAllocatedTime() != null) {// This means IP is allocated
|
||||||
// release public ip address here
|
// release public ip address here
|
||||||
success = _ipAddrMgr.disassociatePublicIpAddress(ip.getId(), userId, caller);
|
success = _ipAddrMgr.disassociatePublicIpAddress(ip.getId(), userId, caller);
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
s_logger.warn("Some ip addresses failed to be released as a part of vlan " + vlanDbId + " removal");
|
s_logger.warn("Some ip addresses failed to be released as a part of vlan " + vlanDbId + " removal");
|
||||||
} else {
|
} else {
|
||||||
|
resourceCountToBeDecrement++;
|
||||||
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getAccountId(), ip.getDataCenterId(), ip.getId(),
|
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getAccountId(), ip.getDataCenterId(), ip.getId(),
|
||||||
ip.getAddress().toString(), ip.isSourceNat(), vlanRange.getVlanType().toString(), ip.getSystem(), ip.getClass().getName(), ip.getUuid());
|
ip.getAddress().toString(), ip.isSourceNat(), vlanRange.getVlanType().toString(), ip.getSystem(), ip.getClass().getName(), ip.getUuid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
_vlanDao.releaseFromLockTable(vlanDbId);
|
_vlanDao.releaseFromLockTable(vlanDbId);
|
||||||
|
if (resourceCountToBeDecrement > 0) { //Making sure to decrement the count of only success operations above. For any reaason if disassociation fails then this number will vary from original range length.
|
||||||
|
_resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(), ResourceType.public_ip, new Long(resourceCountToBeDecrement));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else { // !isAccountSpecific
|
} else { // !isAccountSpecific
|
||||||
final NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(vlanRange.getVlanGateway(), vlanRange.getNetworkId(), NicIpAlias.state.active);
|
final NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(vlanRange.getVlanGateway(), vlanRange.getNetworkId(), NicIpAlias.state.active);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user