You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mt...@apache.org on 2014/07/19 08:42:40 UTC

git commit: updated refs/heads/master to 08d7b46

Repository: cloudstack
Updated Branches:
  refs/heads/master 88f866645 -> 08d7b46be


Update to volume-resize logic


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

Branch: refs/heads/master
Commit: 08d7b46be748794773df1f549d3b3dc98068861f
Parents: 88f8666
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Fri Jul 18 12:02:52 2014 -0600
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Sat Jul 19 00:42:04 2014 -0600

----------------------------------------------------------------------
 .../driver/SolidFirePrimaryDataStoreDriver.java |  2 +-
 .../com/cloud/storage/VolumeApiServiceImpl.java | 24 ++++++++++++++++----
 2 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/08d7b46b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
index 5a23fcf..2228c59 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
@@ -423,7 +423,7 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
             SolidFireUtil.modifySolidFireVolume(sfConnection, sfVolumeId, sfVolume.getTotalSize(), payload.newMinIops, payload.newMaxIops,
                     getDefaultBurstIops(storagePoolId, payload.newMaxIops));
 
-            VolumeVO volume = _volumeDao.findById(sfVolumeId);
+            VolumeVO volume = _volumeDao.findById(volumeInfo.getId());
 
             volume.setMinIops(payload.newMinIops);
             volume.setMaxIops(payload.newMaxIops);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/08d7b46b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 49cb520..64d6bc0 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -733,12 +733,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
         DiskOfferingVO newDiskOffering = _diskOfferingDao.findById(cmd.getNewDiskOfferingId());
 
-        /* Only works for KVM/XenServer/VMware for now, and volumes with 'None' since they're just allocated in DB */
+        /* Only works for KVM/XenServer/VMware (or "Any") for now, and volumes with 'None' since they're just allocated in DB */
 
         HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId());
 
         if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.XenServer &&
-            hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.None) {
+            hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Any && hypervisorType != HypervisorType.None) {
             throw new InvalidParameterValueException("CloudStack currently only supports volumes marked as the KVM, VMware, or XenServer hypervisor type for resize.");
         }
 
@@ -808,6 +808,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                 throw new InvalidParameterValueException("There are no tags on the current disk offering. The new disk offering needs to have no tags, as well.");
             }
 
+            if (!areIntegersEqual(diskOffering.getHypervisorSnapshotReserve(), newDiskOffering.getHypervisorSnapshotReserve())) {
+                throw new InvalidParameterValueException("The hypervisor snapshot reverse on the new and old disk offerings must be equal.");
+            }
+
             if (newDiskOffering.getDomainId() != null) {
                 // not a public offering; check access
                 _configMgr.checkDiskOfferingAccess(CallContext.current().getCallingAccount(), newDiskOffering);
@@ -945,6 +949,18 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                 newDiskOffering != null ? cmd.getNewDiskOfferingId() : null, shrinkOk);
     }
 
+    private static boolean areIntegersEqual(Integer i1, Integer i2) {
+        if (i1 == null) {
+            i1 = 0;
+        }
+
+        if (i2 == null) {
+            i2 = 0;
+        }
+
+        return i1.equals(i2);
+    }
+
     private void validateIops(Long minIops, Long maxIops) {
         if ((minIops == null && maxIops != null) || (minIops != null && maxIops == null)) {
             throw new InvalidParameterValueException("Either 'miniops' and 'maxiops' must both be provided or neither must be provided.");
@@ -999,14 +1015,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
             StoragePoolVO storagePool = _storagePoolDao.findById(vol.getPoolId());
 
-            if (storagePool.isManaged()) {
+            if (currentSize != newSize && storagePool.isManaged()) {
                 if (hosts.length > 0) {
                     volService.resizeVolumeOnHypervisor(volumeId, newSize, hosts[0], instanceName);
                 }
 
                 volume.setSize(newSize);
-
-                /** @todo let the storage driver know the CloudStack volume within the storage volume in question has a new size */
             }
 
             if (newDiskOfferingId != null) {