Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0531310EF5 for ; Wed, 26 Jun 2013 05:31:17 +0000 (UTC) Received: (qmail 55756 invoked by uid 500); 26 Jun 2013 05:31:16 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 55577 invoked by uid 500); 26 Jun 2013 05:31:16 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 55569 invoked by uid 99); 26 Jun 2013 05:31:15 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jun 2013 05:31:15 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9F7141CA8A; Wed, 26 Jun 2013 05:31:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: likithas@apache.org To: commits@cloudstack.apache.org Message-Id: <428859dec82e4a44bbf092be7b002070@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master-6-17-stable to bc8cd34 Date: Wed, 26 Jun 2013 05:31:15 +0000 (UTC) Updated Branches: refs/heads/master-6-17-stable 85e55136c -> bc8cd3466 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. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/bc8cd346 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/bc8cd346 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/bc8cd346 Branch: refs/heads/master-6-17-stable Commit: bc8cd34662dee1902c1be5afdc63704a7ef01195 Parents: 85e5513 Author: Likitha Shetty Authored: Thu Jun 20 15:49:44 2013 +0530 Committer: Likitha Shetty Committed: Wed Jun 26 10:57:39 2013 +0530 ---------------------------------------------------------------------- .../cloud/configuration/ConfigurationManagerImpl.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc8cd346/server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 59672ad..22bb883 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -3256,6 +3256,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati long allocIpCount = _publicIpAddressDao.countIPs(vlan.getDataCenterId(), vlanDbId, true); List ips = _publicIpAddressDao.listByVlanId(vlanDbId); boolean success = true; + List ipsInUse = new ArrayList(); if (allocIpCount > 0) { try { vlan = _vlanDao.acquireInLockTable(vlanDbId, 30); @@ -3273,6 +3274,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati " range release to the system pool"); } success = success && _networkMgr.disassociatePublicIpAddress(ip.getId(), userId, caller); + } else { + ipsInUse.add(ip); } } if (!success) { @@ -3286,11 +3289,13 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati // A Public IP range can only be dedicated to one account at a time if (_accountVlanMapDao.remove(acctVln.get(0).getId())) { - // generate usage events to remove dedication for every ip in the range + // generate usage events to remove dedication for every ip in the range that has been disassociated for (IPAddressVO ip : ips) { - UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getAccountId(), - ip.getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(), vlan.getVlanType().toString(), - ip.getSystem(), ip.getClass().getName(), ip.getUuid()); + if (!ipsInUse.contains(ip)) { + UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getAccountId(), ip + .getDataCenterId(), ip.getId(), ip.getAddress().toString(), ip.isSourceNat(), vlan + .getVlanType().toString(), ip.getSystem(), ip.getClass().getName(), ip.getUuid()); + } } // decrement resource count for dedicated public ip's _resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(), ResourceType.public_ip, new Long(ips.size()));