incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: CLOUDSTACK-348: decrement resource count when the network gets removed
Date Tue, 16 Oct 2012 23:51:08 GMT
Updated Branches:
  refs/heads/master c762830fb -> a9fab0526


CLOUDSTACK-348: decrement resource count when the network gets removed

Conflicts:

	server/src/com/cloud/network/NetworkManagerImpl.java


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a9fab052
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a9fab052
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a9fab052

Branch: refs/heads/master
Commit: a9fab0526b466fffa398c522e876a558554e793e
Parents: c762830
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Tue Oct 16 16:09:49 2012 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue Oct 16 16:18:36 2012 -0700

----------------------------------------------------------------------
 .../src/com/cloud/network/NetworkManagerImpl.java  |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a9fab052/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index cf5b6e3..2eff189 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -2726,8 +2726,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
             s_logger.warn("Only guest networks can be created using this method");
             return null;
         }
-        
-        boolean updateResourceCount = (!ntwkOff.getSpecifyVlan() && aclType == ACLType.Account);
+
+        boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, aclType);
         //check resource limits
         if (updateResourceCount) {
             _resourceLimitMgr.checkResourceLimit(owner, ResourceType.network);
@@ -3587,6 +3587,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
                 network.setState(Network.State.Destroy);
                 _networksDao.update(network.getId(), network);
                 _networksDao.remove(network.getId());
+                
+                NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
+                boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());
+                if (updateResourceCount) {
+                    _resourceLimitMgr.decrementResourceCount(owner.getId(), ResourceType.network);
+                }
                 txn.commit();
             }
         }
@@ -3594,6 +3600,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService,
Manag
         return success;
     }
 
+    private boolean resourceCountNeedsUpdate(NetworkOffering ntwkOff, ACLType aclType) {
+        boolean updateResourceCount = (!ntwkOff.getSpecifyVlan() && aclType == ACLType.Account);
+        return updateResourceCount;
+    }
+
     protected boolean deleteVlansInNetwork(long networkId, long userId, Account callerAccount)
{
         
         //cleanup Public vlans


Mime
View raw message