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/4.4-forward to 1e78354
Date Mon, 30 Jun 2014 21:37:08 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward a34faae91 -> 1e7835488


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

Branch: refs/heads/4.4-forward
Commit: 1e7835488222471a565174ee1fdf8bb985fc9024
Parents: a34faae
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:36:57 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/1e783548/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 a7ba087..425598c 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -4673,10 +4673,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/1e783548/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 b67c164..21cebb5 100755
--- a/server/test/com/cloud/vm/UserVmManagerTest.java
+++ b/server/test/com/cloud/vm/UserVmManagerTest.java
@@ -35,6 +35,7 @@ import java.lang.reflect.Field;
 import java.util.List;
 import java.util.UUID;
 
+import com.cloud.event.dao.UsageEventDao;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -145,6 +146,8 @@ public class UserVmManagerTest {
     ResourceLimitService _resourceLimitMgr;
     @Mock
     PrimaryDataStoreDao _storagePoolDao;
+    @Mock
+    UsageEventDao _usageEventDao;
 
     @Before
     public void setup() {
@@ -154,6 +157,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