cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weiz...@apache.org
Subject git commit: updated refs/heads/4.2-forward to 948014d
Date Fri, 30 Aug 2013 06:52:16 GMT
Updated Branches:
  refs/heads/4.2-forward 1ba591516 -> 948014dee


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

Branch: refs/heads/4.2-forward
Commit: 948014dee6af67d4bdd27301e23f4cdee695d9f1
Parents: 1ba5915
Author: Wei Zhou <w.zhou@leaseweb.com>
Authored: Fri Aug 30 08:51:01 2013 +0200
Committer: Wei Zhou <w.zhou@leaseweb.com>
Committed: Fri Aug 30 08:51:01 2013 +0200

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/948014de/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 472336c..fb1dcb1 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -508,7 +508,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
         }
         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/948014de/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 251c203..a970478 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1479,8 +1479,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
         }
 
         //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();
@@ -4878,6 +4876,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
         } 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/948014de/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 973b8bc..b113f5d 100755
--- a/server/test/com/cloud/vm/UserVmManagerTest.java
+++ b/server/test/com/cloud/vm/UserVmManagerTest.java
@@ -68,6 +68,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.UserContext;
 import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
@@ -104,6 +105,8 @@ public class UserVmManagerTest {
     @Mock List<VolumeVO> _rootVols;
     @Mock Account _accountMock2;
     @Mock ServiceOfferingDao _offeringDao;
+    @Mock ResourceLimitService _resourceLimitMgr;
+
     @Before
     public void setup(){
         MockitoAnnotations.initMocks(this);
@@ -121,6 +124,7 @@ public class UserVmManagerTest {
         _userVmMgr._configMgr = _configMgr;
         _userVmMgr._offeringDao= _offeringDao;
         _userVmMgr._capacityMgr = _capacityMgr;
+        _userVmMgr._resourceLimitMgr = _resourceLimitMgr;
         _userVmMgr._scaleRetry = 2;
 
         doReturn(3L).when(_account).getId();
@@ -488,4 +492,4 @@ public class UserVmManagerTest {
         _userVmMgr.moveVMToUser(cmd);
     }
 
-}
\ No newline at end of file
+}


Mime
View raw message