cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devd...@apache.org
Subject [2/3] git commit: updated refs/heads/4.2 to 78781ff
Date Mon, 29 Jul 2013 12:36:15 GMT
CLOUDSTACK-3846 usage event is not generated for volume resize


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

Branch: refs/heads/4.2
Commit: c5a95184cb8d52facda77462ec5cd3a6445fe8e5
Parents: 50fe9e1
Author: Rajesh Battala <rajesh.battala@citrix.com>
Authored: Sat Jul 27 20:28:41 2013 +0530
Committer: Devdeep Singh <devdeep@gmail.com>
Committed: Mon Jul 29 17:57:24 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/storage/VolumeManagerImpl.java    | 34 +++++++++++---------
 1 file changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c5a95184/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 a3802a9..b2623b9 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -31,9 +31,9 @@ import java.util.concurrent.ExecutionException;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
 import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
@@ -72,10 +72,9 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
 import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
+
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.storage.CreateVolumeOVAAnswer;
-import com.cloud.agent.api.storage.CreateVolumeOVACommand;
 import com.cloud.agent.api.to.DataTO;
 import com.cloud.agent.api.to.DiskTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
@@ -1265,6 +1264,11 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                 volume.setDiskOfferingId(cmd.getNewDiskOfferingId());
             }
             _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);
 
             /* Update resource count for the account on primary storage resource */
             if (!shrinkOk) {
@@ -1413,7 +1417,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
             vol.setDeviceId(1l);
         }
 
-        vol.setFormat(this.getSupportedImageFormatForCluster(vm.getHypervisorType()));
+        vol.setFormat(getSupportedImageFormatForCluster(vm.getHypervisorType()));
         vol = _volsDao.persist(vol);
 
         // Save usage event and update resource count for user vm volumes
@@ -1444,7 +1448,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(),
                 owner.getDomainId(), owner.getId(), offering.getId(), size,
                 offering.getMinIops(), offering.getMaxIops(), null);
-        vol.setFormat(this.getSupportedImageFormatForCluster(template.getHypervisorType()));
+        vol.setFormat(getSupportedImageFormatForCluster(template.getHypervisorType()));
         if (vm != null) {
             vol.setInstanceId(vm.getId());
         }
@@ -1556,10 +1560,10 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
             }
         }
 
-        VolumeVO volVO = this._volsDao.findById(vol.getId());
-        volVO.setFormat(this.getSupportedImageFormatForCluster(rootDiskHyperType));
-        this._volsDao.update(volVO.getId(), volVO);
-        return this.volFactory.getVolume(volVO.getId());
+        VolumeVO volVO = _volsDao.findById(vol.getId());
+        volVO.setFormat(getSupportedImageFormatForCluster(rootDiskHyperType));
+        _volsDao.update(volVO.getId(), volVO);
+        return volFactory.getVolume(volVO.getId());
     }
 
     private boolean needMoveVolume(VolumeVO rootVolumeOfVm, VolumeInfo volume) {
@@ -2103,7 +2107,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         for (VolumeVO vol : volumesForVm) {
             if (vol.getVolumeType().equals(Type.ROOT)) {
                 // Destroy volume if not already destroyed
-                boolean volumeAlreadyDestroyed = (vol.getState() == Volume.State.Destroy
|| 
+                boolean volumeAlreadyDestroyed = (vol.getState() == Volume.State.Destroy
||
                         vol.getState() == Volume.State.Expunged ||
                         vol.getState() == Volume.State.Expunging);
                 if (!volumeAlreadyDestroyed) {
@@ -2788,15 +2792,15 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
 
         // Clean up code to remove all those previous uploadVO and uploadMonitor code. Previous
code is trying to fake an async operation purely in
         // db table with uploadVO and async_job entry, but internal implementation is actually
synchronous.
-        StoragePool srcPool = (StoragePool) this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
-        ImageStoreEntity secStore = (ImageStoreEntity) this.dataStoreMgr.getImageStore(zoneId);
+        StoragePool srcPool = (StoragePool) dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
+        ImageStoreEntity secStore = (ImageStoreEntity) dataStoreMgr.getImageStore(zoneId);
         String secondaryStorageURL = secStore.getUri();
 
-        String value = this._configDao.getValue(Config.CopyVolumeWait.toString());
+        String value = _configDao.getValue(Config.CopyVolumeWait.toString());
         int copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue()));
         // Copy volume from primary to secondary storage
-        VolumeInfo srcVol = this.volFactory.getVolume(volume.getId());
-        AsyncCallFuture<VolumeApiResult> cvAnswer = this.volService.copyVolume(srcVol,
secStore);
+        VolumeInfo srcVol = volFactory.getVolume(volume.getId());
+        AsyncCallFuture<VolumeApiResult> cvAnswer = volService.copyVolume(srcVol, secStore);
         // Check if you got a valid answer.
         VolumeApiResult cvResult = null;
         try {


Mime
View raw message