cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject [16/50] [abbrv] git commit: updated refs/heads/network_acl to 1609d01
Date Fri, 03 May 2013 13:14:58 GMT
CLOUDSTACK-2087: Destroying the instance is not decrementing the primary storage usage [Resource
Count table - No of volumes is not got decremented]

Signed-off-by: Sateesh Chodapuneedi <sateesh@apache.org>


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

Branch: refs/heads/network_acl
Commit: 85a1cc962cb39baafd0aeb3457eeb227e848aef9
Parents: 1f14679
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Tue Apr 23 10:01:56 2013 +0530
Committer: Sateesh Chodapuneedi <sateesh@apache.org>
Committed: Thu May 2 16:17:13 2013 +0530

----------------------------------------------------------------------
 .../resourcelimit/ResourceLimitManagerImpl.java    |    2 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |   11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85a1cc96/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
index e8805ae..5bb7708 100755
--- a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
+++ b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
@@ -582,7 +582,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
         }
 
         //Convert max storage size from GiB to bytes
-        if (resourceType == ResourceType.primary_storage || resourceType == ResourceType.secondary_storage)
{
+        if ((resourceType == ResourceType.primary_storage || resourceType == ResourceType.secondary_storage)
&& max >= 0) {
             max = max * ResourceType.bytesToGiB;
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85a1cc96/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index b0d6378..afffbec 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -64,6 +64,7 @@ import com.cloud.alert.AlertManager;
 import com.cloud.cluster.ClusterManager;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
+import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.DataCenter;
@@ -131,6 +132,7 @@ import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.storage.snapshot.SnapshotManager;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
+import com.cloud.user.ResourceLimitService;
 import com.cloud.user.User;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
@@ -231,6 +233,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     protected VMSnapshotDao _vmSnapshotDao;
     @Inject
     protected VolumeDataFactory volFactory;
+    @Inject
+    protected ResourceLimitService _resourceLimitMgr;
 
     protected List<DeploymentPlanner> _planners;
     public List<DeploymentPlanner> getPlanners() {
@@ -428,6 +432,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         s_logger.debug("Cleaning up NICS");
         _networkMgr.cleanupNics(profile);
         // Clean up volumes based on the vm's instance id
+        List<VolumeVO> rootVol = _volsDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
         this.volumeMgr.cleanupVolumes(vm.getId());
 
         VirtualMachineGuru<T> guru = getVmGuru(vm);
@@ -462,6 +467,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
             s_logger.debug("Expunged " + vm);
         }
 
+        // Update Resource count
+        if (vm.getAccountId() != Account.ACCOUNT_ID_SYSTEM && !rootVol.isEmpty())
{
+            _resourceLimitMgr.decrementResourceCount(vm.getAccountId(), ResourceType.volume);
+            _resourceLimitMgr.decrementResourceCount(vm.getAccountId(), ResourceType.primary_storage,
+                    new Long(rootVol.get(0).getSize()));
+        }
         return true;
     }
 


Mime
View raw message