You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/06/27 22:57:18 UTC

[16/50] [abbrv] git commit: updated refs/heads/vmsync to 3c2aa18

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/8a1fefc7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8a1fefc7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8a1fefc7

Branch: refs/heads/vmsync
Commit: 8a1fefc7aa9290c654859b58f85682126eb7c36a
Parents: 4b3c012
Author: Likitha Shetty <li...@citrix.com>
Authored: Thu Jun 20 15:49:44 2013 +0530
Committer: Likitha Shetty <li...@citrix.com>
Committed: Wed Jun 26 10:51:39 2013 +0530

----------------------------------------------------------------------
 .../cloud/configuration/ConfigurationManagerImpl.java | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8a1fefc7/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 704162e..48728f7 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -3471,6 +3471,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         long allocIpCount = _publicIpAddressDao.countIPs(vlan.getDataCenterId(), vlanDbId, true);
         List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId);
         boolean success = true;
+        List<IPAddressVO> ipsInUse = new ArrayList<IPAddressVO>();
         if (allocIpCount > 0) {
             try {
                 vlan = _vlanDao.acquireInLockTable(vlanDbId, 30);
@@ -3488,6 +3489,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                                     + " as part of Public IP" + " range release to the system pool");
                         }
                         success = success && _networkMgr.disassociatePublicIpAddress(ip.getId(), userId, caller);
+                    } else {
+                        ipsInUse.add(ip);
                     }
                 }
                 if (!success) {
@@ -3501,12 +3504,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(