cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [09/50] [abbrv] git commit: updated refs/heads/marvin_refactor to 2a99064
Date Tue, 09 Apr 2013 13:20:46 GMT
CLOUDSTACK-1608: enable attach a volume created on zone wide storage to a vm created on cluster
or host wide storage


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

Branch: refs/heads/marvin_refactor
Commit: 7d4fd16691a144bf1adce4c40ca2145a7f1f7048
Parents: 8b15988
Author: Edison Su <sudison@gmail.com>
Authored: Tue Mar 19 14:45:17 2013 -0700
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Sun Mar 31 22:01:24 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/storage/VolumeManagerImpl.java   |  107 ++++-----------
 1 files changed, 28 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7d4fd166/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 ff0235f..1bf092f 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -146,7 +146,6 @@ import com.cloud.uservm.UserVm;
 import com.cloud.utils.EnumUtils;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
-import com.cloud.utils.UriUtils;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.JoinBuilder;
@@ -470,10 +469,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         }
         validateUrl(url);
 
-        // Check that the resource limit for secondary storage won't be exceeded
-        _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.secondary_storage,
-                UriUtils.getRemoteSize(url));
-
         return false;
     }
     
@@ -741,8 +736,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         // decrement it
         _resourceLimitMgr.incrementResourceCount(volume.getAccountId(),
                 ResourceType.volume);
-        _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage,
-                UriUtils.getRemoteSize(url));
 
         txn.commit();
         return volume;
@@ -913,10 +906,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
             _accountMgr.checkAccess(caller, null, true, snapshotCheck);
         }
 
-        // Check that the resource limit for primary storage won't be exceeded
-        _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.primary_storage,
-                new Long(size));
-
         // Verify that zone exists
         DataCenterVO zone = _dcDao.findById(zoneId);
         if (zone == null) {
@@ -985,8 +974,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         // decrement it
         _resourceLimitMgr.incrementResourceCount(volume.getAccountId(),
                 ResourceType.volume);
-        _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage,
-                new Long(volume.getSize()));
 
         txn.commit();
 
@@ -1019,8 +1006,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                         + " as volume failed to create on the backend");
                 _resourceLimitMgr.decrementResourceCount(volume.getAccountId(),
                         ResourceType.volume);
-                _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage,
-                        new Long(volume.getSize()));
             }
         }
     }
@@ -1028,8 +1013,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
     @Override
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_VOLUME_RESIZE, eventDescription = "resizing
volume", async = true)
-    public VolumeVO resizeVolume(ResizeVolumeCmd cmd)
-            throws ResourceAllocationException {
+    public VolumeVO resizeVolume(ResizeVolumeCmd cmd) {
         Long newSize = null;
         boolean shrinkOk = cmd.getShrinkOk();
         
@@ -1165,12 +1149,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                             + " would shrink the volume, need to sign off by supplying the
shrinkok parameter with value of true");
         }
 
-        if (!shrinkOk) {
-            /* Check resource limit for this account on primary storage resource */
-            _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(volume.getAccountId()),
-                    ResourceType.primary_storage, new Long(newSize - currentSize));
-        }
-
         /*
          * get a list of hosts to send the commands to, try the system the
          * associated vm is running on first, then the last known place it ran.
@@ -1198,35 +1176,27 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         ResizeVolumePayload payload = new ResizeVolumePayload(newSize, shrinkOk, instanceName,
hosts);
         
         try {
-            VolumeInfo vol = this.volFactory.getVolume(volume.getId());
+        	VolumeInfo vol = this.volFactory.getVolume(volume.getId());
             vol.addPayload(payload);
-
-            AsyncCallFuture<VolumeApiResult> future = this.volService.resize(vol);
-            future.get();
-            volume = _volsDao.findById(volume.getId());
-
-            if (newDiskOffering != null) {
-                volume.setDiskOfferingId(cmd.getNewDiskOfferingId());
-            }
-            _volsDao.update(volume.getId(), volume);
-
-            /* Update resource count for the account on primary storage resource */
-            if (!shrinkOk) {
-                _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage,
-                        new Long(newSize - currentSize));
-            } else {
-                _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage,
-                        new Long(currentSize - newSize));
-            }
-            return volume;
-        } catch (InterruptedException e) {
-            s_logger.debug("failed get resize volume result", e);
-        } catch (ExecutionException e) {
-            s_logger.debug("failed get resize volume result", e);
-        } catch (Exception e) {
-            s_logger.debug("failed get resize volume result", e);
-        }
-
+            
+        	AsyncCallFuture<VolumeApiResult> future = this.volService.resize(vol);
+        	future.get();
+        	volume = _volsDao.findById(volume.getId());
+
+        	if (newDiskOffering != null) {
+        		volume.setDiskOfferingId(cmd.getNewDiskOfferingId());
+        	}
+        	_volsDao.update(volume.getId(), volume);
+
+        	return volume;
+		} catch (InterruptedException e) {
+			s_logger.debug("failed get resize volume result", e);
+		} catch (ExecutionException e) {
+			s_logger.debug("failed get resize volume result", e);
+		} catch (Exception e) {
+			s_logger.debug("failed get resize volume result", e);
+		}
+       
         return null;
     }
     
@@ -1273,19 +1243,9 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                 VMInstanceVO vmInstance = this._vmInstanceDao.findById(instanceId);
                 if (instanceId == null
                         || (vmInstance.getType().equals(VirtualMachine.Type.User))) {
-                    // Decrement the resource count for volumes and primary storage belonging
user VM's only
+                    // Decrement the resource count for volumes belonging user VM's only
                     _resourceLimitMgr.decrementResourceCount(volume.getAccountId(),
                             ResourceType.volume);
-                    /* If volume is in primary storage, decrement primary storage count else
decrement secondary
-                     storage count (in case of upload volume). */
-                    if (volume.getFolder() != null) {
-                        _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage,
-                                new Long(volume.getSize()));
-                    } else {
-                        _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(),
volume.getDomainId(),
-                                ResourceType.secondary_storage.getOrdinal());
-                    }
-
                     // Log usage event for volumes belonging user VM's only
                     UsageEventVO usageEvent = new UsageEventVO(
                             EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(),
@@ -1357,8 +1317,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
 
             _resourceLimitMgr.incrementResourceCount(vm.getAccountId(),
                     ResourceType.volume);
-            _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.primary_storage,
-                    new Long(vol.getSize()));
         }
         return toDiskProfile(vol, offering);
     }
@@ -1406,8 +1364,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
 
             _resourceLimitMgr.incrementResourceCount(vm.getAccountId(),
                     ResourceType.volume);
-            _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.primary_storage,
-                    new Long(vol.getSize()));
         }
         return toDiskProfile(vol, offering);
     }
@@ -1479,13 +1435,6 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
             vol = copyVolume(rootDiskPool
                     , volume, vm, rootDiskTmplt,  dcVO,
                     pod,  diskVO,  svo,  rootDiskHyperType);
-            if (vol != null) {
-                // Moving of Volume is successful, decrement the volume resource count from
secondary for an account and increment it into primary storage under same account.
-                _resourceLimitMgr.decrementResourceCount(volume.getAccountId(),
-                        ResourceType.secondary_storage, new Long(volume.getSize()));
-                _resourceLimitMgr.incrementResourceCount(volume.getAccountId(),
-                        ResourceType.primary_storage, new Long(volume.getSize()));
-            }
         }
         return vol;
     }
@@ -1498,23 +1447,23 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
         if (storeForRootStoreScope == null) {
             throw new CloudRuntimeException("Can't get scope of data store: " + storeForRootVol.getId());
         }
-        
+
         Scope storeForDataStoreScope = storeForDataVol.getScope();
         if (storeForDataStoreScope == null) {
             throw new CloudRuntimeException("Can't get scope of data store: " + storeForDataVol.getId());
         }
-        
+
         if (storeForDataStoreScope.getScopeType() == ScopeType.ZONE) {
             return false;
         }
-        
+
         if (storeForRootStoreScope.getScopeType() != storeForDataStoreScope.getScopeType())
{
             throw new CloudRuntimeException("Can't move volume between scope: " + storeForDataStoreScope.getScopeType()
+ " and " + storeForRootStoreScope.getScopeType());
         }
-       
+
         return !storeForRootStoreScope.isSameScope(storeForDataStoreScope);
     }
-    
+
     private VolumeVO sendAttachVolumeCommand(UserVmVO vm, VolumeVO volume, Long deviceId)
{
         String errorMsg = "Failed to attach volume: " + volume.getName()
                 + " to VM: " + vm.getHostName();
@@ -2184,7 +2133,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager
{
                                             + assignedPool
                                             + " assigned by deploymentPlanner");
                                 }
-                                VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE,
vol, assignedPool);
+                                VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE,
vol, null);
                                 tasks.add(task);
                             }
                         } else {


Mime
View raw message