cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/master to 0c9c5a7
Date Mon, 30 Jun 2014 21:41:50 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master e6f8833b9 -> 0c9c5a71b


CLOUDSTACK-4364: Restore VM - log a usage event for newly created volume


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

Branch: refs/heads/master
Commit: 0c9c5a71b4bcddf89381d6d3f66c5b83905c94d9
Parents: e6f8833
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Mon Jun 30 14:36:57 2014 -0700
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Mon Jun 30 14:41:37 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 5 ++++-
 server/test/com/cloud/vm/UserVmManagerTest.java | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c9c5a71/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 25c3eeb..3df05e0 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -4683,10 +4683,13 @@ 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
+        // 1. Save usage event and update resource count for user vm volumes
         if (vm instanceof UserVm) {
             _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.volume);
         }
+        //2. Create Usage event for the newly created volume
+        UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, newVol.getAccountId(),
newVol.getDataCenterId(), newVol.getId(), newVol.getName(), newVol.getDiskOfferingId(), templateId,
newVol.getSize());
+        _usageEventDao.persist(usageEvent);
 
         handleManagedStorage(vm, root);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c9c5a71/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 a69f270..3188d04 100755
--- a/server/test/com/cloud/vm/UserVmManagerTest.java
+++ b/server/test/com/cloud/vm/UserVmManagerTest.java
@@ -36,6 +36,7 @@ import java.util.List;
 import java.util.UUID;
 
 import com.cloud.storage.Storage;
+import com.cloud.event.dao.UsageEventDao;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -146,6 +147,8 @@ public class UserVmManagerTest {
     ResourceLimitService _resourceLimitMgr;
     @Mock
     PrimaryDataStoreDao _storagePoolDao;
+    @Mock
+    UsageEventDao _usageEventDao;
 
     @Before
     public void setup() {
@@ -155,6 +158,7 @@ public class UserVmManagerTest {
         _userVmMgr._vmInstanceDao = _vmInstanceDao;
         _userVmMgr._templateDao = _templateDao;
         _userVmMgr._volsDao = _volsDao;
+        _userVmMgr._usageEventDao = _usageEventDao;
         _userVmMgr._itMgr = _itMgr;
         _userVmMgr.volumeMgr = _storageMgr;
         _userVmMgr._accountDao = _accountDao;


Mime
View raw message