cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/master to 730d045
Date Tue, 30 Jul 2013 21:51:10 GMT
Updated Branches:
  refs/heads/master 9f66d18de -> 730d04508


CLOUDSTACK-3857: create VOLUME_CREATE event at CreateVolumeCmd instead
of at AttachVolumeCmd.


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

Branch: refs/heads/master
Commit: 730d04508507409065a432e2aac931225947f268
Parents: 9f66d18
Author: Min Chen <min.chen@citrix.com>
Authored: Tue Jul 30 14:50:46 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Tue Jul 30 14:51:02 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/storage/VolumeManagerImpl.java    | 51 ++++++--------------
 1 file changed, 16 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/730d0450/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index e3ba4b7..3cce8b6 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -105,9 +105,8 @@ import com.cloud.domain.Domain;
 import com.cloud.domain.dao.DomainDao;
 import com.cloud.event.ActionEvent;
 import com.cloud.event.EventTypes;
-import com.cloud.event.UsageEventVO;
+import com.cloud.event.UsageEventUtils;
 import com.cloud.event.dao.EventDao;
-import com.cloud.event.dao.UsageEventDao;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientStorageCapacityException;
 import com.cloud.exception.InvalidParameterValueException;
@@ -271,8 +270,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
     @Inject
     protected ClusterDao _clusterDao;
     @Inject
-    protected UsageEventDao _usageEventDao;
-    @Inject
     protected VirtualMachineManager _vmMgr;
     @Inject
     protected DomainRouterDao _domrDao;
@@ -606,13 +603,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         createdVolume = createVolumeFromSnapshot(volume,
                 snapshot);
 
-        UsageEventVO usageEvent = new UsageEventVO(
-                EventTypes.EVENT_VOLUME_CREATE,
-                createdVolume.getAccountId(),
-                createdVolume.getDataCenterId(), createdVolume.getId(),
-                createdVolume.getName(), createdVolume.getDiskOfferingId(),
-                null, createdVolume.getSize());
-        _usageEventDao.persist(usageEvent);
+        UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, createdVolume.getAccountId(),
createdVolume.getDataCenterId(), createdVolume.getId(),
+                createdVolume.getName(), createdVolume.getDiskOfferingId(), null, createdVolume.getSize(),
Volume.class.getName(), createdVolume.getUuid());
 
         return _volsDao.findById(createdVolume.getId());
     }
@@ -704,12 +696,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                 throw new CloudRuntimeException("create volume failed:" + result.getResult());
             }
 
-
-            UsageEventVO usageEvent = new UsageEventVO(
-                    EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(),
-                    volume.getDataCenterId(), volume.getId(), volume.getName(),
-                    volume.getDiskOfferingId(), null, volume.getSize());
-            _usageEventDao.persist(usageEvent);
             return result.getVolume();
         } catch (InterruptedException e) {
             s_logger.error("create volume failed", e);
@@ -1028,6 +1014,11 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         }
 
         volume = _volsDao.persist(volume);
+        if (cmd.getSnapshotId() == null) {
+            // for volume created from snapshot, create usage event after volume creation
+            UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(),
volume.getDataCenterId(), volume.getId(), volume.getName(), diskOfferingId,
+                    null, size, Volume.class.getName(), volume.getUuid());
+        }
 
         CallContext.current().setEventDetails("Volume Id: " + volume.getId());
 
@@ -1260,10 +1251,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
             }
             _volsDao.update(volume.getId(), volume);
             // Log usage event for volumes belonging user VM's only
-            UsageEventVO usageEvent = new UsageEventVO(
-                    EventTypes.EVENT_VOLUME_RESIZE, volume.getAccountId(),
-                    volume.getDataCenterId(), volume.getId(), volume.getName(), volume.getDiskOfferingId(),
volume.getTemplateId(), volume.getSize());
-            _usageEventDao.persist(usageEvent);
+            UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_RESIZE, volume.getAccountId(),
volume.getDataCenterId(), volume.getId(), volume.getName(),
+                    volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(),
Volume.class.getName(), volume.getUuid());
 
             /* Update resource count for the account on primary storage resource */
             if (!shrinkOk) {
@@ -1342,10 +1331,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                     }
 
                     // Log usage event for volumes belonging user VM's only
-                    UsageEventVO usageEvent = new UsageEventVO(
-                            EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(),
-                            volume.getDataCenterId(), volume.getId(), volume.getName());
-                    _usageEventDao.persist(usageEvent);
+                    UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(),
volume.getDataCenterId(), volume.getId(), volume.getName(),
+                            Volume.class.getName(), volume.getUuid());
                 }
             }
             // expunge volume from primary if volume is on primary
@@ -1418,11 +1405,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         // Save usage event and update resource count for user vm volumes
         if (vm instanceof UserVm) {
 
-            UsageEventVO usageEvent = new UsageEventVO(
-                    EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(),
-                    vol.getDataCenterId(), vol.getId(), vol.getName(),
-                    offering.getId(), null, size);
-            _usageEventDao.persist(usageEvent);
+            UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(),
vol.getDataCenterId(), vol.getId(), vol.getName(), offering.getId(), null, size,
+                    Volume.class.getName(), vol.getUuid());
 
             _resourceLimitMgr.incrementResourceCount(vm.getAccountId(),
                     ResourceType.volume);
@@ -1469,11 +1453,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                 offeringId = offering.getId();
             }
 
-            UsageEventVO usageEvent = new UsageEventVO(
-                    EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(),
-                    vol.getDataCenterId(), vol.getId(), vol.getName(),
-                    offeringId, template.getId(), vol.getSize());
-            _usageEventDao.persist(usageEvent);
+            UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(),
vol.getDataCenterId(), vol.getId(), vol.getName(), offeringId, null, size,
+                    Volume.class.getName(), vol.getUuid());
 
             _resourceLimitMgr.incrementResourceCount(vm.getAccountId(),
                     ResourceType.volume);


Mime
View raw message