Skip to content

Commit 8a1fefc

Browse files
author
Likitha Shetty
committed
CLOUDSTACK-3192. When a dedicated public ip range is released, don't generate usage event EVENT_NET_IP_RELEASE
for ips in the range that are in use becauase these ips are not disassociated from the account.
1 parent 4b3c012 commit 8a1fefc

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎server/src/com/cloud/configuration/ConfigurationManagerImpl.java‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,6 +3471,7 @@ public boolean releasePublicIpRange(long vlanDbId, long userId, Account caller)
34713471
long allocIpCount = _publicIpAddressDao.countIPs(vlan.getDataCenterId(), vlanDbId, true);
34723472
List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
34733473
boolean success = true;
3474+
List<IPAddressVO> ipsInUse = new ArrayList<IPAddressVO>();
34743475
if (allocIpCount > 0) {
34753476
try {
34763477
vlan = _vlanDao.acquireInLockTable(vlanDbId, 30);
@@ -3488,6 +3489,8 @@ public boolean releasePublicIpRange(long vlanDbId, long userId, Account caller)
34883489
+ " as part of Public IP" + " range release to the system pool");
34893490
}
34903491
success = success && _networkMgr.disassociatePublicIpAddress(ip.getId(), userId, caller);
3492+
} else {
3493+
ipsInUse.add(ip);
34913494
}
34923495
}
34933496
if (!success) {
@@ -3501,12 +3504,13 @@ public boolean releasePublicIpRange(long vlanDbId, long userId, Account caller)
35013504

35023505
// A Public IP range can only be dedicated to one account at a time
35033506
if (_accountVlanMapDao.remove(acctVln.get(0).getId())) {
3504-
// generate usage events to remove dedication for every ip in the
3505-
// range
3507+
// generate usage events to remove dedication for every ip in the range that has been disassociated
35063508
for (IPAddressVO ip : ips) {
3507-
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getAccountId(), ip
3508-
.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(), vlan
3509-
.getVlanType().toString(), ip.getSystem(), ip.getClass().getName(), ip.getUuid());
3509+
if (!ipsInUse.contains(ip)) {
3510+
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getAccountId(), ip
3511+
.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(), vlan
3512+
.getVlanType().toString(), ip.getSystem(), ip.getClass().getName(), ip.getUuid());
3513+
}
35103514
}
35113515
// decrement resource count for dedicated public ip's
35123516
_resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(), ResourceType.public_ip, new Long(

0 commit comments

Comments
 (0)