cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wid...@apache.org
Subject [46/50] [abbrv] git commit: updated refs/heads/disk-cache to 72f2f12
Date Tue, 03 Sep 2013 11:09:51 GMT
CLOUDSTACK-4566: fix incorrect values in resource_count table for resource limitation

There are three issues in resource_count table
(1) expunge a vm, the public_ip decreases and becomes -1 in basic zone.
(2) recover a vm, the volume increase.
(3) restore a vm, the volume decrease.


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

Branch: refs/heads/disk-cache
Commit: a16fd4781c6c86495df419832df9f80d29597ded
Parents: 62b09c9
Author: Wei Zhou <w.zhou@leaseweb.com>
Authored: Fri Aug 30 08:51:01 2013 +0200
Committer: Wei Zhou <w.zhou@leaseweb.com>
Committed: Mon Sep 2 16:56:34 2013 +0200

----------------------------------------------------------------------
 server/src/com/cloud/network/IpAddressManagerImpl.java | 2 +-
 server/src/com/cloud/vm/UserVmManagerImpl.java         | 6 ++++--
 server/test/com/cloud/vm/UserVmManagerTest.java        | 5 ++++-
 3 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a16fd478/server/src/com/cloud/network/IpAddressManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java b/server/src/com/cloud/network/IpAddressManagerImpl.java
index 5f06c48..f60709f 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -773,7 +773,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
         }
         addr.setState(assign ? IpAddress.State.Allocated : IpAddress.State.Allocating);
 
-        if (vlanUse != VlanType.DirectAttached || zone.getNetworkType() == NetworkType.Basic)
{
+        if (vlanUse != VlanType.DirectAttached) {
             addr.setAssociatedWithNetworkId(guestNetworkId);
             addr.setVpcId(vpcId);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a16fd478/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 20f5fda..435d964 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1471,8 +1471,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
         }
 
         //Update Resource Count for the given account
-        _resourceLimitMgr.incrementResourceCount(account.getId(),
-                ResourceType.volume, new Long(volumes.size()));
         resourceCountIncrement(account.getId(), new Long(serviceOffering.getCpu()),
                 new Long(serviceOffering.getRamSize()));
         txn.commit();
@@ -4837,6 +4835,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Vir
         } else {
             newVol = volumeMgr.allocateDuplicateVolume(root, null);
         }
+        // Save usage event and update resource count for user vm volumes
+        if (vm instanceof UserVm) {
+            _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.volume);
+        }
 
         _volsDao.attachVolume(newVol.getId(), vmId, newVol.getDeviceId());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a16fd478/server/test/com/cloud/vm/UserVmManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/UserVmManagerTest.java b/server/test/com/cloud/vm/UserVmManagerTest.java
index 1bb25ac..df676d3 100755
--- a/server/test/com/cloud/vm/UserVmManagerTest.java
+++ b/server/test/com/cloud/vm/UserVmManagerTest.java
@@ -74,6 +74,7 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.AccountService;
 import com.cloud.user.AccountVO;
+import com.cloud.user.ResourceLimitService;
 import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
@@ -112,6 +113,7 @@ public class UserVmManagerTest {
     @Mock ServiceOfferingDao _offeringDao;
     @Mock
     EntityManager _entityMgr;
+    @Mock ResourceLimitService _resourceLimitMgr;
 
     @Before
     public void setup(){
@@ -130,6 +132,7 @@ public class UserVmManagerTest {
         _userVmMgr._configMgr = _configMgr;
         _userVmMgr._offeringDao= _offeringDao;
         _userVmMgr._capacityMgr = _capacityMgr;
+        _userVmMgr._resourceLimitMgr = _resourceLimitMgr;
         _userVmMgr._scaleRetry = 2;
         _userVmMgr._entityMgr = _entityMgr;
 
@@ -568,4 +571,4 @@ public class UserVmManagerTest {
         }
     }
 
-}
\ No newline at end of file
+}


Mime
View raw message